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"))
|
supporter = MultiplePersonFormField(required=False, label=_("Supporters"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MotionTrivialChangesMixin(object):
|
class MotionTrivialChangesMixin(object):
|
||||||
trivial_change = forms.BooleanField(
|
trivial_change = forms.BooleanField(
|
||||||
required=False, label=_("Trivial change"),
|
required=False, label=_("Trivial change"),
|
||||||
|
@ -87,11 +87,13 @@ class Motion(SlideMixin, models.Model):
|
|||||||
Saves the motion. Create or update a motion_version object
|
Saves the motion. Create or update a motion_version object
|
||||||
"""
|
"""
|
||||||
super(Motion, self).save(*args, **kwargs)
|
super(Motion, self).save(*args, **kwargs)
|
||||||
new_data = False
|
for attr in ['title', 'text', 'reason']:
|
||||||
for attr in ['_title', '_text', '_reason']:
|
if getattr(self, attr) != getattr(self.last_version, attr):
|
||||||
if hasattr(self, attr):
|
|
||||||
new_data = True
|
new_data = True
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
new_data = False
|
||||||
|
|
||||||
need_new_version = True # TODO: Do we need a new version (look in config)
|
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):
|
if hasattr(self, '_version') or (new_data and need_new_version):
|
||||||
version = self.new_version
|
version = self.new_version
|
||||||
|
@ -32,10 +32,6 @@ from .models import Motion, MotionSubmitter
|
|||||||
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
|
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
|
||||||
MotionTrivialChangesMixin)
|
MotionTrivialChangesMixin)
|
||||||
|
|
||||||
|
|
||||||
from django.views.generic.edit import ModelFormMixin
|
|
||||||
|
|
||||||
|
|
||||||
class MotionListView(ListView):
|
class MotionListView(ListView):
|
||||||
"""
|
"""
|
||||||
List all motion.
|
List all motion.
|
||||||
|
Loading…
Reference in New Issue
Block a user