diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models.py | 21 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/sheet_person.html | 18 | ||||
-rw-r--r-- | ishtar_common/templatetags/window_tables.py | 3 |
3 files changed, 24 insertions, 18 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e1c4e825d..02c19e011 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1214,7 +1214,8 @@ class DocumentItem(object): def images(self): if not hasattr(self, 'documents'): return Document.objects.none() - return self.documents.filter(image__isnull=False).exclude(image="") + return self.documents.filter( + image__isnull=False).exclude(image="").order_by("pk") def get_extra_actions(self, request): """ @@ -2735,6 +2736,9 @@ class Person(Address, Merge, OwnPerms, ValueGetter): if getattr(self, attr)] return slugify(u"-".join(values)) + def docs_q(self): + return Document.objects.filter(authors__person=self) + def operation_docs_q(self): return Document.objects.filter( authors__person=self, operations__pk__isnull=False) @@ -3105,6 +3109,17 @@ class Document(OwnPerms, ImageModel, FullSearch): BOOL_FIELDS = ['duplicate'] CACHED_LABELS = ['cache_related_label'] + EXTRA_REQUEST_KEYS = { + "operations": "operations__pk", + "context_records": "context_records__pk", + "context_records__operation": "context_records__operation__pk", + "finds": "finds__pk", + "finds__base_finds__context_record": + "finds__base_finds__context_record__pk", + "finds__base_finds__context_record__operation": + "finds__base_finds__context_record__operation__pk", + "authors__person": "authors__person__pk" + } title = models.TextField(_(u"Title"), blank=True, default='') associated_file = models.FileField( @@ -3183,8 +3198,8 @@ class Document(OwnPerms, ImageModel, FullSearch): @property def images(self): # mimic a queryset pointing to himself - return Document.objects.filter(pk=self.pk, - image__isnull=False).exclude(image='') + return Document.objects.filter( + pk=self.pk, image__isnull=False).exclude(image='') @property def has_related(self): diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index a37193572..f84b80d83 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -103,22 +103,10 @@ {% dynamic_table_document af 'files' 'responsible_town_planning_service' item.pk '' output %} {% endif %} -{% comment %} -{% if item.operation_docs_q.count %} -{% trans "Documents associated to operations" as operation_docs %} -{% dynamic_table_document operation_docs 'operation_docs' 'person' item.pk '' output %} +{% if item.docs_q.count %} +{% trans "Documents" as docs %} +{% dynamic_table_document docs 'documents' 'authors__person' item.pk '' output %} {% endif %} -{% if item.contextrecord_docs_q.count %} -{% trans "Documents associated to context records" as context_records %} -{% dynamic_table_document context_records 'context_records_docs' 'person' item.pk '' output %} -{% endif %} - -{% if item.find_docs_q.count %} -{% trans "Documents associated to finds" as finds_docs %} -{% dynamic_table_document finds_docs 'finds_docs' 'person' item.pk '' output %} -{% endif %} -{% endcomment %} - {% endblock %} diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index b442b4353..ce767e1ac 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -12,6 +12,7 @@ from django.utils.translation import ugettext_lazy as _ from ishtar_common.forms import reverse_lazy from ishtar_common.widgets import DataTable +from ishtar_common.models import Document from archaeological_files.models import File from archaeological_operations.models import Operation, ArchaeologicalSite from archaeological_context_records.models import ContextRecord, \ @@ -56,6 +57,8 @@ ASSOCIATED_MODELS['treatments'] = ( ASSOCIATED_MODELS['containers'] = ( Container, 'get-container', '') +ASSOCIATED_MODELS['documents'] = (Document, 'get-document', '') + @register.simple_tag(takes_context=True) def dynamic_table_document( |