Remove item id from error message "{user} is already on the list of speakers."

This commit is contained in:
Oskar Hahn 2016-01-10 09:24:26 +01:00
parent 7dd9edec8b
commit 78640a27f1
2 changed files with 41 additions and 33 deletions

View File

@ -302,8 +302,7 @@ class SpeakerManager(models.Manager):
""" """
if self.filter(user=user, item=item, begin_time=None).exists(): if self.filter(user=user, item=item, begin_time=None).exists():
raise OpenSlidesError( raise OpenSlidesError(
_('%(user)s is already on the list of speakers of %(id)s.') _('{user} is already on the list of speakers.').format(user=user)
% {'user': user, 'id': item.id})
if isinstance(user, AnonymousUser): if isinstance(user, AnonymousUser):
raise OpenSlidesError( raise OpenSlidesError(
_('An anonymous user can not be on lists of speakers.')) _('An anonymous user can not be on lists of speakers.'))

View File

@ -197,55 +197,63 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
}, function () { }, function () {
$scope.speakers = $filter('orderBy')(item.speakers, 'weight'); $scope.speakers = $filter('orderBy')(item.speakers, 'weight');
}); });
// close/open list of speakers of current item // close/open list of speakers of current item
$scope.closeList = function (listClosed) { $scope.closeList = function (listClosed) {
item.speaker_list_closed = listClosed; item.speaker_list_closed = listClosed;
Agenda.save(item); Agenda.save(item);
}; };
// add user to list of speakers // add user to list of speakers
$scope.addSpeaker = function (userId) { $scope.addSpeaker = function (userId) {
$http.post('/rest/agenda/item/' + item.id + '/manage_speaker/', {'user': userId}) $http.post('/rest/agenda/item/' + item.id + '/manage_speaker/', {'user': userId})
.success(function(data){ .success(function (data){
$scope.alert.show = false; $scope.alert.show = false;
$scope.speakers = item.speakers; $scope.speakers = item.speakers;
$scope.speakerSelectBox = {}; $scope.speakerSelectBox = {};
}) })
.error(function(data){ .error(function (data){
$scope.alert = { type: 'danger', msg: data.detail, show: true }; $scope.alert = {type: 'danger', msg: data.detail, show: true};
$scope.speakerSelectBox = {}; $scope.speakerSelectBox = {};
}); });
}; };
// delete speaker(!) from list of speakers // delete speaker(!) from list of speakers
$scope.removeSpeaker = function (speakerId) { $scope.removeSpeaker = function (speakerId) {
$http.delete('/rest/agenda/item/' + item.id + '/manage_speaker/', $http.delete(
{headers: {'Content-Type': 'application/json'}, '/rest/agenda/item/' + item.id + '/manage_speaker/',
data: JSON.stringify({speaker: speakerId})}) {headers: {'Content-Type': 'application/json'},
.success(function(data){ data: JSON.stringify({speaker: speakerId})}
$scope.speakers = item.speakers; )
}) .success(function(data){
.error(function(data){ $scope.speakers = item.speakers;
$scope.alert = { type: 'danger', msg: data.detail, show: true }; })
}); .error(function(data){
$scope.alert = { type: 'danger', msg: data.detail, show: true };
});
$scope.speakers = item.speakers; $scope.speakers = item.speakers;
}; };
// begin speech of selected/next speaker // begin speech of selected/next speaker
$scope.beginSpeech = function (speakerId) { $scope.beginSpeech = function (speakerId) {
$http.put('/rest/agenda/item/' + item.id + '/speak/', {'speaker': speakerId}) $http.put('/rest/agenda/item/' + item.id + '/speak/', {'speaker': speakerId})
.success(function(data){ .success(function(data){
$scope.alert.show = false; $scope.alert.show = false;
}) })
.error(function(data){ .error(function(data){
$scope.alert = { type: 'danger', msg: data.detail, show: true }; $scope.alert = { type: 'danger', msg: data.detail, show: true };
}); });
}; };
// end speech of current speaker // end speech of current speaker
$scope.endSpeech = function () { $scope.endSpeech = function () {
$http.delete('/rest/agenda/item/' + item.id + '/speak/', $http.delete(
{headers: {'Content-Type': 'application/json'}, '/rest/agenda/item/' + item.id + '/speak/',
data: JSON.stringify()}) {headers: {'Content-Type': 'application/json'}, data: JSON.stringify()}
.error(function(data){ )
$scope.alert = { type: 'danger', msg: data.detail, show: true }; .error(function(data){
}); $scope.alert = { type: 'danger', msg: data.detail, show: true };
});
}; };
// save reordered list of speakers // save reordered list of speakers
$scope.treeOptions = { $scope.treeOptions = {
@ -256,7 +264,8 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
sortedSpeakers.push(speaker.id); sortedSpeakers.push(speaker.id);
}); });
$http.post('/rest/agenda/item/' + item.id + '/sort_speakers/', $http.post('/rest/agenda/item/' + item.id + '/sort_speakers/',
{speakers: sortedSpeakers}); {speakers: sortedSpeakers}
);
} }
}; };
} }