diff --git a/setup.py b/setup.py index 25f69f29c..5e362a2fa 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ def build_media_pattern(base_folder, file_extension): setup( name = "django-wiki", - version = "0.0.8", + version = "0.0.9", author = "Benjamin Bach", author_email = "benjamin@overtag.dk", description = ("A wiki system written for the Django framework."), diff --git a/wiki/forms.py b/wiki/forms.py index 826403afe..6782e18fd 100644 --- a/wiki/forms.py +++ b/wiki/forms.py @@ -203,7 +203,8 @@ def __init__(self, urlpath_parent, *args, **kwargs): self.urlpath_parent = urlpath_parent 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'), required=False, widget=getEditor().get_widget()) #@UndefinedVariable diff --git a/wiki/migrations/0004_increase_slug_size.py b/wiki/migrations/0004_increase_slug_size.py new file mode 100644 index 000000000..b9fae30be --- /dev/null +++ b/wiki/migrations/0004_increase_slug_size.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('wiki', '0003_ip_address_conv'), + ] + + operations = [ + migrations.AlterField( + model_name='urlpath', + name='slug', + field=models.SlugField(max_length=255, null=True, verbose_name='slug', blank=True), + ), + ] diff --git a/wiki/models/urlpath.py b/wiki/models/urlpath.py index 2b5d06ca6..98adf88b6 100644 --- a/wiki/models/urlpath.py +++ b/wiki/models/urlpath.py @@ -41,7 +41,12 @@ class URLPath(MPTTModel): article = models.ForeignKey(Article, on_delete=models.CASCADE, editable=False, verbose_name=_(u'Cache lookup value for articles')) - slug = models.SlugField(verbose_name=_(u'slug'), null=True, blank=True) + # The slug is constructed from course key and will in practice be much shorter then 255 characters + # since course keys are capped at 65 characters in the Studio (https://openedx.atlassian.net/browse/TNL-889). + SLUG_MAX_LENGTH = 255 + + slug = models.SlugField(verbose_name=_(u'slug'), null=True, blank=True, + max_length=SLUG_MAX_LENGTH) site = models.ForeignKey(Site) parent = TreeForeignKey('self', null=True, blank=True, related_name='children')