summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_finds/models_treatments.py14
-rw-r--r--archaeological_finds/templates/ishtar/sheet_treatment.html2
2 files changed, 12 insertions, 4 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"),
diff --git a/archaeological_finds/templates/ishtar/sheet_treatment.html b/archaeological_finds/templates/ishtar/sheet_treatment.html
index 78460d002..029257f63 100644
--- a/archaeological_finds/templates/ishtar/sheet_treatment.html
+++ b/archaeological_finds/templates/ishtar/sheet_treatment.html
@@ -71,7 +71,7 @@
</div>
<div class="row">
- {% field_flex_multiple "Treatment type" item.treatment_types %}
+ {% field_flex_multiple_obj "Treatment type" item 'treatment_types' %}
{% field_flex "State" item.treatment_state %}
{% field_flex_detail "Associated request" item.file %}
{% field_flex "Location" item.location %}