diff --git a/common/djangoapps/util/model_utils.py b/common/djangoapps/util/model_utils.py index 5aec1bada0..bc22fb0017 100644 --- a/common/djangoapps/util/model_utils.py +++ b/common/djangoapps/util/model_utils.py @@ -1,13 +1,8 @@ """ Utilities for django models. """ -import re -import unicodedata - from django.conf import settings from django.dispatch import Signal -from django.utils.encoding import force_unicode -from django.utils.safestring import mark_safe from django_countries.fields import Country from eventtracking import tracker @@ -171,20 +166,3 @@ def _get_truncated_setting_value(value, max_length=None): return value[0:max_length], True else: return value, False - - -# Taken from Django 1.8 source code because it's not supported in 1.4 -def slugify(value): - """Converts value into a string suitable for readable URLs. - - Converts to ASCII. Converts spaces to hyphens. Removes characters that - aren't alphanumerics, underscores, or hyphens. Converts to lowercase. - Also strips leading and trailing whitespace. - - Args: - value (string): String to slugify. - """ - value = force_unicode(value) - value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') - value = re.sub(r'[^\w\s-]', '', value).strip().lower() - return mark_safe(re.sub(r'[-\s]+', '-', value)) diff --git a/lms/djangoapps/badges/events/course_complete.py b/lms/djangoapps/badges/events/course_complete.py index 24002771ae..7cb9e4986c 100644 --- a/lms/djangoapps/badges/events/course_complete.py +++ b/lms/djangoapps/badges/events/course_complete.py @@ -5,7 +5,7 @@ import hashlib import logging from django.core.urlresolvers import reverse -from django.template.defaultfilters import slugify +from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ from badges.models import BadgeAssertion, BadgeClass, CourseCompleteImageConfiguration diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 231e960ab3..c4f7a01dfb 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -64,7 +64,7 @@ from student.roles import CourseBetaTesterRole from track import contexts from util import milestones_helpers from util.json_request import JsonResponse -from util.model_utils import slugify +from django.utils.text import slugify from util.sandboxing import can_execute_unsafe_code, get_python_lib_zip from xblock_django.user_service import DjangoXBlockUserService from xmodule.contentstore.django import contentstore diff --git a/lms/djangoapps/teams/models.py b/lms/djangoapps/teams/models.py index 154f424acd..dd5461263d 100644 --- a/lms/djangoapps/teams/models.py +++ b/lms/djangoapps/teams/models.py @@ -27,7 +27,7 @@ from lms.djangoapps.teams import TEAM_DISCUSSION_CONTEXT from lms.djangoapps.teams.utils import emit_team_event from openedx.core.djangoapps.xmodule_django.models import CourseKeyField from student.models import CourseEnrollment, LanguageField -from util.model_utils import slugify +from django.utils.text import slugify from .errors import AlreadyOnTeamInCourse, ImmutableMembershipFieldException, NotEnrolledInCourseForTeam