Skip to content

Commit

Permalink
Event registration payment orders (#876)
Browse files Browse the repository at this point in the history
* added list of payment orders for registrations

* update CHANGELOG.md
  • Loading branch information
MadsNyl authored Sep 24, 2024
1 parent 1166728 commit 0771f2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions app/content/serializers/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -36,6 +38,7 @@ class Meta:
"has_paid_order",
"wait_queue_number",
"created_by_admin",
"payment_orders",
)

def get_survey_submission(self, obj):
Expand All @@ -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"]

Expand Down
6 changes: 6 additions & 0 deletions app/payment/serializers/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ def create(self, validated_data):
)

return order


class OrderEventRegistrationSerializer(BaseModelSerializer):
class Meta:
model = Order
fields = ("order_id", "status", "created_at")

0 comments on commit 0771f2d

Please sign in to comment.