From 0771f2de074ede4f3c6d4c2601f6e9d66e3853f9 Mon Sep 17 00:00:00 2001 From: Mads Nylund <73914541+MadsNyl@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:02:35 +0200 Subject: [PATCH] Event registration payment orders (#876) * added list of payment orders for registrations * update CHANGELOG.md --- CHANGELOG.md | 2 ++ app/content/serializers/registration.py | 7 +++++++ app/payment/serializers/order.py | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ee78df7..34bf9554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ ## Neste versjon +- ⚡**Betalingsordre**. Man kan nå se historikk over betalingsordre for en påmelding til et arrangement. +- ✨**Gruppe**. HS kan nå opprette en ny gruppe. - ⚡**Swagger**. La til en GitHub Action for å verifisere at Swagger er oppe og går. - ✨**Swagger**. API dokumentasjon er nå tilgjengelig med Swagger. - ⚡**Profil**. Endret rekkefølge på tidligere arrangementer slik at nyeste kommer først. diff --git a/app/content/serializers/registration.py b/app/content/serializers/registration.py index 4c7ac599..339cc1dc 100644 --- a/app/content/serializers/registration.py +++ b/app/content/serializers/registration.py @@ -10,6 +10,7 @@ from app.forms.enums import NativeEventFormType as EventFormType from app.forms.serializers.submission import SubmissionInRegistrationSerializer from app.payment.enums import OrderStatus +from app.payment.serializers.order import OrderEventRegistrationSerializer from app.payment.util.order_utils import has_paid_order from app.payment.util.payment_utils import get_payment_order_status @@ -20,6 +21,7 @@ class RegistrationSerializer(BaseModelSerializer): has_unanswered_evaluation = serializers.SerializerMethodField() has_paid_order = serializers.SerializerMethodField(required=False) wait_queue_number = serializers.SerializerMethodField(required=False) + payment_orders = serializers.SerializerMethodField(required=False) class Meta: model = Registration @@ -36,6 +38,7 @@ class Meta: "has_paid_order", "wait_queue_number", "created_by_admin", + "payment_orders", ) def get_survey_submission(self, obj): @@ -55,6 +58,10 @@ def get_has_paid_order(self, obj): return has_paid_order(orders) + def get_payment_orders(self, obj): + orders = obj.event.orders.filter(user=obj.user) + return OrderEventRegistrationSerializer(orders, many=True, read_only=True).data + def create(self, validated_data): event = validated_data["event"] diff --git a/app/payment/serializers/order.py b/app/payment/serializers/order.py index 3541023e..c8f171d9 100644 --- a/app/payment/serializers/order.py +++ b/app/payment/serializers/order.py @@ -68,3 +68,9 @@ def create(self, validated_data): ) return order + + +class OrderEventRegistrationSerializer(BaseModelSerializer): + class Meta: + model = Order + fields = ("order_id", "status", "created_at")