Skip to content

Commit

Permalink
Increase slug size from 50 to 255.
Browse files Browse the repository at this point in the history
In edx-platform, default course wiki article's slug is automatically set
to "{org}.{number}.{run}", which can be more than 50 characters long.

The wiki breaks if the automatically assigned slug is longer than 50
characters.

We usually use 255 character size for columns that store course_key in
edx-platform, so I believe it makes sense to use a limit of 255 for wiki
slugs, too.
  • Loading branch information
mtyaka committed Aug 23, 2016
1 parent 4a3dc1f commit 6462655
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]",
description = ("A wiki system written for the Django framework."),
Expand Down
19 changes: 19 additions & 0 deletions wiki/migrations/0004_increase_slug_size.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
4 changes: 3 additions & 1 deletion wiki/models/urlpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class URLPath(MPTTModel):
article = models.ForeignKey(Article, on_delete=models.CASCADE, editable=False,
verbose_name=_(u'Cache lookup value for articles'))

SLUG_MAX_LENGTH = 50
# 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)
Expand Down

0 comments on commit 6462655

Please sign in to comment.