Commit a8e7167f authored by Luko van der Maas's avatar Luko van der Maas

Merge branch 'fix/pizza-api' into 'master'

Fix pizza api serializers and viewsets

See merge request !1278
parents b33e9c0f ca6bba41
......@@ -37,7 +37,8 @@ class OrderSerializer(serializers.ModelSerializer):
read_only_fields = ('pk', 'payment', 'name', 'member')
payment = PaymentTypeField(source='payment.type',
choices=Payment.PAYMENT_TYPE)
choices=Payment.PAYMENT_TYPE,
read_only=True)
class AdminOrderSerializer(serializers.ModelSerializer):
......@@ -64,5 +65,6 @@ class AdminOrderSerializer(serializers.ModelSerializer):
).get('type', instance.payment.type) != instance.payment.type:
instance.payment.type = validated_data['payment']['type']
instance.payment.save()
del validated_data['payment']
if 'payment' in validated_data:
del validated_data['payment']
return super().update(instance, validated_data)
......@@ -8,6 +8,7 @@ from rest_framework.mixins import ListModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet, ModelViewSet
from payments.models import Payment
from pizzas.api import serializers
from pizzas.models import Product, PizzaEvent, Order
from pizzas.services import can_change_order
......@@ -54,7 +55,7 @@ class OrderViewset(ModelViewSet):
return Order.objects.none()
return Order.objects.filter(member=self.request.member,
paid=False,
payment__type=Payment.NONE,
pizza_event=event)
return Order.objects.filter(member=self.request.member,
pizza_event=event)
......
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