bugfix - empty slug field

This commit is contained in:
Maxime Beauchemin 2015-12-08 14:15:48 -08:00
parent 021654cdf1
commit 2833bd3825
1 changed files with 3 additions and 2 deletions

View File

@ -229,8 +229,9 @@ class DashboardModelView(PanoramixModelView, DeleteMixin):
}
def pre_add(self, obj):
obj.slug = obj.slug.strip() or None
obj.slug = obj.slug.replace(" ", "-")
obj.slug = re.sub(r'\W+', '', obj.slug)
if obj.slug:
obj.slug = obj.slug.replace(" ", "-")
obj.slug = re.sub(r'\W+', '', obj.slug)
def pre_update(self, obj):
self.pre_add(obj)