Merge pull request #5076 from FinnStutzenstein/readdLastSpeakerFix
Fixed readding last speaker
This commit is contained in:
commit
0df87fd522
@ -535,12 +535,12 @@ class ListOfSpeakersViewSet(
|
|||||||
list_of_speakers = self.get_object()
|
list_of_speakers = self.get_object()
|
||||||
|
|
||||||
# Retrieve speaker which spoke last and next speaker
|
# Retrieve speaker which spoke last and next speaker
|
||||||
ordered_speakers = list_of_speakers.speakers.order_by("-end_time")
|
last_speaker = (
|
||||||
if len(ordered_speakers) == 0:
|
list_of_speakers.speakers.exclude(end_time=None)
|
||||||
raise ValidationError({"detail": "There is no last speaker at the moment."})
|
.order_by("-end_time")
|
||||||
|
.first()
|
||||||
last_speaker = ordered_speakers[0]
|
)
|
||||||
if last_speaker.end_time is None:
|
if not last_speaker:
|
||||||
raise ValidationError({"detail": "There is no last speaker at the moment."})
|
raise ValidationError({"detail": "There is no last speaker at the moment."})
|
||||||
|
|
||||||
next_speaker = list_of_speakers.get_next_speaker()
|
next_speaker = list_of_speakers.get_next_speaker()
|
||||||
|
@ -497,7 +497,7 @@ class ManageSpeaker(TestCase):
|
|||||||
username="test_user_KLGHjkHJKBhjJHGGJKJn",
|
username="test_user_KLGHjkHJKBhjJHGGJKJn",
|
||||||
password="test_password_JHt678VbhjuGhj76hjGA",
|
password="test_password_JHt678VbhjuGhj76hjGA",
|
||||||
)
|
)
|
||||||
Speaker.objects.add(user2, self.list_of_speakers)
|
speaker2 = Speaker.objects.add(user2, self.list_of_speakers)
|
||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
reverse(
|
reverse(
|
||||||
@ -511,6 +511,7 @@ class ManageSpeaker(TestCase):
|
|||||||
and speaker.end_time is None
|
and speaker.end_time is None
|
||||||
and speaker.weight is not None
|
and speaker.weight is not None
|
||||||
)
|
)
|
||||||
|
self.assertTrue(speaker.weight < speaker2.weight)
|
||||||
|
|
||||||
def test_readd_last_speaker_no_admin(self):
|
def test_readd_last_speaker_no_admin(self):
|
||||||
self.util_add_user_as_last_speaker()
|
self.util_add_user_as_last_speaker()
|
||||||
|
Loading…
Reference in New Issue
Block a user