From: Jacob Hilker Date: Sun, 2 Feb 2014 00:35:03 +0000 (-0500) Subject: use middleware for revision X-Git-Tag: release-20150131~178^2~9 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3578ac2b9e54c483c7600334cc7113807e5e8333;p=oweals%2Fkarmaworld.git use middleware for revision --- diff --git a/karmaworld/apps/courses/models.py b/karmaworld/apps/courses/models.py index 78761a8..8619553 100644 --- a/karmaworld/apps/courses/models.py +++ b/karmaworld/apps/courses/models.py @@ -249,7 +249,6 @@ class Course(models.Model): """ 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 @@ -265,7 +264,6 @@ class Course(models.Model): 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() diff --git a/karmaworld/apps/courses/views.py b/karmaworld/apps/courses/views.py index 0e91be5..714047c 100644 --- a/karmaworld/apps/courses/views.py +++ b/karmaworld/apps/courses/views.py @@ -4,7 +4,6 @@ """ Views for the KarmaNotes Courses app """ import json -import reversion from django.core import serializers from django.core.exceptions import MultipleObjectsReturned @@ -202,7 +201,6 @@ def flag_course(request, pk): """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 diff --git a/karmaworld/settings/common.py b/karmaworld/settings/common.py index af0271e..06f03e1 100644 --- a/karmaworld/settings/common.py +++ b/karmaworld/settings/common.py @@ -177,6 +177,9 @@ MIDDLEWARE_CLASSES = ( # 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',