diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-23 13:01:16 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-05-23 13:01:16 +0200 | 
| commit | c8fd6a33381a76e646b99007bd5e5901eb375e84 (patch) | |
| tree | 0e5976187da70e90b90e2db51648e0503ba41fe1 | |
| parent | f3c7e0da58c49d105d66078784521869ca2e92a5 (diff) | |
| download | Ishtar-c8fd6a33381a76e646b99007bd5e5901eb375e84.tar.bz2 Ishtar-c8fd6a33381a76e646b99007bd5e5901eb375e84.zip | |
Generate document: force extra types listing
| -rw-r--r-- | ishtar_common/models.py | 23 | 
1 files changed, 13 insertions, 10 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index c598b1e3d..67e6f5371 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -110,11 +110,13 @@ post_save.connect(post_save_user, sender=User)  class ValueGetter(object):      _prefix = "" -    GET_VALUES_EXTRA = []      COL_LABELS = {} -    GET_VALUE_EXCLUDE_FIELDS = [ +    GET_VALUES_EXTRA = [] +    GET_VALUES_EXCLUDE_FIELDS = [          'search_vector', 'id', 'multi_polygon', 'point_2d', 'point',          'history_m2m'] +    GET_VALUES_EXTRA_TYPES = [ +        'preservation_to_considers', 'alterations', 'alteration_causes']      def _get_values_documents(self, prefix=""):          values = {} @@ -136,7 +138,7 @@ class ValueGetter(object):          values = {}          for field_name in get_all_field_names(self):              if not hasattr(self, field_name) or \ -                    field_name in self.GET_VALUE_EXCLUDE_FIELDS: +                    field_name in self.GET_VALUES_EXCLUDE_FIELDS:                  continue              value = getattr(self, field_name)              if hasattr(value, 'get_values'): @@ -150,9 +152,8 @@ class ValueGetter(object):              val = values[key]              if val is None:                  val = '' -            elif "type" in key and ( -                    val.__class__.__name__.split('.')[0] -                    == 'ManyRelatedManager'): +            elif (key in self.GET_VALUES_EXTRA_TYPES or "type" in key) and ( +                  val.__class__.__name__.split('.')[0] == 'ManyRelatedManager'):                  val = u" ; ".join([unicode(v) for v in val.all()])              elif isinstance(val, (tuple, list, dict)):                  pass @@ -4407,15 +4408,17 @@ class Document(BaseHistorizedItem, OwnPerms, ImageModel, ValueGetter):      SLUG = 'document'      LINK_SPLIT = u"<||>" -    GET_VALUE_EXCLUDE_FIELDS = ValueGetter.GET_VALUE_EXCLUDE_FIELDS + [ +    GET_VALUES_EXCLUDE_FIELDS = ValueGetter.GET_VALUES_EXCLUDE_FIELDS + [          "warehouses", "operations", "treatments",          "files", "treatment_files", "id",          "associated_links", "source_type_id",          "history_creator_id", "containers", "sites", -        "main_image_warehouses", "main_image_operations", "main_image_treatments", -        "main_image_files", "main_image_treatment_files", "main_image_id", +        "main_image_warehouses", "main_image_operations", +        "main_image_treatments", "main_image_files", +        "main_image_treatment_files", "main_image_id",          "main_image_associated_links", "main_image_source_type_id", -        "main_image_history_creator_id", "main_image_containers", "main_image_sites", +        "main_image_history_creator_id", "main_image_containers", +        "main_image_sites",      ]      TABLE_COLS = ['title', 'source_type', 'cache_related_label', | 
