diff --git a/app/content/models/event.py b/app/content/models/event.py index c23401fc..21871d1a 100644 --- a/app/content/models/event.py +++ b/app/content/models/event.py @@ -136,7 +136,7 @@ def get_has_attended(self): return self.get_participants().filter(has_attended=True) def get_participants(self): - return self.registrations.filter(is_on_wait=False) + return self.registrations.select_for_update().filter(is_on_wait=False) def get_waiting_list(self): """Number of users on the waiting list""" diff --git a/app/content/views/registration.py b/app/content/views/registration.py index 2b5d680a..520b9405 100644 --- a/app/content/views/registration.py +++ b/app/content/views/registration.py @@ -1,5 +1,6 @@ import uuid +from django.db import transaction from django.shortcuts import get_object_or_404 from django_filters.rest_framework import DjangoFilterBackend from rest_framework import filters, status @@ -48,6 +49,7 @@ def _is_own_registration(self): def _is_not_own_registration(self): return not self._is_own_registration() + @transaction.atomic def create(self, request, *args, **kwargs): """Register the current user for the given event."""