Commit 15c35790 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Merge branch 'fix/external-payment' into 'master'

fix for api assuming non external registration

Closes #822

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