Django 1.5 fixes, also turn indexing back on (oops)
authorCharles Connell <charles@connells.org>
Tue, 14 Jan 2014 16:40:47 +0000 (11:40 -0500)
committerCharles Connell <charles@connells.org>
Tue, 14 Jan 2014 16:40:47 +0000 (11:40 -0500)
karmaworld/apps/courses/models.py
karmaworld/apps/courses/test/test.py
karmaworld/apps/notes/models.py
karmaworld/apps/notes/search.py
karmaworld/templates/partial/filepicker.html
karmaworld/urls.py

index 9a36d98e20baba8040d9b87edd69ff39185ba443..5419dc445959e12309d74a9d394402a560b85a3f 100644 (file)
@@ -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):
index 4951e017ea50b92b834df85e1b2143562518e2e5..6a424e2eae7b4a847171acafd9b6032490a7f44d 100644 (file)
@@ -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"""
index 00e72cf39fa8bd8536cd35ea10bf2bd0f7d32be5..9cc402f6f3a3d19c4db9ecc1f0a6741be1ba36ab 100644 (file)
@@ -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:
index 4a5869f3b481ba1122c39a63e8252c096b95a7a3..03bcfa3fb1507bad3ab6233c62b2982321234781 100644 (file)
@@ -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))
 
index c4580cc49a5dfc4597928d4173f94ee89c086444..61ca95fec229f98bb4b227060b92a66f8330109a 100644 (file)
@@ -1,5 +1,5 @@
 {% load url from future %}
-{% load socialaccount_tags %}
+{% load socialaccount %}
 <section id=filepicker-form class="extend-form">
 <!-- Javascript -->
 <script type="text/javascript" src="//api.filepicker.io/v1/filepicker.js"></script>
index 30cc7a75d0714cfa7974916a4cc1cb6d8972b246..b859767e37edd597f48e70fc35acca8352bdeeba 100644 (file)
@@ -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