Only save new version, when version-data has changed
This commit is contained in:
parent
1f87749742
commit
8708ba5da6
@ -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"),
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user