orders_local.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from rest_framework import serializers
  2. from openlocal.models import OrdersLocal
  3. class OrdersLocalSerializer(serializers.ModelSerializer):
  4. service = serializers.IntegerField(source="order_synced.service", allow_null=True)
  5. service_type = serializers.IntegerField(source="order_synced.service_type", allow_null=True)
  6. state = serializers.CharField(source="order_synced.state", allow_null=True)
  7. id_metaservice = serializers.IntegerField(source="order_synced.id_metaservice", allow_null=True)
  8. provider = serializers.CharField(source="order_synced.provider.pk", allow_null=True)
  9. provider_screen_name = serializers.CharField(source="order_synced.provider.user_id.full_name", allow_null=True)
  10. receiver = serializers.IntegerField(source="order_synced.receiver.pk", allow_null=True)
  11. receiver_screen_name = serializers.CharField(source="order_synced.receiver.full_name", allow_null=True)
  12. client_id = serializers.CharField(source="order_synced.client_id.pk", allow_null=True)
  13. client_screen_name = serializers.CharField(source="order_synced.client.user.full_name", allow_null=True)
  14. #time_created = serializers.DateTimeField(source="order_synced.time_created", allow_null=True)
  15. time_placed = serializers.DateTimeField(source="order_synced.time_placed", allow_null=True)
  16. time_start = serializers.DateTimeField(source="order_synced.time_start", allow_null=True)
  17. time_start_real = serializers.DateTimeField(source="order_synced.time_start_real", allow_null=True)
  18. time_start_predicted = serializers.DateTimeField(source="order_synced.time_start_predicted", allow_null=True)
  19. time_finish_predicted = serializers.DateTimeField(source="order_synced.time_finish_predicted", allow_null=True)
  20. time_finish_real = serializers.DateTimeField(source="order_synced.time_finish_real", allow_null=True)
  21. predicted_price = serializers.FloatField(source="order_synced.predicted_price", allow_null=True)
  22. real_price = serializers.FloatField(source="order_synced.real_price", allow_null=True)
  23. is_global = serializers.BooleanField(source="order_synced.is_global", allow_null=True)
  24. is_visible = serializers.BooleanField(source="order_synced.is_visible", allow_null=True)
  25. ticket = serializers.IntegerField(source="order_synced.ticket.pk", allow_null=True)
  26. status = serializers.IntegerField(source="order_synced.ticket.stauts", allow_null=True)
  27. priority = serializers.IntegerField(source="order_synced.ticket.priority", allow_null=True)
  28. title = serializers.CharField(source="order_synced.ticket.title", allow_null=True)
  29. note = serializers.CharField(source="order_synced.ticket.note", allow_null=True)
  30. due_date = serializers.DateField(source="order_synced.ticket.due_date", allow_null=True)
  31. status_changed_date = serializers.DateTimeField(source="order_synced.ticket.status_changed_date", allow_null=True)
  32. class Meta:
  33. model = OrdersLocal
  34. fields = '__all__'