summaryrefslogtreecommitdiff
path: root/archaeological_files
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_files')
-rw-r--r--archaeological_files/models.py14
-rw-r--r--archaeological_files/templates/ishtar/sheet_file.html4
2 files changed, 13 insertions, 5 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py
index 4d0422f3c..16f3e4de9 100644
--- a/archaeological_files/models.py
+++ b/archaeological_files/models.py
@@ -28,12 +28,12 @@ from django.utils.translation import ugettext_lazy as _, pgettext_lazy, \
activate, deactivate
from ishtar_common.utils import cached_label_changed, get_cache, \
- get_current_year
+ get_current_year, m2m_historization_changed
from ishtar_common.models import GeneralType, BaseHistorizedItem, \
HistoricalRecords, OwnPerms, Person, Organization, Department, Town, \
Dashboard, DashboardFormItem, ValueGetter, ShortMenuItem, \
- OperationType, get_external_id, post_save_cache, Document
+ OperationType, get_external_id, post_save_cache, Document, HistoryModel
from archaeological_operations.models import get_values_town_related, \
ClosedItem
@@ -217,6 +217,8 @@ class File(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
'towns__numero_insee__startswith': '_get_department_code',
}
+ HISTORICAL_M2M = ['towns', 'departments']
+
# fields
year = models.IntegerField(_(u"Year"), default=get_current_year)
numeric_reference = models.IntegerField(
@@ -325,7 +327,7 @@ class File(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
db_index=True)
imported_line = models.TextField(_(u"Imported line"), null=True,
blank=True)
- history = HistoricalRecords()
+ history = HistoricalRecords(bases=[HistoryModel])
GET_VALUES_EXTRA = [
'general_contractor_address_1',
@@ -692,9 +694,15 @@ class File(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,
def is_preventive(self):
return FileType.is_preventive(self.file_type.pk)
+
m2m_changed.connect(cached_label_changed, sender=File.towns.through)
+
post_save.connect(cached_label_changed, sender=File)
+for attr in File.HISTORICAL_M2M:
+ m2m_changed.connect(m2m_historization_changed,
+ sender=getattr(File, attr).through)
+
class FileByDepartment(models.Model):
"""
diff --git a/archaeological_files/templates/ishtar/sheet_file.html b/archaeological_files/templates/ishtar/sheet_file.html
index 062dbc5a8..989c2cdfd 100644
--- a/archaeological_files/templates/ishtar/sheet_file.html
+++ b/archaeological_files/templates/ishtar/sheet_file.html
@@ -67,8 +67,8 @@
<h3>{% trans "Localisation"%}</h3>
<div class="row">
- {% field_flex_multiple "Towns" item.towns %}
- {% field_flex_multiple "Departments" item.departments %}
+ {% field_flex_multiple_obj "Towns" item 'towns' %}
+ {% field_flex_multiple_obj "Departments" item 'departments' %}
{% field_flex "Main address" item.address %}
{% field_flex "Complement" item.address_complement %}
{% field_flex "Postal code" item.postal_code %}