Commit bf6181c7 authored by Luko van der Maas's avatar Luko van der Maas Committed by Sébastiaan Versteeg
Browse files

fix for api assuming non external registration

parent eb8602ca
......@@ -181,7 +181,7 @@ class RegistrationViewSet(GenericViewSet, RetrieveModelMixin,
def get_object(self):
instance = super().get_object()
if (instance.member.pk != self.request.member.pk and
if ((instance.name or instance.member.pk != self.request.member.pk) and
not services.is_organiser(self.request.member,
instance.event)):
raise NotFound()
......
......@@ -254,12 +254,17 @@ def update_registration_by_organiser(registration, member, data):
registration.payment.save()
elif (data['payment']['type'] != Payment.NONE
and registration.payment is None):
note = f'Event registration {registration.event.title_en}. '
if registration.name:
note += f'Paid by {registration.name}. '
note += (f'{registration.event.start}. '
f'Registration date: {registration.date}.')
registration.payment = Payment.objects.create(
amount=registration.event.price,
paid_by=registration.member,
notes=(f'Event registration {registration.event.title_en}'
f'{registration.event.start}. '
f'Registration date: {registration.date}.'),
notes=note,
processed_by=member,
type=data['payment']['type']
)
......
......@@ -48,8 +48,12 @@ class PaymentAdmin(admin.ModelAdmin):
@staticmethod
def _member_link(member):
return format_html("<a href='{}'>{}</a>", member.get_absolute_url(),
member.get_full_name())
if member:
return format_html("<a href='{}'>{}</a>",
member.get_absolute_url(),
member.get_full_name())
else:
return "-"
def paid_by_link(self, obj):
return self._member_link(obj.paid_by)
......
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