From 8708ba5da67b14b947a84e84ace1ebc0ae22a2f4 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sat, 26 Jan 2013 15:39:35 +0100 Subject: [PATCH] Only save new version, when version-data has changed --- openslides/motion/forms.py | 2 -- openslides/motion/models.py | 8 +++++--- openslides/motion/views.py | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/openslides/motion/forms.py b/openslides/motion/forms.py index 028328837..ef644aff1 100644 --- a/openslides/motion/forms.py +++ b/openslides/motion/forms.py @@ -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"), diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 19afe043e..65c73d326 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -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 diff --git a/openslides/motion/views.py b/openslides/motion/views.py index c46697f20..23815b9d2 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -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.