summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_finds.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-12-20 19:49:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-01-11 17:30:46 +0100
commit330215cf864ad3a917d51d6be15d68f360c166dc (patch)
tree3ae604ef9a36c7edaac48530db753810324e5494 /archaeological_finds/models_finds.py
parent35ba8c95c9e359be0346dd163a47dd4874dd0ecb (diff)
downloadIshtar-330215cf864ad3a917d51d6be15d68f360c166dc.tar.bz2
Ishtar-330215cf864ad3a917d51d6be15d68f360c166dc.zip
Manage main image: model, auto associate default image
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r--archaeological_finds/models_finds.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index 393583749..33ec2df0b 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -40,7 +40,7 @@ from ishtar_common.models import Document, GeneralType, \
HistoricalRecords, OwnPerms, Person, Basket, post_save_cache, \
ValueGetter, get_current_profile, IshtarSiteProfile, PRIVATE_FIELDS, \
SpatialReferenceSystem, BulkUpdatedItem, ExternalIdManager, QuickAction, \
- MainItem
+ MainItem, document_attached_changed
from archaeological_operations.models import AdministrativeAct, Operation
from archaeological_context_records.models import ContextRecord, Dating
@@ -1179,6 +1179,9 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
documents = models.ManyToManyField(
Document, related_name='finds', verbose_name=_(u"Documents"),
blank=True)
+ main_image = models.ForeignKey(
+ Document, related_name='main_image_finds',
+ verbose_name=_(u"Main image"), blank=True, null=True)
treatments = models.ManyToManyField(
"Treatment", verbose_name=_(u"Treatments"),
related_name='finds', blank=True,
@@ -1954,6 +1957,9 @@ def base_find_find_changed(sender, **kwargs):
m2m_changed.connect(base_find_find_changed, sender=Find.base_finds.through)
+m2m_changed.connect(document_attached_changed,
+ sender=Find.documents.through)
+
class Property(LightHistorizedItem):
find = models.ForeignKey(Find, verbose_name=_(u"Find"))