Commit 1dbd51fd by benjaoming

Ensure that CreateForm fails when slug field is longer than the maximum allowed slug length (#57)

parent 393aa34f
...@@ -199,7 +199,8 @@ class CreateForm(forms.Form): ...@@ -199,7 +199,8 @@ class CreateForm(forms.Form):
self.urlpath_parent = urlpath_parent self.urlpath_parent = urlpath_parent
title = forms.CharField(label=_(u'Title'),) title = forms.CharField(label=_(u'Title'),)
slug = forms.SlugField(label=_(u'Slug'), help_text=_(u"This will be the address where your article can be found. Use only alphanumeric characters and - or _. Note that you cannot change the slug after creating the article."),) slug = forms.SlugField(label=_(u'Slug'), help_text=_(u"This will be the address where your article can be found. Use only alphanumeric characters and - or _. Note that you cannot change the slug after creating the article."),
max_length=models.URLPath.SLUG_MAX_LENGTH)
content = forms.CharField(label=_(u'Contents'), content = forms.CharField(label=_(u'Contents'),
required=False, widget=getEditor().get_widget()) #@UndefinedVariable required=False, widget=getEditor().get_widget()) #@UndefinedVariable
......
...@@ -39,7 +39,10 @@ class URLPath(MPTTModel): ...@@ -39,7 +39,10 @@ class URLPath(MPTTModel):
article = models.ForeignKey(Article, on_delete=models.CASCADE, editable=False, article = models.ForeignKey(Article, on_delete=models.CASCADE, editable=False,
verbose_name=_(u'Cache lookup value for articles')) verbose_name=_(u'Cache lookup value for articles'))
slug = models.SlugField(verbose_name=_(u'slug'), null=True, blank=True) SLUG_MAX_LENGTH = 50
slug = models.SlugField(verbose_name=_(u'slug'), null=True, blank=True,
max_length=SLUG_MAX_LENGTH)
site = models.ForeignKey(Site) site = models.ForeignKey(Site)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children') parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment