diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 101 | 
1 files changed, 61 insertions, 40 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index aa1e2dcb4..860422980 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -39,7 +39,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \      post_delete_record_relation, post_save_cache, RelationItem, \      ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile, \      document_attached_changed, HistoryModel, SearchAltName, \ -    GeoItem, QRCodeItem +    GeoItem, QRCodeItem, SearchVectorConfig  from ishtar_common.utils import cached_label_changed, \      force_cached_label_changed, mode, m2m_historization_changed, post_save_geo @@ -117,19 +117,23 @@ class ArchaeologicalSite(BaseHistorizedItem, QRCodeItem, GeoItem, OwnPerms,      LONG_SLUG = 'archaeologicalsite'      BASE_SEARCH_VECTORS = [ -        "comment", -        "discovery_area", -        "locality_cadastral", -        "locality_ngi", -        "name", -        "oceanographic_service_localisation", -        "reference", -        "shipwreck_code", -        "shipwreck_name", -        "drassm_number", -        "affmar_number", +        SearchVectorConfig("comment", 'local'), +        SearchVectorConfig("discovery_area", 'local'), +        SearchVectorConfig("locality_cadastral", 'local'), +        SearchVectorConfig("locality_ngi", 'local'), +        SearchVectorConfig("name"), +        SearchVectorConfig("oceanographic_service_localisation"), +        SearchVectorConfig("reference"), +        SearchVectorConfig("shipwreck_code"), +        SearchVectorConfig("shipwreck_name"), +        SearchVectorConfig("drassm_number"), +        SearchVectorConfig("affmar_number"), +    ] +    M2M_SEARCH_VECTORS = [ +        SearchVectorConfig("periods__label", "local"), +        SearchVectorConfig("remains__label", "local"), +        SearchVectorConfig("towns__name"),      ] -    M2M_SEARCH_VECTORS = ["periods__label", "remains__label", "towns__name"]      PARENT_SEARCH_VECTORS = ['operations']      DATED_FIELDS = ['sinking_date'] @@ -517,8 +521,9 @@ class Operation(ClosedItem, BaseHistorizedItem, QRCodeItem, GeoItem, OwnPerms,\      APP = "archaeological-operations"      MODEL = "operation"      SHOW_URL = 'show-operation' -    TABLE_COLS = ['year', 'towns_label', 'common_name', 'operation_type', -                  'start_date', 'excavation_end_date', 'remains'] +    TABLE_COLS = ['code_patriarche', 'year', 'towns_label', 'common_name', +                  'operation_type', 'start_date', 'excavation_end_date', +                  'remains']      # search parameters      BOOL_FIELDS = ['end_date__isnull', 'virtual_operation', @@ -583,28 +588,36 @@ class Operation(ClosedItem, BaseHistorizedItem, QRCodeItem, GeoItem, OwnPerms,\          'towns_label': _(u"Towns"),      }      BASE_SEARCH_VECTORS = [ -        "abstract", -        "address", -        "code_patriarche", -        "comment", -        "common_name", -        "in_charge__cached_label", -        "name_of_the_protagonist", -        "official_report_number", -        "old_code", -        "operation_type__label", -        "operator_reference", -        "operator__cached_label", -        "scientist__cached_label", -        "scientific_documentation_comment", -        "seizure_name", -        "drassm_code", +        SearchVectorConfig("abstract", "local"), +        SearchVectorConfig("address", "local"), +        SearchVectorConfig("code_patriarche"), +        SearchVectorConfig("comment", "local"), +        SearchVectorConfig("common_name"), +        SearchVectorConfig("common_name", "local"), +        SearchVectorConfig("in_charge__cached_label"), +        SearchVectorConfig("name_of_the_protagonist"), +        SearchVectorConfig("official_report_number"), +        SearchVectorConfig("old_code"), +        SearchVectorConfig("operation_type__label"), +        SearchVectorConfig("operator_reference"), +        SearchVectorConfig("operator__cached_label"), +        SearchVectorConfig("scientist__cached_label"), +        SearchVectorConfig("scientific_documentation_comment", "local"), +        SearchVectorConfig("seizure_name"), +        SearchVectorConfig("drassm_code"),      ]      PROPERTY_SEARCH_VECTORS = [ -        "full_reference", "short_code_patriarche" +        SearchVectorConfig("full_reference"), +        SearchVectorConfig("short_code_patriarche"), +    ] +    INT_SEARCH_VECTORS = [ +        SearchVectorConfig("year"), +    ] +    M2M_SEARCH_VECTORS = [ +        SearchVectorConfig("periods__label", "local"), +        SearchVectorConfig("remains__label", "local"), +        SearchVectorConfig("towns__name"),      ] -    INT_SEARCH_VECTORS = ["year"] -    M2M_SEARCH_VECTORS = ["periods__label", "remains__label", "towns__name"]      PARENT_SEARCH_VECTORS = ["associated_file"]      PARENT_ONLY_SEARCH_VECTORS = ["archaeological_sites"]      ASSOCIATED = { @@ -849,8 +862,6 @@ class Operation(ClosedItem, BaseHistorizedItem, QRCodeItem, GeoItem, OwnPerms,\      ## fr      code_patriarche = models.TextField(u"Code PATRIARCHE", null=True,                                         blank=True, unique=True) -    TABLE_COLS = ['code_patriarche'] + TABLE_COLS -    BASE_SEARCH_VECTORS = ['code_patriarche'] + BASE_SEARCH_VECTORS      # preventive      fnap_financing = models.FloatField(u"Financement FNAP (%)",                                         blank=True, null=True) @@ -1634,9 +1645,15 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):          'associated_file__cached_label': _(u"Archaeological file"),          'operation__cached_label': _(u"Operation"),      } -    BASE_SEARCH_VECTORS = ['act_type__label', 'act_object', -                           'towns_label'] -    INT_SEARCH_VECTORS = ["year", "index"] +    BASE_SEARCH_VECTORS = [ +        SearchVectorConfig("act_type__label"), +        SearchVectorConfig("act_object", 'local'), +        SearchVectorConfig("towns_label"), +    ] +    INT_SEARCH_VECTORS = [ +        SearchVectorConfig("year"), +        SearchVectorConfig("index"), +    ]      PARENT_SEARCH_VECTORS = ['operator', 'scientist', 'signatory',                               'associated_file', 'operation', 'treatment_file',                               'treatment'] @@ -2048,7 +2065,11 @@ class ParcelManager(models.Manager):  class Parcel(LightHistorizedItem):      EXTERNAL_ID_KEY = 'parcel_external_id' -    BASE_SEARCH_VECTORS = ['section', 'parcel_number', "cached_label"] +    BASE_SEARCH_VECTORS = [ +        SearchVectorConfig("section"), +        SearchVectorConfig("parcel_number"), +        SearchVectorConfig("cached_label"), +    ]      PARENT_SEARCH_VECTORS = ['operation']      objects = ParcelManager() | 
