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
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)
""" 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):
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"""
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:
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))
{% 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>
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