From 601b5ef0a53ff697890dcd0c26396aa664e35ad7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 Apr 2018 17:52:48 +0200 Subject: Manage groupment of towns with areas (refs #4060) --- ishtar_common/models.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 5d48dd813..1825335fd 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3130,6 +3130,19 @@ def town_child_changed(sender, **kwargs): m2m_changed.connect(town_child_changed, sender=Town.children.through) +class Area(HierarchicalType): + towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"), blank=True) + parent = models.ForeignKey( + 'self', blank=True, null=True, verbose_name=_(u"Parent"), + help_text=_(u"Only four level of parent are managed.") + ) + + class Meta: + verbose_name = _(u"Area") + verbose_name_plural = _(u"Areas") + ordering = ('parent__label', 'label') + + class OperationType(GeneralType): order = models.IntegerField(_(u"Order"), default=1) preventive = models.BooleanField(_(u"Is preventive"), default=True) -- cgit v1.2.3