Add message if someone adds himself to the list of speakers. Fix #927.

This commit is contained in:
Norman Jäckel 2013-10-22 19:12:42 +02:00
parent 7fcc786cf9
commit 218d0bad23
2 changed files with 13 additions and 1 deletions

View File

@ -348,6 +348,8 @@ class SpeakerAppendView(SingleObjectMixin, RedirectView):
Speaker.objects.add(item=self.object, person=request.user) Speaker.objects.add(item=self.object, person=request.user)
except OpenSlidesError, e: except OpenSlidesError, e:
messages.error(request, e) messages.error(request, e)
else:
messages.success(request, _('You were successfully added to the list of speakers.'))
class SpeakerDeleteView(DeleteView): class SpeakerDeleteView(DeleteView):
@ -573,6 +575,8 @@ class CurrentListOfSpeakersView(RedirectView):
Speaker.objects.add(self.request.user, item) Speaker.objects.add(self.request.user, item)
except OpenSlidesError, e: except OpenSlidesError, e:
messages.error(request, e) messages.error(request, e)
else:
messages.success(request, _('You were successfully added to the list of speakers.'))
finally: finally:
reverse_to_dashboard = False reverse_to_dashboard = False
else: else:

View File

@ -7,6 +7,7 @@
:license: GNU GPL, see LICENSE for more details. :license: GNU GPL, see LICENSE for more details.
""" """
from django.contrib.auth.models import Permission
from django.test.client import Client from django.test.client import Client
from openslides.agenda.models import Item, Speaker from openslides.agenda.models import Item, Speaker
@ -133,9 +134,10 @@ class TestSpeakerAppendView(SpeakerViewTestCase):
self.assertEqual(Speaker.objects.filter(item=self.item1).count(), 0) self.assertEqual(Speaker.objects.filter(item=self.item1).count(), 0)
# Set speaker1 to item1 # Set speaker1 to item1
self.check_url('/agenda/1/speaker/', self.speaker1_client, 302) response = self.check_url('/agenda/1/speaker/', self.speaker1_client, 302)
self.assertTrue(Speaker.objects.filter(person=self.speaker1, item=self.item1).exists()) self.assertTrue(Speaker.objects.filter(person=self.speaker1, item=self.item1).exists())
self.assertEqual(Speaker.objects.filter(item=self.item1).count(), 1) self.assertEqual(Speaker.objects.filter(item=self.item1).count(), 1)
self.assertMessage(response, 'You were successfully added to the list of speakers.')
# Try to set speaker 1 to item 1 again # Try to set speaker 1 to item 1 again
response = self.check_url('/agenda/1/speaker/', self.speaker1_client, 302) response = self.check_url('/agenda/1/speaker/', self.speaker1_client, 302)
@ -251,6 +253,12 @@ class GlobalListOfSpeakersLinks(SpeakerViewTestCase):
response = self.speaker1_client.get('/agenda/list_of_speakers/add/') response = self.speaker1_client.get('/agenda/list_of_speakers/add/')
self.assertRedirects(response, '/agenda/1/') self.assertRedirects(response, '/agenda/1/')
self.assertEqual(Speaker.objects.get(item__pk='1').person, self.speaker1) self.assertEqual(Speaker.objects.get(item__pk='1').person, self.speaker1)
self.assertMessage(response, 'You were successfully added to the list of speakers.')
perm = Permission.objects.filter(name='Can see agenda').get()
self.speaker2.groups.get(name='Registered').permissions.remove(perm)
response = self.speaker2_client.get('/agenda/list_of_speakers/add/')
self.assertMessage(response, 'You were successfully added to the list of speakers.')
def test_global_next_speaker_url(self): def test_global_next_speaker_url(self):
response = self.admin_client.get('/agenda/list_of_speakers/next/') response = self.admin_client.get('/agenda/list_of_speakers/next/')