浏览代码

update serializer

kateshev14 5 月之前
父节点
当前提交
e7a54d0897
共有 2 个文件被更改,包括 42 次插入31 次删除
  1. 3 3
      models/orders_local.py
  2. 39 28
      serializer/orders_local.py

+ 3 - 3
models/orders_local.py

@@ -6,7 +6,7 @@ class OrdersLocal(models.Model):
     """
     OrdersLocal - таблица с заказами
     """
-    order_synced = models.ForeignKey(Orders, on_delete=models.DO_NOTHING)
+    #order_synced = models.ForeignKey(Orders, on_delete=models.DO_NOTHING)
    # resource_id = models.ForeignKey(Resource, null=True, on_delete=models.DO_NOTHING)
    # rating_id = models.IntegerField(null=True)#Need create table with rating
    # payment_transaction_id = models.IntegerField(null=True)#Need create table with payment_transaction or it get from platform (i dont know)
@@ -16,8 +16,8 @@ class OrdersLocal(models.Model):
     comment = models.CharField(null=True, max_length=300, default="-")
     place_start = models.CharField(null=True, max_length=100)
     place_end = models.CharField(null=True, max_length=100)
-    guide_type = models.IntegerField(null=True)
-    movement_way = models.IntegerField(null=True)
+    guide_type = models.CharField(null=True, max_length=100)
+    movement_way = models.CharField(null=True, max_length=100)
     numb_of_people = models.IntegerField(null=True)
    # is_with_payment_document = models.BooleanField(default=False)
    # asap = models.BooleanField(default=False)

+ 39 - 28
serializer/orders_local.py

@@ -18,41 +18,52 @@ class OrderNotDefined(Exception):
 
 
 class OrdersLocalSerializer(serializers.ModelSerializer):
-    service = serializers.IntegerField(source="order_synced.service.pk", allow_null=True)    
-    service_type = serializers.IntegerField(source="order_synced.service_type.pk", allow_null=True) 
-    state = serializers.CharField(source="order_synced.state", allow_null=True) 
-    id_metaservice = serializers.IntegerField(source="order_synced.id_metaservice", allow_null=True) 
+    #service = serializers.IntegerField(source="order_synced.service.pk", allow_null=True)    
+    #service_type = serializers.IntegerField(source="order_synced.service_type.pk", allow_null=True) 
+    #state = serializers.CharField(source="order_synced.state", allow_null=True) 
+    #id_metaservice = serializers.IntegerField(source="order_synced.id_metaservice", allow_null=True) 
     
-    provider = serializers.IntegerField(source="order_synced.provider.pk", allow_null=True) 
-    provider_screen_name = serializers.CharField(source="order_synced.provider.user_id.full_name", allow_null=True) 
+    #provider = serializers.IntegerField(source="order_synced.provider.pk", allow_null=True) 
+    #provider_screen_name = serializers.CharField(source="order_synced.provider.user_id.full_name", allow_null=True) 
 
-    receiver = serializers.IntegerField(source="order_synced.receiver.pk", allow_null=True)
-    receiver_screen_name = serializers.CharField(source="order_synced.receiver.full_name", allow_null=True) 
+    #receiver = serializers.IntegerField(source="order_synced.receiver.pk", allow_null=True)
+    #receiver_screen_name = serializers.CharField(source="order_synced.receiver.full_name", allow_null=True) 
     
-    client_id = serializers.CharField(source="order_synced.client_id.pk", allow_null=True) 
-    client_screen_name = serializers.CharField(source="order_synced.client.user.full_name", allow_null=True) 
+    #client_id = serializers.CharField(source="order_synced.client_id.pk", allow_null=True) 
+    #client_screen_name = serializers.CharField(source="order_synced.client.user.full_name", allow_null=True) 
 
     #time_created = serializers.DateTimeField(source="order_synced.time_created", allow_null=True) 
