From 7062f7dd4b3f2bedd2407801a3a196795e79b2e9 Mon Sep 17 00:00:00 2001 From: Bryan Date: Sun, 12 Jan 2014 08:10:35 +0000 Subject: [PATCH] updating slugify for 1.5.5, not necessary but good practice. --- karmaworld/apps/courses/models.py | 8 ++++---- karmaworld/apps/courses/test/test.py | 5 +++-- karmaworld/apps/notes/models.py | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/karmaworld/apps/courses/models.py b/karmaworld/apps/courses/models.py index 4543a07..9a36d98 100644 --- a/karmaworld/apps/courses/models.py +++ b/karmaworld/apps/courses/models.py @@ -11,7 +11,7 @@ import datetime from django.db import models -from django.template import defaultfilters +from django.utils.text import slugify from karmaworld.settings.manual_unique_together import auto_add_check_unique_together @@ -59,7 +59,7 @@ class School(models.Model): def save(self, *args, **kwargs): """ Save school and generate a slug if one doesn't exist """ if not self.slug: - self.slug = defaultfilters.slugify(self.name) + self.slug = slugify(self.name) super(School, self).save(*args, **kwargs) @staticmethod @@ -113,7 +113,7 @@ class Department(models.Model): def save(self, *args, **kwargs): """ Save department and generate a slug if one doesn't exist """ if not self.slug: - self.slug = defaultfilters.slugify(self.name) + self.slug = slugify(self.name) super(Department, self).save(*args, **kwargs) @@ -252,7 +252,7 @@ class Course(models.Model): """ Save school and generate a slug if one doesn't exist """ super(Course, self).save(*args, **kwargs) # generate a self.id if not self.slug: - self.slug = defaultfilters.slugify("%s %s" % (self.name, self.id)) + self.slug = slugify("%s %s" % (self.name, self.id)) self.save() # Save the slug def get_updated_at_string(self): diff --git a/karmaworld/apps/courses/test/test.py b/karmaworld/apps/courses/test/test.py index 1157152..4951e01 100644 --- a/karmaworld/apps/courses/test/test.py +++ b/karmaworld/apps/courses/test/test.py @@ -3,6 +3,7 @@ from django.test import TestCase from karmaworld.apps.courses.models import * from django.test.client import Client from django.core.urlresolvers import reverse +from django.utils.text import slugify import json class CoursesTests(TestCase): @@ -21,10 +22,10 @@ class CoursesTests(TestCase): self.assertEqual(Course.objects.count(), 1) def testSchoolSlug(self): - self.assertEqual(self.harvard.slug, defaultfilters.slugify(self.harvard.name)) + self.assertEqual(self.harvard.slug, slugify(self.harvard.name)) def testCourseSlug(self): - self.assertEqual(self.course1.slug, defaultfilters.slugify("%s %s" % (self.course1.name, self.course1.id))) + self.assertEqual(self.course1.slug, slugify("%s %s" % (self.course1.name, self.course1.id))) def testSearchForSchool(self): """Test searching for a school by partial name""" diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index d284977..00e72cf 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -23,7 +23,7 @@ from django.conf import settings from django.core.files import File from django.core.files.storage import FileSystemStorage from django.db import models -from django.template import defaultfilters +from django.utils.text import slugify import django_filepicker from lxml.html import fromstring, tostring from taggit.managers import TaggableManager @@ -87,7 +87,7 @@ class Document(models.Model): def _generate_unique_slug(self): """ generate a unique slug based on name and uploaded_at """ - _slug = defaultfilters.slugify(self.name) + _slug = slugify(self.name) klass = self.__class__ collision = klass.objects.filter(slug=_slug) if collision: -- 2.25.1