From 3f14d0f6481f1781d598d29b79a96fb7ee727320 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 9 May 2018 17:49:16 +0200 Subject: Standardize related field item for imagee collections (refs #4076) --- ishtar_common/models.py | 10 ++++++++++ ishtar_common/wizards.py | 2 ++ 2 files changed, 12 insertions(+) (limited to 'ishtar_common') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 35be3ffc0..d4d6d2c79 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3065,6 +3065,16 @@ class IshtarImage(ImageModel): ordering = ('name',) +class ThroughImage(models.Model): + image = models.ForeignKey( + IshtarImage, on_delete=models.CASCADE) + is_main = models.BooleanField(_(u"Main image"), default=False) + + class Meta: + ordering = ('-is_main', 'image__name') + abstract = True + + if settings.COUNTRY == 'fr': class Arrondissement(models.Model): name = models.CharField(u"Nom", max_length=30) diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 2182e9060..f200447e4 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -789,6 +789,8 @@ class Wizard(NamedUrlWizardView): for old_item in old_m2ms[key]: is_ok = True for k in value: + if not hasattr(old_item, k): + continue if is_ok and getattr(old_item, k) != value[k]: is_ok = False continue -- cgit v1.2.3