Skip to content

Commit

Permalink
altered orderlistserializer
Browse files Browse the repository at this point in the history
  • Loading branch information
MadsNyl committed Sep 19, 2023
1 parent a48c1ca commit a1bea0d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 4 additions & 2 deletions app/content/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ def get_user_events(self, request, *args, **kwargs):
return self.paginate_response(
data=events, serializer=EventListSerializer, context={"request": request}
)

@action(detail=False, methods=["get"], url_path="me/payment_orders")
def get_user_payment_orders(self, request, *args, **kwargs):
payment_orders = request.user.orders.all()
return self.paginate_response(
data=payment_orders, serializer=OrderListSerializer, context={"request": request}
data=payment_orders,
serializer=OrderListSerializer,
context={"request": request},
)

@action(detail=False, methods=["get"], url_path="me/forms")
Expand Down
12 changes: 3 additions & 9 deletions app/payment/serializers/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ def create(self, validated_data):


class OrderEventListSerializer(BaseModelSerializer):

class Meta:
model = Event
fields = (
"title",
)
fields = ("title",)


class OrderListSerializer(BaseModelSerializer):
event = OrderEventListSerializer(read_only=True)

class Meta:
model = Order
fields = (
"status",
"user",
"event"
)
fields = ("order_id", "status", "payment_link", "user", "event")
2 changes: 1 addition & 1 deletion app/payment/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from app.payment.views.order import Order, OrderListSerializer
from app.payment.views.order import Order, OrderListSerializer

0 comments on commit a1bea0d

Please sign in to comment.