diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-11-24 17:37:21 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:21 +0100 |
commit | 2597642e86b26d127d740142ba4580247564be7c (patch) | |
tree | 319455e933c1270aba23df9b9c6eaa7155bdc4c8 | |
parent | 4670b412f55b70f35971e2bc407a9b5f75c3395a (diff) | |
download | Ishtar-2597642e86b26d127d740142ba4580247564be7c.tar.bz2 Ishtar-2597642e86b26d127d740142ba4580247564be7c.zip |
Document: display complete identifier on sheet and tables
-rw-r--r-- | ishtar_common/models.py | 21 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_document.html | 5 | ||||
-rw-r--r-- | ishtar_common/views_item.py | 2 | ||||
-rw-r--r-- | ishtar_common/widgets.py | 2 |
4 files changed, 24 insertions, 6 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 5a28aaffe..1762674e8 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2717,9 +2717,8 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, "main_image_sites", ] - TABLE_COLS = ['title', 'source_type', 'cache_related_label', - 'authors__cached_label', - 'associated_url'] + _TABLE_COLS = ['title', 'source_type', 'cache_related_label', + 'authors__cached_label', 'associated_url'] COL_LINK = ['associated_url'] BASE_SEARCH_VECTORS = [ SearchVectorConfig("title"), @@ -2747,7 +2746,10 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, BOOL_FIELDS = ['duplicate'] - COL_LABELS = {"authors__cached_label": _("Authors")} + COL_LABELS = { + "authors__cached_label": _("Authors"), + "complete_identifier": _("Identifier"), + } CACHED_LABELS = ['cache_related_label'] EXTRA_REQUEST_KEYS = { @@ -2760,6 +2762,7 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, "finds__base_finds__context_record__operation": "finds__base_finds__context_record__operation__pk", 'authors__cached_label': 'authors__cached_label', + 'complete_identifier': 'complete_identifier', 'authors__person__pk': 'authors__person__pk', "container_id": "container_id", 'publisher__pk': 'publisher__pk' @@ -3083,6 +3086,14 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, def __str__(self): return self.title + @classmethod + def TABLE_COLS(cls): + cols = cls._TABLE_COLS[:] + profile = get_current_profile() + if profile.document_complete_identifier: + cols = ["complete_identifier"] + cols + return cols + @property def operation_codes(self): Operation = apps.get_model("archaeological_operations", "Operation") @@ -3406,7 +3417,7 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel, return " ; ".join(items) def _generate_cache_related_label(self): - return self.related_label() + return self.related_label()[:1000] @classmethod def get_next_index(cls): diff --git a/ishtar_common/templates/ishtar/sheet_document.html b/ishtar_common/templates/ishtar/sheet_document.html index 5aff68107..e01d0d9fb 100644 --- a/ishtar_common/templates/ishtar/sheet_document.html +++ b/ishtar_common/templates/ishtar/sheet_document.html @@ -1,7 +1,7 @@ {% extends "ishtar/sheet.html" %} {% load i18n window_field window_header link_to_window %} -{% block head_title %}<strong>{% trans "Document" %}</strong> - {{item.title}}{% endblock %} +{% block head_title %}<strong>{% trans "Document" %}</strong> {% if item.complete_identifier %} - {{item.complete_identifier}}{% endif %} - {{item.title}}{% endblock %} {% block content %} {% block window_nav %} @@ -23,6 +23,9 @@ <h4 class="col-12">{% trans "Identification" %}</h4> <div class="col-12 col-md-6 col-lg-3 flex-wrap"> + {% if item.complete_identifier %}<p class="window-refs" + title="{% trans 'Complete identifier' %}"> + <strong>{{ item.complete_identifier|default:"" }}</strong></p>{% endif %} <p class="window-refs" title="{% trans 'Reference' %}">{{ item.reference|default:"" }}</p> <p class="window-refs" diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 8efcaa9ee..d93db355b 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -1782,6 +1782,8 @@ def get_item(model, func_name, default_name, extra_request_keys=None, table_cols = settings.TABLE_COLS[tb_key] else: table_cols = model.TABLE_COLS + if callable(table_cols): + table_cols = table_cols() table_cols = list(table_cols) if data_type == "json-map": table_cols = [] # only pk for map diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 0136d7257..93352ccf3 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -1081,6 +1081,8 @@ class DataTable(Select2Media, forms.RadioSelect): table_cols = settings.TABLE_COLS[tb_key] else: table_cols = getattr(self.associated_model, self.table_cols) + if callable(table_cols): + table_cols = table_cols() for col_names in table_cols: field_verbose_names = [] |