diff --git a/aleksis/apps/paweljong/schema/event_registration.py b/aleksis/apps/paweljong/schema/event_registration.py index 66ece1aa73c8ceacf41a8dd9ab2b6f46766be501..041ea7e092c50d588b6aade6dfe1d26764d0e0d6 100644 --- a/aleksis/apps/paweljong/schema/event_registration.py +++ b/aleksis/apps/paweljong/schema/event_registration.py @@ -55,6 +55,17 @@ class SendEventRegistrationMutation(graphene.Mutation): print(event_registration) + email = None + + if event_registration["email"] is not None: + _mail_address = MailAddress.objects.create( + local_part=event_registration["email"]["local_part"], + domain=event_registration["email"]["domain"], + ) + email = str(_mail_address) + elif event_registration["user"] is not None: + email = event_registration["user"]["email"] + # Create user if event_registration is not None: user = User.objects.create( @@ -69,7 +80,7 @@ class SendEventRegistrationMutation(graphene.Mutation): person, created = Person.objects.get_or_create( user=user, defaults={ - "email": event_registration["person"]["email"], + "email": email, "first_name": event_registration["person"]["first_name"], "last_name": event_registration["person"]["last_name"], }, @@ -134,7 +145,7 @@ class SendEventRegistrationMutation(graphene.Mutation): registration.cost = event.cost if event.max_cost is not None and event.max_cost > 0: - amount = event_registration["payment"].amount + amount = event_registration["payment"]["amount"] if amount < event.cost: voucher_amount = event.cost - amount