diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-04-23 18:40:47 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:43:58 +0200 |
commit | e6d28b9a5e69461726a06826cbcf089dfe34f148 (patch) | |
tree | c595e4556ff333b80c51e161d6c539d9775cec94 /archaeological_operations/models.py | |
parent | 95145c2b3fb315c9c16aeeccd1e3e1770c9e2f08 (diff) | |
download | Ishtar-e6d28b9a5e69461726a06826cbcf089dfe34f148.tar.bz2 Ishtar-e6d28b9a5e69461726a06826cbcf089dfe34f148.zip |
Images: add a main_image field (refs #4076) - Add images associated to warehouses (refs #3879)
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 2a5f1cbe6..10a281dda 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -130,6 +130,8 @@ class ArchaeologicalSite(BaseHistorizedItem): _(u"Sinking date"), null=True, blank=True) discovery_area = models.TextField( _(u"Discovery area"), null=True, blank=True) + images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"), + through='SiteImage', blank=True) class Meta: verbose_name = _(u"Archaeological site") @@ -218,6 +220,12 @@ class ArchaeologicalSite(BaseHistorizedItem): ) +class SiteImage(models.Model): + image = models.ForeignKey(IshtarImage, on_delete=models.CASCADE) + site = models.ForeignKey(ArchaeologicalSite, on_delete=models.CASCADE) + is_main = models.BooleanField(_(u"Main image"), default=False) + + def get_values_town_related(item, prefix, values): values[prefix + 'parcellist'] = item.render_parcels() values[prefix + 'towns'] = '' @@ -453,7 +461,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms, scientific_documentation_comment = models.TextField( _(u"Comment about scientific documentation"), null=True, blank=True) images = models.ManyToManyField(IshtarImage, verbose_name=_(u"Images"), - blank=True) + blank=True, through='OperationImage') cached_label = models.CharField(_(u"Cached name"), max_length=500, null=True, blank=True, db_index=True) archaeological_sites = models.ManyToManyField( @@ -971,6 +979,12 @@ def operation_post_save(sender, **kwargs): post_save.connect(operation_post_save, sender=Operation) +class OperationImage(models.Model): + image = models.ForeignKey(IshtarImage, on_delete=models.CASCADE) + operation = models.ForeignKey(Operation, on_delete=models.CASCADE) + is_main = models.BooleanField(_(u"Main image"), default=False) + + class RelationType(GeneralRelationType): class Meta: |