mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
chore: Delete numerous application modules, templates, static assets, documentation, and build files.
This commit is contained in:
31
orders/serializers.py
Normal file
31
orders/serializers.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Order
|
||||
|
||||
class OrderSerializer(serializers.ModelSerializer):
|
||||
status = serializers.SerializerMethodField()
|
||||
product_name = serializers.ReadOnlyField(source='id_product.name')
|
||||
comanda_name = serializers.ReadOnlyField(source='id_comanda.name')
|
||||
mesa_name = serializers.ReadOnlyField(source='id_comanda.mesa.name')
|
||||
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = [
|
||||
'id', 'id_product', 'product_name', 'id_comanda', 'comanda_name',
|
||||
'mesa_name', 'obs', 'queue', 'preparing', 'finished',
|
||||
'delivered', 'canceled', 'status'
|
||||
]
|
||||
extra_kwargs = {
|
||||
'queue': {'read_only': True},
|
||||
'status': {'read_only': True},
|
||||
}
|
||||
|
||||
def get_status(self, obj):
|
||||
if obj.delivered:
|
||||
return 'Entregue'
|
||||
if obj.finished:
|
||||
return 'Pronto'
|
||||
if obj.preparing:
|
||||
return 'Preparando'
|
||||
if obj.canceled:
|
||||
return 'Cancelado'
|
||||
return 'Em espera'
|
||||
Reference in New Issue
Block a user