summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-23 16:55:08 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-11-23 16:55:08 +0100
commit72bda3fe8a40a0e3f7a96e9188802fd0b30b5763 (patch)
treed620e029c4bc4b2071e0e800f6fb23f63582afa7
parent1d1e38567ee456b41cd5d09a8d7b5f4d7c98db1a (diff)
downloadChimère-72bda3fe8a40a0e3f7a96e9188802fd0b30b5763.tar.bz2
Chimère-72bda3fe8a40a0e3f7a96e9188802fd0b30b5763.zip
Make slug unique and mandatory for property modelsHEADmaster
-rw-r--r--chimere/admin.py1
-rw-r--r--chimere/migrations/0011_auto_20171123_1654.py26
-rw-r--r--chimere/models.py10
3 files changed, 35 insertions, 2 deletions
diff --git a/chimere/admin.py b/chimere/admin.py
index c497aca..36072ab 100644
--- a/chimere/admin.py
+++ b/chimere/admin.py
@@ -627,6 +627,7 @@ class PropertyModelChoiceInline(admin.TabularInline):
class PropertyModelAdmin(admin.ModelAdmin):
list_display = ('name', 'order', 'available')
inlines = [PropertyModelChoiceInline]
+ prepopulated_fields = {"slug": ("name",)}
# register of differents database fields
admin.site.register(Page, PageAdmin)
diff --git a/chimere/migrations/0011_auto_20171123_1654.py b/chimere/migrations/0011_auto_20171123_1654.py
new file mode 100644
index 0000000..63efe5e
--- /dev/null
+++ b/chimere/migrations/0011_auto_20171123_1654.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.5 on 2017-11-23 16:54
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('chimere', '0010_auto_20171123_1226'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='area',
+ name='max_zoom',
+ field=models.IntegerField(blank=True, help_text='Set a maximal zoom level. By default maximal zoom level is 18.', null=True, verbose_name='Maximum zoom'),
+ ),
+ migrations.AlterField(
+ model_name='propertymodel',
+ name='slug',
+ field=models.SlugField(default='to-change', help_text='The slug is the standardized version of the name. It contains only lowercase letters, numbers and hyphens. Each slug must be unique.', unique=True, verbose_name='Slug'),
+ preserve_default=False,
+ ),
+ ]
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"))