summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_treatments.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-15 12:33:41 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-15 12:33:41 +0100
commite3e21e5109551740c122bc245d0ef30405aa8229 (patch)
treef1a59e354f9e396be8c2b1190065eed803d601fb /archaeological_finds/models_treatments.py
parent7340559478af4fc05b8d33d9bd0e83d532d71eab (diff)
downloadIshtar-e3e21e5109551740c122bc245d0ef30405aa8229.tar.bz2
Ishtar-e3e21e5109551740c122bc245d0ef30405aa8229.zip
Treatments: settings for M2M history
Diffstat (limited to 'archaeological_finds/models_treatments.py')
-rw-r--r--archaeological_finds/models_treatments.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index 64bad203d..ad3b92262 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -36,9 +36,10 @@ from archaeological_warehouse.models import Warehouse, Container
from ishtar_common.models import Document, GeneralType, \
ImageModel, BaseHistorizedItem, OwnPerms, HistoricalRecords, Person, \
Organization, ValueGetter, post_save_cache, ShortMenuItem, \
- DashboardFormItem, ExternalIdManager, document_attached_changed
+ DashboardFormItem, ExternalIdManager, document_attached_changed, \
+ HistoryModel
from ishtar_common.utils import cached_label_changed, get_current_year, \
- update_data
+ update_data, m2m_historization_changed
class TreatmentState(GeneralType):
@@ -121,6 +122,9 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
activate(language_code)
EXTRA_REQUEST_KEYS[unicode(v[0])] = v[1]
deactivate()
+ HISTORICAL_M2M = [
+ 'treatment_types',
+ ]
BASE_SEARCH_VECTORS = [
'treatment_types__label', 'treatment_state__label', 'label', 'goal',
@@ -185,7 +189,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
verbose_name=_(u"Main image"), blank=True, null=True)
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
- history = HistoricalRecords()
+ history = HistoricalRecords(bases=[HistoryModel])
class Meta:
verbose_name = _(u"Treatment")
@@ -586,6 +590,10 @@ pre_delete.connect(pre_delete_treatment, sender=Treatment)
m2m_changed.connect(document_attached_changed,
sender=Treatment.documents.through)
+for attr in Treatment.HISTORICAL_M2M:
+ m2m_changed.connect(m2m_historization_changed,
+ sender=getattr(Treatment, attr).through)
+
class AbsFindTreatments(models.Model):
find = models.ForeignKey(Find, verbose_name=_(u"Find"),