From 4472734d098ca199a53be68a6f326466dcdc2670 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 18 Aug 2017 13:13:53 +0200 Subject: [PATCH] New permission for managing lists of speakers (fixes #3363) --- CHANGELOG | 1 + .../migrations/0003_auto_20170818_1202.py | 27 +++++++++++++++++++ openslides/agenda/models.py | 1 + openslides/agenda/static/js/agenda/site.js | 11 +++----- .../list-of-speakers-partial-management.html | 18 +++++++------ openslides/agenda/views.py | 9 ++++--- openslides/users/signals.py | 2 ++ openslides/users/static/js/users/site.js | 1 + 8 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 openslides/agenda/migrations/0003_auto_20170818_1202.py diff --git a/CHANGELOG b/CHANGELOG index 311af3106..42dd00c0f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ Version 2.2 (unreleased) Agenda: - Fixed wrong sorting of last speakers [#3193]. - Fixed issue when sorting a new inserted speaker [#3210]. +- New permission for managing lists of speakers [#3366]. Motions: - New export dialog [#3185]. diff --git a/openslides/agenda/migrations/0003_auto_20170818_1202.py b/openslides/agenda/migrations/0003_auto_20170818_1202.py new file mode 100644 index 000000000..719058023 --- /dev/null +++ b/openslides/agenda/migrations/0003_auto_20170818_1202.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-08-18 10:02 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda', '0002_item_duration'), + ] + + operations = [ + migrations.AlterModelOptions( + name='item', + options={ + 'default_permissions': (), + 'permissions': ( + ('can_see', 'Can see agenda'), + ('can_manage', 'Can manage agenda'), + ('can_manage_list_of_speakers', 'Can manage list of speakers'), + ('can_see_hidden_items', 'Can see hidden items and time scheduling of agenda') + ) + }, + ), + ] diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 090668721..221781581 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -278,6 +278,7 @@ class Item(RESTModelMixin, models.Model): permissions = ( ('can_see', 'Can see agenda'), ('can_manage', 'Can manage agenda'), + ('can_manage_list_of_speakers', 'Can manage list of speakers'), ('can_see_hidden_items', 'Can see hidden items and time scheduling of agenda')) unique_together = ('content_type', 'object_id') diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 73b04808e..1a2d7027a 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -451,7 +451,6 @@ angular.module('OpenSlidesApp.agenda.site', [ $http.post('/rest/agenda/item/' + $scope.item.id + '/manage_speaker/', {'user': userId}).then( function (success) { $scope.alert.show = false; - $scope.speakers = $scope.item.speakers; $scope.speakerSelectBox = {}; }, function (error) { $scope.alert = ErrorMessage.forAlert(error); @@ -468,11 +467,9 @@ angular.module('OpenSlidesApp.agenda.site', [ data: JSON.stringify({speaker: speakerId})} ) .then(function (success) { - $scope.speakers = $scope.item.speakers; }, function (error) { $scope.alert = ErrorMessage.forAlert(error); }); - $scope.speakers = $scope.item.speakers; }; //delete all speakers from list of speakers @@ -487,11 +484,9 @@ angular.module('OpenSlidesApp.agenda.site', [ data: JSON.stringify({speaker: speakersOnList})} ) .then(function (success) { - $scope.speakers = $scope.item.speakers; }, function (error) { $scope.alert = ErrorMessage.forAlert(error); }); - $scope.speakers = $scope.item.speakers; }; // Return true if the requested user is allowed to do a specific action @@ -512,13 +507,13 @@ angular.module('OpenSlidesApp.agenda.site', [ } return false; case 'removeAll': - return (operator.hasPerms('agenda.can_manage') && + return (operator.hasPerms('agenda.can_manage_list_of_speakers') && $scope.speakers.length > 0); case 'beginNextSpeech': - return (operator.hasPerms('agenda.can_manage') && + return (operator.hasPerms('agenda.can_manage_list_of_speakers') && $scope.nextSpeakers.length > 0); case 'endCurrentSpeech': - return (operator.hasPerms('agenda.can_manage') && + return (operator.hasPerms('agenda.can_manage_list_of_speakers') && $scope.currentSpeaker.length > 0); case 'showLastSpeakers': return $scope.lastSpeakers.length > 0; diff --git a/openslides/agenda/static/templates/agenda/list-of-speakers-partial-management.html b/openslides/agenda/static/templates/agenda/list-of-speakers-partial-management.html index 63f1859fc..e0e21788f 100644 --- a/openslides/agenda/static/templates/agenda/list-of-speakers-partial-management.html +++ b/openslides/agenda/static/templates/agenda/list-of-speakers-partial-management.html @@ -1,13 +1,15 @@
- + + + @@ -69,11 +71,11 @@

{{ speaker.user.get_full_name() }} - - @@ -84,15 +86,15 @@

  1. - + {{ $index + 1 }}. {{ speaker.user.get_full_name() }}   - - @@ -105,7 +107,7 @@
    {{ alert.msg }}
    -
    +