Verified Commit 1ff181d6 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Handle update of present/payment fields separately

parent 2727b297
......@@ -187,8 +187,14 @@ class RegistrationViewSet(GenericViewSet, RetrieveModelMixin,
return super().get_serializer(*args, **kwargs)
def perform_update(self, serializer):
super().perform_update(serializer)
registration = serializer.instance
if services.is_organiser(self.request.member, registration.event):
services.update_registration_by_organiser(
registration,
self.request.member,
serializer.validated_data)
services.update_registration(registration.member,
registration.event,
serializer.field_values())
......
......@@ -233,3 +233,17 @@ def registration_fields(request, member, event):
else:
raise RegistrationError(
_("You are not allowed to update this registration."))
def update_registration_by_organiser(registration, member, data):
if not is_organiser(member, registration.event):
raise RegistrationError(
_("You are not allowed to update this registration."))
if 'payment' in data:
registration.payment = data['payment']
if 'present' in data:
registration.present = data['present']
registration.save()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment