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.
This commit is contained in:
Emanuel Schütze 2017-01-06 13:01:08 +01:00
parent 6502f36a90
commit 41124a53ca
5 changed files with 31 additions and 5 deletions

View File

@ -56,6 +56,7 @@ Motions:
- New csv import layout and using Papa Parse for parsing the csv. - New csv import layout and using Papa Parse for parsing the csv.
- Number of ballots printed can now be set in config. - 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 remove all whitespaces from motion identifier.
- Add new personal settings to allow amendments of amendments.
Elections: Elections:
- Added options to calculate percentages on different bases. - Added options to calculate percentages on different bases.

View File

@ -140,7 +140,7 @@ class WebclientJavaScriptView(utils_views.View):
js_files.extend(app_js_files) js_files.extend(app_js_files)
client_settings_keys = [ 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 = {} client_settings = {}
for key in client_settings_keys: for key in client_settings_keys:
@ -184,7 +184,7 @@ class WebclientJavaScriptView(utils_views.View):
$.when.apply(this,deferres).done( function() {{ $.when.apply(this,deferres).done( function() {{
angular.bootstrap(document,['OpenSlidesApp.{realm}']); 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) +
""" """
}()); }());
""") """)

View File

@ -202,9 +202,10 @@ angular.module('OpenSlidesApp.motions', [
'Config', 'Config',
'lineNumberingService', 'lineNumberingService',
'diffService', 'diffService',
'OpenSlidesSettings',
'Projector', 'Projector',
function(DS, $http, MotionPoll, MotionChangeRecommendation, MotionComment, jsDataModel, gettext, gettextCatalog, function(DS, $http, MotionPoll, MotionChangeRecommendation, MotionComment, jsDataModel, gettext, gettextCatalog,
operator, Config, lineNumberingService, diffService, Projector) { operator, Config, lineNumberingService, diffService, OpenSlidesSettings, Projector) {
var name = 'motions/motion'; var name = 'motions/motion';
return DS.defineResource({ return DS.defineResource({
name: name, 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) { isAllowed: function (action) {
/* /*
* Return true if the requested user is allowed to do the specific 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'); return operator.hasPerms('motions.can_manage');
case 'can_manage': case 'can_manage':
return operator.hasPerms('motions.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: default:
return false; return false;
} }

View File

@ -113,14 +113,15 @@
</button> </button>
</div> </div>
<!-- Amendments --> <!-- Amendments -->
<div ng-if="config('motions_amendments_enabled')">
<div ng-if="motion.isAllowed('can_see_amendments')">
<h3 translate>Amendments</h3> <h3 translate>Amendments</h3>
<div ng-repeat="amendment in amendments"> <div ng-repeat="amendment in amendments">
<a ui-sref="motions.motion.detail({id: amendment.id})"> <a ui-sref="motions.motion.detail({id: amendment.id})">
<translate>Motion</translate> {{ amendment.identifier || amendment.getTitle() }} <translate>Motion</translate> {{ amendment.identifier || amendment.getTitle() }}
</a> </a>
</div> </div>
<button os-perms="motions.can_create" ng-click="newAmendment()" class="btn btn-default btn-sm"> <button ng-if="motion.isAllowed('can_create_amendment')" ng-click="newAmendment()" class="btn btn-default btn-sm">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
<translate>New amendment</translate> <translate>New amendment</translate>
</button> </button>

View File

@ -121,3 +121,4 @@ SEARCH_INDEX = os.path.join(OPENSLIDES_USER_DATA_PATH, 'search_index')
MOTION_IDENTIFIER_MIN_DIGITS = 1 MOTION_IDENTIFIER_MIN_DIGITS = 1
MOTION_IDENTIFIER_WITHOUT_BLANKS = False MOTION_IDENTIFIER_WITHOUT_BLANKS = False
MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS = True