diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 16 |
1 files changed, 11 insertions, 5 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: |