summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_treatments.py
diff options
context:
space:
mode:
Diffstat (limited to 'archaeological_finds/models_treatments.py')
-rw-r--r--archaeological_finds/models_treatments.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py
index b35912fd0..f96a0febf 100644
--- a/archaeological_finds/models_treatments.py
+++ b/archaeological_finds/models_treatments.py
@@ -125,7 +125,7 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem,
target_is_basket = models.BooleanField(_(u"Target a basket"),
default=False)
images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"),
- blank=True)
+ blank=True, through='TreatmentImage')
cached_label = models.TextField(_(u"Cached name"), null=True, blank=True,
db_index=True)
history = HistoricalRecords()
@@ -307,6 +307,12 @@ def pre_delete_treatment(sender, **kwargs):
pre_delete.connect(pre_delete_treatment, sender=Treatment)
+class TreatmentImage(models.Model):
+ image = models.ForeignKey(IshtarImage, on_delete=models.CASCADE)
+ treatment = models.ForeignKey(Treatment, on_delete=models.CASCADE)
+ is_main = models.BooleanField(_(u"Main image"), default=False)
+
+
class AbsFindTreatments(models.Model):
find = models.ForeignKey(Find, verbose_name=_(u"Find"),
related_name='%(class)s_related')
@@ -602,6 +608,7 @@ class TreatmentFile(DashboardFormItem, ClosedItem, BaseHistorizedItem,
self.pre_save()
super(TreatmentFile, self).save(*args, **kwargs)
+
post_save.connect(cached_label_changed, sender=TreatmentFile)