summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
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
commit577eeee08c80784c6ca1cf93d16df8e7f1ec2a3f (patch)
tree0e5976187da70e90b90e2db51648e0503ba41fe1 /ishtar_common
parent00c57b7e83f216f1047a486d58b58c3722b58a0b (diff)
downloadIshtar-577eeee08c80784c6ca1cf93d16df8e7f1ec2a3f.tar.bz2
Ishtar-577eeee08c80784c6ca1cf93d16df8e7f1ec2a3f.zip
Generate document: force extra types listing
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py23
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',