From 200ca5cdb1e2faa36f10906e1bc2da2215aafe80 Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Tue, 14 Jan 2014 11:40:47 -0500 Subject: [PATCH] Django 1.5 fixes, also turn indexing back on (oops) --- karmaworld/apps/courses/models.py | 6 +++--- karmaworld/apps/courses/test/test.py | 14 +++++++++----- karmaworld/apps/notes/models.py | 2 +- karmaworld/apps/notes/search.py | 2 +- karmaworld/templates/partial/filepicker.html | 2 +- karmaworld/urls.py | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/karmaworld/apps/courses/models.py b/karmaworld/apps/courses/models.py index 9a36d98..5419dc4 100644 --- a/karmaworld/apps/courses/models.py +++ b/karmaworld/apps/courses/models.py @@ -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 = slugify(self.name) + self.slug = slugify(unicode(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 = slugify(self.name) + self.slug = slugify(unicode(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 = slugify("%s %s" % (self.name, self.id)) + self.slug = slugify(u"%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 4951e01..6a424e2 100644 --- a/karmaworld/apps/courses/test/test.py +++ b/karmaworld/apps/courses/test/test.py @@ -11,21 +11,25 @@ class CoursesTests(TestCase): def setUp(self): self.harvard = School.objects.create(name="Harvard University") self.harvard.save() - self.course1 = Course.objects.create(name="Underwater Basketweaving", instructor_name="Alice Janney", school=self.harvard) + self.department = Department.objects.create(name="School of Study", school=self.harvard) + self.department.save() + self.course1 = Course.objects.create(name="Underwater Basketweaving", instructor_name="Alice Janney", + school=self.harvard, department=self.department) self.client = Client() def testCourseUniqueness(self): """Make sure we can't create multiple courses with the same - school + course name + instructor name combination.""" + name + department name combination.""" with self.assertRaises(IntegrityError): - Course.objects.create(name=self.course1.name, instructor_name=self.course1.instructor_name, school=self.course1.school) + Course.objects.create(name=self.course1.name, instructor_name=self.course1.instructor_name, + school=self.course1.school, department=self.department) self.assertEqual(Course.objects.count(), 1) def testSchoolSlug(self): - self.assertEqual(self.harvard.slug, slugify(self.harvard.name)) + self.assertEqual(self.harvard.slug, slugify(unicode(self.harvard.name))) def testCourseSlug(self): - self.assertEqual(self.course1.slug, slugify("%s %s" % (self.course1.name, self.course1.id))) + self.assertEqual(self.course1.slug, slugify(u"%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 00e72cf..9cc402f 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -87,7 +87,7 @@ class Document(models.Model): def _generate_unique_slug(self): """ generate a unique slug based on name and uploaded_at """ - _slug = slugify(self.name) + _slug = slugify(unicode(self.name)) klass = self.__class__ collision = klass.objects.filter(slug=_slug) if collision: diff --git a/karmaworld/apps/notes/search.py b/karmaworld/apps/notes/search.py index 4a5869f..03bcfa3 100644 --- a/karmaworld/apps/notes/search.py +++ b/karmaworld/apps/notes/search.py @@ -94,7 +94,7 @@ class SearchIndex(object): already in the index, it will be overwritten.""" if note.text: logger.info("Indexing {n}".format(n=note)) - #self.index.add_document(note.id, SearchIndex._note_to_dict(note), variables={0: note.thanks}) + self.index.add_document(note.id, SearchIndex._note_to_dict(note), variables={0: note.thanks}) else: logger.info("Note {n} has no text, will not add to IndexDen".format(n=note)) diff --git a/karmaworld/templates/partial/filepicker.html b/karmaworld/templates/partial/filepicker.html index c4580cc..61ca95f 100644 --- a/karmaworld/templates/partial/filepicker.html +++ b/karmaworld/templates/partial/filepicker.html @@ -1,5 +1,5 @@ {% load url from future %} -{% load socialaccount_tags %} +{% load socialaccount %}
diff --git a/karmaworld/urls.py b/karmaworld/urls.py index 30cc7a7..b859767 100644 --- a/karmaworld/urls.py +++ b/karmaworld/urls.py @@ -5,7 +5,7 @@ from django.contrib import admin from django.conf import settings -from django.conf.urls.defaults import patterns, include, url +from django.conf.urls import patterns, include, url from django.views.generic.base import TemplateView from karmaworld.apps.courses.models import Course -- 2.25.1