From 72bda3fe8a40a0e3f7a96e9188802fd0b30b5763 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 23 Nov 2017 16:55:08 +0100 Subject: Make slug unique and mandatory for property models --- chimere/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'chimere/models.py') diff --git a/chimere/models.py b/chimere/models.py index 7c84b0e..30c3be0 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -624,6 +624,7 @@ class GeographicItem(models.Model): # add read attributes for properties for pm in self.all_properties(): attr_name = pm.getAttrName() + print(attr_name) if not hasattr(self, attr_name): val = '' property = self.getProperty(pm) @@ -2014,7 +2015,7 @@ class Area(models.Model, SimpleArea): "is 0.") ) max_zoom = models.IntegerField( - _("Maxim zoom"), blank=True, null=True, + _("Maximum zoom"), blank=True, null=True, help_text=_("Set a maximal zoom level. By default maximal zoom level " "is 18.") ) @@ -2194,12 +2195,17 @@ class AreaOverlays(models.Model): verbose_name_plural = _("Areas - Overlays") +slug_help = _(u"The slug is the standardized version of the name. It contains " + u"only lowercase letters, numbers and hyphens. Each slug must " + u"be unique.") + + class PropertyModel(models.Model): """ Model for a property """ name = models.CharField(_("Name"), max_length=150) - slug = models.SlugField(_("Slug"), blank=True, null=True) + slug = models.SlugField(_("Slug"), help_text=slug_help, unique=True) order = models.IntegerField(_("Order")) available = models.BooleanField(_("Available")) mandatory = models.BooleanField(_("Mandatory")) -- cgit v1.2.3