Only save new version, when version-data has changed

This commit is contained in:
Oskar Hahn 2013-01-26 15:39:35 +01:00
parent 1f87749742
commit 8708ba5da6
3 changed files with 5 additions and 9 deletions

View File

@ -49,8 +49,6 @@ class MotionSupporterMixin(forms.ModelForm):
supporter = MultiplePersonFormField(required=False, label=_("Supporters"))
class MotionTrivialChangesMixin(object):
trivial_change = forms.BooleanField(
required=False, label=_("Trivial change"),

View File

@ -87,11 +87,13 @@ class Motion(SlideMixin, models.Model):
Saves the motion. Create or update a motion_version object
"""
super(Motion, self).save(*args, **kwargs)
new_data = False
for attr in ['_title', '_text', '_reason']:
if hasattr(self, attr):
for attr in ['title', 'text', 'reason']:
if getattr(self, attr) != getattr(self.last_version, attr):
new_data = True
break
else:
new_data = False
need_new_version = True # TODO: Do we need a new version (look in config)
if hasattr(self, '_version') or (new_data and need_new_version):
version = self.new_version

View File

@ -32,10 +32,6 @@ from .models import Motion, MotionSubmitter
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
MotionTrivialChangesMixin)
from django.views.generic.edit import ModelFormMixin
class MotionListView(ListView):
"""
List all motion.