updating slugify for 1.5.5, not necessary but good practice.
authorBryan <btbonval@gmail.com>
Sun, 12 Jan 2014 08:10:35 +0000 (08:10 +0000)
committerBryan <btbonval@gmail.com>
Sun, 12 Jan 2014 08:10:35 +0000 (08:10 +0000)
karmaworld/apps/courses/models.py
karmaworld/apps/courses/test/test.py
karmaworld/apps/notes/models.py

index 4543a078faf3eb4c6cba6ff442a69d5774a28e05..9a36d98e20baba8040d9b87edd69ff39185ba443 100644 (file)
@@ -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):
index 115715242cbbd51a62a723f9a8eaa35b5e39723e..4951e017ea50b92b834df85e1b2143562518e2e5 100644 (file)
@@ -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"""
index d284977020f30a4353fbfd06b6279676016b04f9..00e72cf39fa8bd8536cd35ea10bf2bd0f7d32be5 100644 (file)
@@ -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: