From 78640a27f155bcbdf6e2233984d73196419a1ad8 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 10 Jan 2016 09:24:26 +0100 Subject: [PATCH] Remove item id from error message "{user} is already on the list of speakers." --- openslides/agenda/models.py | 3 +- openslides/agenda/static/js/agenda/site.js | 71 ++++++++++++---------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 3f72910c9..7adf1af52 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -302,8 +302,7 @@ class SpeakerManager(models.Manager): """ if self.filter(user=user, item=item, begin_time=None).exists(): raise OpenSlidesError( - _('%(user)s is already on the list of speakers of %(id)s.') - % {'user': user, 'id': item.id}) + _('{user} is already on the list of speakers.').format(user=user) if isinstance(user, AnonymousUser): raise OpenSlidesError( _('An anonymous user can not be on lists of speakers.')) diff --git a/openslides/agenda/static/js/agenda/site.js b/openslides/agenda/static/js/agenda/site.js index 27aa213a9..1b84d22b3 100644 --- a/openslides/agenda/static/js/agenda/site.js +++ b/openslides/agenda/static/js/agenda/site.js @@ -197,55 +197,63 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) }, function () { $scope.speakers = $filter('orderBy')(item.speakers, 'weight'); }); + // close/open list of speakers of current item $scope.closeList = function (listClosed) { item.speaker_list_closed = listClosed; Agenda.save(item); }; + // add user to list of speakers $scope.addSpeaker = function (userId) { $http.post('/rest/agenda/item/' + item.id + '/manage_speaker/', {'user': userId}) - .success(function(data){ - $scope.alert.show = false; - $scope.speakers = item.speakers; - $scope.speakerSelectBox = {}; - }) - .error(function(data){ - $scope.alert = { type: 'danger', msg: data.detail, show: true }; - $scope.speakerSelectBox = {}; - }); + .success(function (data){ + $scope.alert.show = false; + $scope.speakers = item.speakers; + $scope.speakerSelectBox = {}; + }) + .error(function (data){ + $scope.alert = {type: 'danger', msg: data.detail, show: true}; + $scope.speakerSelectBox = {}; + }); }; + // delete speaker(!) from list of speakers $scope.removeSpeaker = function (speakerId) { - $http.delete('/rest/agenda/item/' + item.id + '/manage_speaker/', - {headers: {'Content-Type': 'application/json'}, - data: JSON.stringify({speaker: speakerId})}) - .success(function(data){ - $scope.speakers = item.speakers; - }) - .error(function(data){ - $scope.alert = { type: 'danger', msg: data.detail, show: true }; - }); + $http.delete( + '/rest/agenda/item/' + item.id + '/manage_speaker/', + {headers: {'Content-Type': 'application/json'}, + data: JSON.stringify({speaker: speakerId})} + ) + .success(function(data){ + $scope.speakers = item.speakers; + }) + .error(function(data){ + $scope.alert = { type: 'danger', msg: data.detail, show: true }; + }); $scope.speakers = item.speakers; }; + // begin speech of selected/next speaker $scope.beginSpeech = function (speakerId) { $http.put('/rest/agenda/item/' + item.id + '/speak/', {'speaker': speakerId}) - .success(function(data){ - $scope.alert.show = false; - }) - .error(function(data){ - $scope.alert = { type: 'danger', msg: data.detail, show: true }; - }); + .success(function(data){ + $scope.alert.show = false; + }) + .error(function(data){ + $scope.alert = { type: 'danger', msg: data.detail, show: true }; + }); }; + // end speech of current speaker $scope.endSpeech = function () { - $http.delete('/rest/agenda/item/' + item.id + '/speak/', - {headers: {'Content-Type': 'application/json'}, - data: JSON.stringify()}) - .error(function(data){ - $scope.alert = { type: 'danger', msg: data.detail, show: true }; - }); + $http.delete( + '/rest/agenda/item/' + item.id + '/speak/', + {headers: {'Content-Type': 'application/json'}, data: JSON.stringify()} + ) + .error(function(data){ + $scope.alert = { type: 'danger', msg: data.detail, show: true }; + }); }; // save reordered list of speakers $scope.treeOptions = { @@ -256,7 +264,8 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda']) sortedSpeakers.push(speaker.id); }); $http.post('/rest/agenda/item/' + item.id + '/sort_speakers/', - {speakers: sortedSpeakers}); + {speakers: sortedSpeakers} + ); } }; }