From 41124a53ca12532e97e91d6e81edbe2346e9f092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Sch=C3=BCtze?= Date: Fri, 6 Jan 2017 13:01:08 +0100 Subject: [PATCH] Add new personal settings MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS. Set settings value to False to disable new amendment button in motion detail template. Default: True. --- CHANGELOG | 1 + openslides/core/views.py | 4 +-- openslides/motions/static/js/motions/base.js | 25 ++++++++++++++++++- .../templates/motions/motion-detail.html | 5 ++-- openslides/utils/settings.py.tpl | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 746a1770a..f1d9cd3eb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,7 @@ Motions: - New csv import layout and using Papa Parse for parsing the csv. - Number of ballots printed can now be set in config. - Add new personal settings to remove all whitespaces from motion identifier. +- Add new personal settings to allow amendments of amendments. Elections: - Added options to calculate percentages on different bases. diff --git a/openslides/core/views.py b/openslides/core/views.py index c0541ce08..1621fb8d5 100644 --- a/openslides/core/views.py +++ b/openslides/core/views.py @@ -140,7 +140,7 @@ class WebclientJavaScriptView(utils_views.View): js_files.extend(app_js_files) client_settings_keys = [ - # Add new settings to personal settings.py, utils/settings.py.tpl and to this list. Remove this comment later. + 'MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS' ] client_settings = {} for key in client_settings_keys: @@ -184,7 +184,7 @@ class WebclientJavaScriptView(utils_views.View): $.when.apply(this,deferres).done( function() {{ angular.bootstrap(document,['OpenSlidesApp.{realm}']); }} ); - """.format(realm=realm, angular_modules=angular_modules, settings=client_settings, js_files=js_files) + + """.format(realm=realm, angular_modules=angular_modules, settings=json.dumps(client_settings), js_files=js_files) + """ }()); """) diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index bbe689246..69930331e 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -202,9 +202,10 @@ angular.module('OpenSlidesApp.motions', [ 'Config', 'lineNumberingService', 'diffService', + 'OpenSlidesSettings', 'Projector', function(DS, $http, MotionPoll, MotionChangeRecommendation, MotionComment, jsDataModel, gettext, gettextCatalog, - operator, Config, lineNumberingService, diffService, Projector) { + operator, Config, lineNumberingService, diffService, OpenSlidesSettings, Projector) { var name = 'motions/motion'; return DS.defineResource({ name: name, @@ -406,6 +407,12 @@ angular.module('OpenSlidesApp.motions', [ ] }); }, + isAmendment: function () { + return this.parent_id !== null; + }, + hasAmendments: function () { + return DS.filter('motions/motion', {parent_id: this.id}).length > 0; + }, isAllowed: function (action) { /* * Return true if the requested user is allowed to do the specific action. @@ -468,6 +475,22 @@ angular.module('OpenSlidesApp.motions', [ return operator.hasPerms('motions.can_manage'); case 'can_manage': return operator.hasPerms('motions.can_manage'); + case 'can_see_amendments': + var result; + if (operator.hasPerms('motions.can_create')) { + result = Config.get('motions_amendments_enabled').value && + (this.hasAmendments() || this.isAllowed('can_create_amendment')); + } else if (operator.hasPerms('motions.can_see')) { + result = Config.get('motions_amendments_enabled').value && this.hasAmendments(); + } + return result; + case 'can_create_amendment': + return ( + operator.hasPerms('motions.can_create') && + Config.get('motions_amendments_enabled').value && + ( !this.isAmendment() || + (this.isAmendment() && OpenSlidesSettings.MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS)) + ); default: return false; } diff --git a/openslides/motions/static/templates/motions/motion-detail.html b/openslides/motions/static/templates/motions/motion-detail.html index 9ca53c518..53394260f 100644 --- a/openslides/motions/static/templates/motions/motion-detail.html +++ b/openslides/motions/static/templates/motions/motion-detail.html @@ -113,14 +113,15 @@ -
+ +

Amendments

Motion {{ amendment.identifier || amendment.getTitle() }}
- diff --git a/openslides/utils/settings.py.tpl b/openslides/utils/settings.py.tpl index 0f4c0226e..e2fb2b530 100644 --- a/openslides/utils/settings.py.tpl +++ b/openslides/utils/settings.py.tpl @@ -121,3 +121,4 @@ SEARCH_INDEX = os.path.join(OPENSLIDES_USER_DATA_PATH, 'search_index') MOTION_IDENTIFIER_MIN_DIGITS = 1 MOTION_IDENTIFIER_WITHOUT_BLANKS = False +MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS = True