""" return url based on school slug and self slug """
return u"/{0}/{1}".format(self.school.slug, self.slug)
- @reversion.create_revision()
def save(self, *args, **kwargs):
""" Save school and generate a slug if one doesn't exist """
super(Course, self).save(*args, **kwargs) # generate a self.id
def autocomplete_search_fields():
return ("name__icontains",)
- @reversion.create_revision()
def update_note_count(self):
""" Update self.file_count by summing the note_set """
self.file_count = self.note_set.count()
""" Views for the KarmaNotes Courses app """
import json
-import reversion
from django.core import serializers
from django.core.exceptions import MultipleObjectsReturned
"""Record that somebody has flagged a note."""
return ajax_increment(Course, request, pk, FLAG_FIELD, process_course_flag_events)
-@reversion.create_revision()
def edit_course(request, pk):
"""
Saves the edited course content
# Use GZip compression to reduce bandwidth.
'django.middleware.gzip.GZipMiddleware',
+ # Version control middleware.
+ 'reversion.middleware.RevisionMiddleware',
+
# Default Django middleware.
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',