Merge pull request #2821 from emanuelschuetze/no-amendments

Add new personal settings MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS.
This commit is contained in:
Emanuel Schütze 2017-01-09 14:33:57 +01:00 committed by GitHub
commit 17b951058b
5 changed files with 31 additions and 5 deletions

View File

@ -57,6 +57,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.

View File

@ -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) +
"""
}());
""")

View File

@ -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;
}

View File

@ -113,14 +113,15 @@
</button>
</div>
<!-- Amendments -->
<div ng-if="config('motions_amendments_enabled')">
<div ng-if="motion.isAllowed('can_see_amendments')">
<h3 translate>Amendments</h3>
<div ng-repeat="amendment in amendments">
<a ui-sref="motions.motion.detail({id: amendment.id})">
<translate>Motion</translate> {{ amendment.identifier || amendment.getTitle() }}
</a>
</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>
<translate>New amendment</translate>
</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_WITHOUT_BLANKS = False
MOTIONS_ALLOW_AMENDMENTS_OF_AMENDMENTS = True