-    time_placed = serializers.DateTimeField(source="order_synced.time_placed", allow_null=True) 
-    time_start = serializers.DateTimeField(source="order_synced.time_start", allow_null=True) 
-    time_start_real = serializers.DateTimeField(source="order_synced.time_start_real", allow_null=True)
-    time_start_predicted = serializers.DateTimeField(source="order_synced.time_start_predicted", allow_null=True)
-    time_finish_predicted = serializers.DateTimeField(source="order_synced.time_finish_predicted", allow_null=True) 
-    time_finish_real = serializers.DateTimeField(source="order_synced.time_finish_real", allow_null=True) 
+    #time_placed = serializers.DateTimeField(source="order_synced.time_placed", allow_null=True) 
+    #time_start = serializers.DateTimeField(source="order_synced.time_start", allow_null=True) 
+    #time_start_real = serializers.DateTimeField(source="order_synced.time_start_real", allow_null=True)
+    #time_start_predicted = serializers.DateTimeField(source="order_synced.time_start_predicted", allow_null=True)
+    #time_finish_predicted = serializers.DateTimeField(source="order_synced.time_finish_predicted", allow_null=True) 
+    #time_finish_real = serializers.DateTimeField(source="order_synced.time_finish_real", allow_null=True) 
     
-    predicted_price = serializers.FloatField(source="order_synced.predicted_price", allow_null=True) 
-    real_price = serializers.FloatField(source="order_synced.real_price", allow_null=True) 
-    is_global = serializers.BooleanField(source="order_synced.is_global", allow_null=True) 
-    is_visible = serializers.BooleanField(source="order_synced.is_visible", allow_null=True) 
-    ticket = serializers.IntegerField(source="order_synced.ticket.pk", allow_null=True) 
-    status = serializers.IntegerField(source="order_synced.ticket.stauts", allow_null=True)
-    priority = serializers.IntegerField(source="order_synced.ticket.priority", allow_null=True)
-    title = serializers.CharField(source="order_synced.ticket.title", allow_null=True)
-    note = serializers.CharField(source="order_synced.ticket.note", allow_null=True)
-    due_date = serializers.DateField(source="order_synced.ticket.due_date", allow_null=True)
-    status_changed_date = serializers.DateTimeField(source="order_synced.ticket.status_changed_date", allow_null=True)
+    #predicted_price = serializers.FloatField(source="order_synced.predicted_price", allow_null=True) 
+    #real_price = serializers.FloatField(source="order_synced.real_price", allow_null=True) 
+    #is_global = serializers.BooleanField(source="order_synced.is_global", allow_null=True) 
+    #is_visible = serializers.BooleanField(source="order_synced.is_visible", allow_null=True) 
+    #ticket = serializers.IntegerField(source="order_synced.ticket.pk", allow_null=True) 
+    #status = serializers.IntegerField(source="order_synced.ticket.stauts", allow_null=True)
+    #priority = serializers.IntegerField(source="order_synced.ticket.priority", allow_null=True)
+    #title = serializers.CharField(source="order_synced.ticket.title", allow_null=True)
+    #note = serializers.CharField(source="order_synced.ticket.note", allow_null=True)
+    #due_date = serializers.DateField(source="order_synced.ticket.due_date", allow_null=True)
+    #status_changed_date = serializers.DateTimeField(source="order_synced.ticket.status_changed_date", allow_null=True)
     # order_synced = OrdersSerializer(read_only=True)
-    
+    service_date = serializers.DateTimeField(null=True)
+    service_time = serializers.TimeField(null=True)
+    discription = serializers.CharField(null=True, max_length=300)
+    price = serializers.IntegerField(null=True)   
+    name_order = serializers.CharField(null=True, max_length=300)
+    comment = serializers.CharField(null=True, max_length=300, default="-")
+    place_start = serializers.CharField(null=True, max_length=100)
+    place_end = serializers.CharField(null=True, max_length=100)
+    guide_type = serializers.IntegerField(null=True)
+    movement_way = serializers.IntegerField(null=True)
+    numb_of_people = serializers.IntegerField(null=True)
+
     class Meta:
         model = OrdersLocal
         fields = "__all__"