summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-15 13:10:43 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-15 13:10:43 +0100
commit83f721df61b06963e2751d8590f8d5fd64d15dac (patch)
tree04a413d7cd8abd8c0baf767a8bc12e6b2d0d1bfa
parent5448e86869157c0191727df404848c2016fc2da2 (diff)
downloadIshtar-83f721df61b06963e2751d8590f8d5fd64d15dac.tar.bz2
Ishtar-83f721df61b06963e2751d8590f8d5fd64d15dac.zip
Context record: settings for M2M history
-rw-r--r--archaeological_context_records/models.py16
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html4
2 files changed, 13 insertions, 7 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py
index 4f1711d31..d2faebc1e 100644
--- a/archaeological_context_records/models.py
+++ b/archaeological_context_records/models.py
@@ -17,8 +17,6 @@
# See the file COPYING for details.
-import datetime
-
from django.conf import settings
from django.contrib.gis.db import models
from django.core.urlresolvers import reverse
@@ -29,13 +27,14 @@ from django.utils.translation import ugettext_lazy as _, pgettext, \
activate, pgettext_lazy, deactivate
from django.utils.text import slugify
-from ishtar_common.utils import cached_label_changed
+from ishtar_common.utils import cached_label_changed, m2m_historization_changed
from ishtar_common.models import Document, GeneralType, \
BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \
GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\
post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager, \
- RelationItem, Town, get_current_profile, document_attached_changed
+ RelationItem, Town, get_current_profile, document_attached_changed, \
+ HistoryModel
from archaeological_operations.models import Operation, Period, Parcel, \
ArchaeologicalSite
@@ -396,8 +395,11 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem,
('site', 'archaeological_site__pk'),
('file', 'operation__associated_file__pk'),
]
+ HISTORICAL_M2M = [
+ 'datings', 'documentations'
+ ]
- history = HistoricalRecords()
+ history = HistoricalRecords(bases=[HistoryModel])
objects = ExternalIdManager()
# fields
@@ -731,6 +733,10 @@ post_save.connect(cached_label_changed, sender=ContextRecord)
m2m_changed.connect(document_attached_changed,
sender=ContextRecord.documents.through)
+for attr in ContextRecord.HISTORICAL_M2M:
+ m2m_changed.connect(m2m_historization_changed,
+ sender=getattr(ContextRecord, attr).through)
+
class RelationType(GeneralRelationType):
class Meta:
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index af5da11dd..d53dbcc6b 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -33,9 +33,9 @@
{% endif %}
{% field_flex "Excavation technic" item.excavation_technic '' '' has_image %}
- {% field_flex_multiple "Chronology" item.datings has_image %}
+ {% field_flex_multiple_obj "Chronology" item 'datings' has_image %}
{% field_flex "Town" item.town.label_with_areas '' '' has_image %}
- {% field_flex_multiple "Documentation" item.documentations has_image %}
+ {% field_flex_multiple_obj "Documentation" item 'documentations' has_image %}
{% field_flex "Opening date" item.opening_date '' '' has_image %}
{% field_flex "Closing date" item.closing_date '' '' has_image %}
{% field_flex_full "Comment on datings" item.datings_comment "<pre>" "</pre>" has_image %}