From 32d3d804b189b05fe02c90a92b6362fb1df2fe06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sun, 13 Nov 2016 13:19:16 +0100 Subject: [PATCH] Overhaul change recommendation statuses --- .../migrations/0008_auto_20161116_2222.py | 24 ++++++++++++++++ openslides/motions/models.py | 4 +-- openslides/motions/serializers.py | 2 +- openslides/motions/static/js/motions/base.js | 22 +++++++++------ .../static/js/motions/motion-services.js | 9 ++---- .../templates/motions/motion-detail.html | 4 +-- .../motions/motion-detail/change-summary.html | 4 +-- .../motions/motion-detail/view-diff.html | 28 +++++++------------ 8 files changed, 55 insertions(+), 42 deletions(-) create mode 100644 openslides/motions/migrations/0008_auto_20161116_2222.py diff --git a/openslides/motions/migrations/0008_auto_20161116_2222.py b/openslides/motions/migrations/0008_auto_20161116_2222.py new file mode 100644 index 000000000..06eecba7d --- /dev/null +++ b/openslides/motions/migrations/0008_auto_20161116_2222.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.1 on 2016-11-16 21:22 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('motions', '0007_auto_20161027_1406'), + ] + + operations = [ + migrations.RemoveField( + model_name='motionchangerecommendation', + name='status', + ), + migrations.AddField( + model_name='motionchangerecommendation', + name='rejected', + field=models.BooleanField(default=False), + ), + ] diff --git a/openslides/motions/models.py b/openslides/motions/models.py index f523aa5ab..3a027f02f 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -757,8 +757,8 @@ class MotionChangeRecommendation(RESTModelMixin, models.Model): related_name='change_recommendations') """The motion version to which the change recommendation belongs.""" - status = models.PositiveIntegerField(default=0) - """Proposed (0), Accepted (1), Rejected (2)""" + rejected = models.BooleanField(default=False) + """If true, this change recommendation has been rejected""" line_from = models.PositiveIntegerField() """The number or the first affected line""" diff --git a/openslides/motions/serializers.py b/openslides/motions/serializers.py index 9f19e53f0..03761a257 100644 --- a/openslides/motions/serializers.py +++ b/openslides/motions/serializers.py @@ -250,7 +250,7 @@ class MotionChangeRecommendationSerializer(ModelSerializer): fields = ( 'id', 'motion_version', - 'status', + 'rejected', 'line_from', 'line_to', 'text', diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 24cf821b9..d09ace0b0 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -239,15 +239,14 @@ angular.module('OpenSlidesApp.motions', [ return html; }, - getTextWithChangeRecommendations: function (versionId, statusCompareCb) { + _getTextWithChangeRecommendations: function (versionId, statusCompareCb) { var lineLength = Config.get('motions_line_length').value, html = this.getVersion(versionId).text, - changes = this.getChangeRecommendations(versionId, 'DESC'), - fragment; + changes = this.getChangeRecommendations(versionId, 'DESC'); for (var i = 0; i < changes.length; i++) { var change = changes[i]; - if (statusCompareCb === undefined || statusCompareCb(change.status)) { + if (statusCompareCb === undefined || statusCompareCb(change.rejected)) { html = lineNumberingService.insertLineNumbers(html, lineLength); html = diffService.replaceLines(html, change.text, change.line_from, change.line_to); } @@ -255,9 +254,14 @@ angular.module('OpenSlidesApp.motions', [ return lineNumberingService.insertLineNumbers(html, lineLength); }, - getTextWithAcceptedChangeRecommendations: function (versionId) { - return this.getTextWithChangeRecommendations(versionId, function(status) { - return (status == 1); + getTextWithAllChangeRecommendations: function (versionId) { + return this._getTextWithChangeRecommendations(versionId, function() { + return true; + }); + }, + getTextWithoutRejectedChangeRecommendations: function (versionId) { + return this._getTextWithChangeRecommendations(versionId, function(rejected) { + return !rejected; }); }, getTextByMode: function(mode, versionId) { @@ -280,10 +284,10 @@ angular.module('OpenSlidesApp.motions', [ text += this.getTextRemainderAfterLastChangeRecommendation(versionId, changes); break; case 'changed': - text = this.getTextWithChangeRecommendations(versionId); + text = this.getTextWithAllChangeRecommendations(versionId); break; case 'agreed': - text = this.getTextWithAcceptedChangeRecommendations(versionId); + text = this.getTextWithoutRejectedChangeRecommendations(versionId); break; } return text; diff --git a/openslides/motions/static/js/motions/motion-services.js b/openslides/motions/static/js/motions/motion-services.js index f47f72cb3..5bf1128c8 100644 --- a/openslides/motions/static/js/motions/motion-services.js +++ b/openslides/motions/static/js/motions/motion-services.js @@ -411,17 +411,12 @@ angular.module('OpenSlidesApp.motions.motionservices', ['OpenSlidesApp.motions', }); }; - obj.newVersionIncludingChanges = function (motion, version, includeProposed) { + obj.newVersionIncludingChanges = function (motion, version) { if (!motion.isAllowed('update')) { throw 'No permission to update motion'; } - var newHtml = ( - includeProposed ? - motion.getTextWithoutRejectedChangeRecommendations(version) : - motion.getTextWithAcceptedChangeRecommendations(version) - ); - + var newHtml = motion.getTextByMode('agreed'); motion.setTextStrippingLineBreaks(newHtml); Motion.inject(motion); diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index e3c7a04e6..5e3ce6b84 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -345,7 +345,7 @@
-
@@ -360,7 +360,7 @@
-
diff --git a/openslides/motions/static/templates/motions/motion-detail/change-summary.html b/openslides/motions/static/templates/motions/motion-detail/change-summary.html index ce7e029d0..14cef260d 100644 --- a/openslides/motions/static/templates/motions/motion-detail/change-summary.html +++ b/openslides/motions/static/templates/motions/motion-detail/change-summary.html @@ -18,9 +18,7 @@ Deletion - Suggested - Accepted - Rejected + Rejected diff --git a/openslides/motions/static/templates/motions/motion-detail/view-diff.html b/openslides/motions/static/templates/motions/motion-detail/view-diff.html index 74d0f899a..d5f3ccc63 100644 --- a/openslides/motions/static/templates/motions/motion-detail/view-diff.html +++ b/openslides/motions/static/templates/motions/motion-detail/view-diff.html @@ -10,22 +10,16 @@
- -
@@ -37,10 +31,8 @@
-
- Suggested - Accepted - Rejected +
+ Rejected