diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-15 10:00:12 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-03-15 10:00:12 +0100 | 
| commit | 145e2100b001dcb682b0d60f02dcad95fb5bf1db (patch) | |
| tree | 783b84ab3738d0e43a4144f02748b4ef9b107080 | |
| parent | b492cb324e76fcef3c1f9444880bc3e8d98d621b (diff) | |
| download | Ishtar-145e2100b001dcb682b0d60f02dcad95fb5bf1db.tar.bz2 Ishtar-145e2100b001dcb682b0d60f02dcad95fb5bf1db.zip  | |
Refactoring: EXTRA_FULL_FIELDS_LABELS -> COL_LABELS (with merge) (refs #3491)
| -rw-r--r-- | archaeological_context_records/models.py | 22 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 20 | ||||
| -rw-r--r-- | archaeological_finds/models_treatments.py | 2 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 3 | ||||
| -rw-r--r-- | ishtar_common/models.py | 2 | ||||
| -rw-r--r-- | ishtar_common/views.py | 8 | 
6 files changed, 28 insertions, 29 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 04ca358e3..1ffdea2f3 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -159,9 +159,17 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms,          TABLE_COLS.insert(1, 'operation__code_patriarche')      TABLE_COLS_FOR_OPE = ['label', 'parcel', 'unit',                            'datings__period__label', 'description'] -    COL_LABELS = {'section__parcel_number': _(u"Parcel"), -                  'datings__period__label': _(u"Periods"), -                  'parcel__town__name': _(u"Town")} +    COL_LABELS = { +        'datings__period__label': _(u"Periods"), +        'datings__period': _(u"Datings (period)"), +        'detailled_related_context_records': _(u"Related context records"), +        'operation__code_patriarche': u"Operation (code patriarche)", +        'parcel__external_id': _(u"Parcel (external ID)"), +        'parcel__town__name': _(u"Parcel (town)"), +        'parcel__town': _(u"Parcel (town)"), +        'parcel__year': _(u"Parcel (year)"), +        'section__parcel_number': _(u"Parcel"), +    }      CONTEXTUAL_TABLE_COLS = {          'full': {              'related_context_records': 'detailled_related_context_records' @@ -188,14 +196,6 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms,      RELATIVE_SESSION_NAMES = [          ('operation', 'operation__pk'),          ('file', 'operation__associated_file__pk')] -    EXTRA_FULL_FIELDS_LABELS = { -        'parcel__town': _(u"Parcel (town)"), -        'detailled_related_context_records': _(u"Related context records"), -        'operation__code_patriarche': u"Operation (code patriarche)", -        'parcel__external_id': _(u"Parcel (external ID)"), -        'datings__period': _(u"Datings (period)"), -        'parcel__year': _(u"Parcel (year)"), -    }      # fields      external_id = models.TextField(_(u"External ID"), blank=True, null=True) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index eb88371ea..9b4860e51 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -502,8 +502,16 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          'base_finds__context_record__parcel', ]      COL_LABELS = {          'base_finds__context_record__label': _(u"Context record"), -        'datings__period__label': _(u"Periods"), +        'base_finds__cache_short_id': _(u"Base find - Short ID"), +        'base_finds__cache_complete_id': _(u"Base find - Complete ID"), +        'base_finds__comment': _(u"Base find - Comment"), +        'base_finds__description': _(u"Base find - Description"), +        'base_finds__topographic_localisation': _(u"Base find - " +                                                  u"Topographic localisation"), +        'base_finds__special_interest': _(u"Base find - Special interest"), +        'base_finds__discovery_date': _(u"Base find - Discovery date"),          'container__cached_label': _(u"Container"), +        'datings__period__label': _(u"Periods"),          'material_types__label': _(u"Material types"),      } @@ -513,16 +521,6 @@ class Find(BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem):          'base_finds__topographic_localisation',          'base_finds__special_interest',          'base_finds__discovery_date'] -    EXTRA_FULL_FIELDS_LABELS = { -        'base_finds__cache_short_id': _(u"Base find - Short ID"), -        'base_finds__cache_complete_id': _(u"Base find - Complete ID"), -        'base_finds__comment': _(u"Base find - Comment"), -        'base_finds__description': _(u"Base find - Description"), -        'base_finds__topographic_localisation': _(u"Base find - " -                                                  u"Topographic localisation"), -        'base_finds__special_interest': _(u"Base find - Special interest"), -        'base_finds__discovery_date': _(u"Base find - Discovery date"), -    }      ATTRS_EQUIV = {'get_first_base_find': 'base_finds'}      # search parameters diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 3e9077a48..dd080835e 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -285,7 +285,7 @@ class AbsFindTreatments(models.Model):      treatment_nb = models.IntegerField(_(u"Order"))      TABLE_COLS = ["treatment__" + col for col in Treatment.TABLE_COLS] + \          ['treatment_nb'] -    EXTRA_FULL_FIELDS_LABELS = { +    COL_LABELS = {          'treatment__treatment_type': _(u"Treatment type"),          'treatment__start_date': _(u"Start date"),          'treatment__end_date': _(u"End date"), diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 3b06bc449..727b29cb5 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -227,7 +227,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,          'context_record__base_finds__find__upstream_treatment__id'      } -    EXTRA_FULL_FIELDS_LABELS = { +    COL_LABELS = {          'full_code_patriarche': u"Code patriarche",          'associated_file_short_label': _(u"Associated file (label)"),          'operator__name': _(u"Operator name"), @@ -988,6 +988,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):      REVERSED_BOOL_FIELDS = ['index__isnull']      RELATIVE_SESSION_NAMES = [('operation', 'operation__pk'),                                ('file', 'associated_file__pk')] +    COL_LABELS = {'full_ref': _(u"Ref.")}      # fields      act_type = models.ForeignKey(ActType, verbose_name=_(u"Act type")) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index ca6ba36c9..35608abdf 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -102,7 +102,7 @@ class Imported(models.Model):  class ValueGetter(object):      _prefix = ""      GET_VALUES_EXTRA = [] -    EXTRA_FULL_FIELDS_LABELS = {} +    COL_LABELS = {}      def get_values(self, prefix=''):          if not prefix: diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 95b7689ec..cbf27c8e7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -1115,9 +1115,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[],                  for field_name in table_cols:                      if type(field_name) in (list, tuple):                          field_name = u" & ".join(field_name) -                    if hasattr(model, 'EXTRA_FULL_FIELDS_LABELS') and\ -                            field_name in model.EXTRA_FULL_FIELDS_LABELS: -                        field = model.EXTRA_FULL_FIELDS_LABELS[field_name] +                    if hasattr(model, 'COL_LABELS') and\ +                            field_name in model.COL_LABELS: +                        field = model.COL_LABELS[field_name]                          col_names.append(unicode(field).encode(ENCODING))                          continue                      else: @@ -1128,7 +1128,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[],                              logger.warning(                                  "**WARN get_item - csv export**: no col name "                                  "for {}\nadd explicit label to " -                                "EXTRA_FULL_FIELDS_LABELS attribute of " +                                "COL_LABELS attribute of "                                  "{}".format(field_name, model))                              continue                          col_names.append(  | 
