Эх сурвалжийг харах

fix client_id filed in orders model

blezz-tech 1 сар өмнө
parent
commit
c12844efeb

+ 2 - 2
admin/favoritecontacts.py

@@ -7,11 +7,11 @@ from webservice_running.models import Favoritecontacts
 class FavoritecontactsAdmin(admin.ModelAdmin):
     list_display = (
         'id',
-        'client_id',
+        'client',
         'full_name',
         'phone_number',
     )
     list_filter = (
         'id',
-        'client_id'
+        'client'
     )

+ 2 - 2
admin/frequentaddress.py

@@ -6,12 +6,12 @@ from webservice_running.models import Frequentaddress
 @admin.register(Frequentaddress)
 class FrequentaddressAdmin(admin.ModelAdmin):
     list_display = (
-        'client_id',
+        'client',
         'address',
         'description',
         'id',
     )
     list_filter = (
-        'client_id',
+        'client',
         'id'
     )

+ 2 - 2
admin/preferreddrivers.py

@@ -7,11 +7,11 @@ from webservice_running.models import Preferreddrivers
 class PreferreddriversAdmin(admin.ModelAdmin):
     list_display = (
         'id',
-        'client_id',
+        'client',
         'provider_id',
     )
     list_filter = (
         'id',
-        'client_id',
+        'client',
         'provider_id'
     )

+ 10 - 10
apiviews/favoritecontacts.py

@@ -15,30 +15,30 @@ class FavoritecontactsMVS(viewsets.ModelViewSet):
     ]
 
     def list(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Favoritecontacts.objects.all()
-        if client_id is not None:
+        if client is not None:
             queryset = queryset \
-                .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-                .filter(client_id_int=client_id)
+                .annotate(client_int=Cast('client', output_field=CharField())) \
+                .filter(client_int=client)
         serializer = self.get_serializer(queryset, many=True)
         return Response(serializer.data)
 
     def delete(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Favoritecontacts.objects.all()
-        if not client_id:
+        if not client:
             return Response(
-                {'error': 'client_id parameter is required'},
+                {'error': 'client parameter is required'},
                 status=status.HTTP_400_BAD_REQUEST
             )
 
         queryset = queryset \
-            .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-            .filter(client_id_int=client_id)
+            .annotate(client_int=Cast('client', output_field=CharField())) \
+            .filter(client_int=client)
         queryset.delete()
 
         return Response(
-            {'message': f'Objects with client_id {client_id} were deleted'},
+            {'message': f'Objects with client {client} were deleted'},
             status=status.HTTP_204_NO_CONTENT
         )

+ 10 - 10
apiviews/frequentaddress.py

@@ -15,30 +15,30 @@ class FrequentaddressMVS(viewsets.ModelViewSet):
     ]
 
     def list(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Frequentaddress.objects.all()
-        if client_id is not None:
+        if client is not None:
             queryset = queryset \
-                .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-                .filter(client_id_int=client_id)
+                .annotate(client_int=Cast('client', output_field=CharField())) \
+                .filter(client_int=client)
         serializer = self.get_serializer(queryset, many=True)
         return Response(serializer.data)
 
     def delete(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Frequentaddress.objects.all()
-        if not client_id:
+        if not client:
             return Response(
-                {'error': 'client_id parameter is required'},
+                {'error': 'client parameter is required'},
                 status=status.HTTP_400_BAD_REQUEST
             )
 
         queryset = queryset \
-            .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-            .filter(client_id_int=client_id)
+            .annotate(client_int=Cast('client', output_field=CharField())) \
+            .filter(client_int=client)
         queryset.delete()
 
         return Response(
-            {'message': f'Objects with client_id {client_id} were deleted'},
+            {'message': f'Objects with client {client} were deleted'},
             status=status.HTTP_204_NO_CONTENT
         )

+ 10 - 10
apiviews/preferreddrivers.py

@@ -15,30 +15,30 @@ class PreferreddriversMVS(viewsets.ModelViewSet):
     ]
 
     def list(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Preferreddrivers.objects.all()
-        if client_id is not None:
+        if client is not None:
             queryset = queryset \
-                .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-                .filter(client_id_int=client_id)
+                .annotate(client_int=Cast('client', output_field=CharField())) \
+                .filter(client_int=client)
         serializer = self.get_serializer(queryset, many=True)
         return Response(serializer.data)
 
     def delete(self, request, *args, **kwargs):
-        client_id = self.request.query_params.get('client_id')
+        client = self.request.query_params.get('client')
         queryset = Preferreddrivers.objects.all()
-        if not client_id:
+        if not client:
             return Response(
-                {'error': 'client_id parameter is required'},
+                {'error': 'client parameter is required'},
                 status=status.HTTP_400_BAD_REQUEST
             )
 
         queryset = queryset \
-            .annotate(client_id_int=Cast('client_id', output_field=CharField())) \
-            .filter(client_id_int=client_id)
+            .annotate(client_int=Cast('client', output_field=CharField())) \
+            .filter(client_int=client)
         queryset.delete()
 
         return Response(
-            {'message': f'Objects with client_id {client_id} were deleted'},
+            {'message': f'Objects with client {client} were deleted'},
             status=status.HTTP_204_NO_CONTENT
         )

+ 7 - 7
handlers/classes/Order.py

@@ -35,7 +35,7 @@ class Order(object):
             provider_screen_name=None,
             receiver=None,
             receiver_screen_name=None,
-            client_id=None,
+            client=None,
             resource_id=None,
             attempts=None,
             asap=None,
@@ -78,7 +78,7 @@ class Order(object):
         self.provider_screen_name = provider_screen_name
         self.receiver = receiver
         self.receiver_screen_name = receiver_screen_name
-        self.client_id = client_id
+        self.client = client
         self.resource_id = resource_id
         self.attempts = attempts
         self.asap = asap
@@ -123,7 +123,7 @@ class Order(object):
             self.provider_screen_name,
             self.receiver,
             self.receiver_screen_name,
-            self.client_id,
+            self.client,
             self.resource_id,
             self.attempts,
             self.asap,
@@ -184,7 +184,7 @@ https://wiki.sharix-app.org/doku.php/open/tech/dev/sharix_open_-_primery_json
 "provider_screen_name": "Vasya Ispolnitelev",
 "receiver": 1,
 "receiver_screen_name": "Marfa Clientovna",
-"client_id": 1,
+"client": 1,
 "client_screen_name": "Fedor Client",
 "resource_id": 1,
 "attempts": null
@@ -192,7 +192,7 @@ https://wiki.sharix-app.org/doku.php/open/tech/dev/sharix_open_-_primery_json
 '''
 # надо адаптировать класс к новому формату JSON
 # class Order(object):
-#     def __init__(self, id,order_synced, ticket, status, title, note, due_date, id_metaservice, is_global, is_visible, service, service_type, status_changed_date,time_created, time_placed, time_start=None, time_start_predicted=None, time_finish_predicted=None, time_start_real=None, time_finish_real=None, order_place_type=None, order_place_start=None, order_place_start_gps=None, order_place_start_real=None, order_place_start_real_gps=None, order_place_finish_predicted=None, order_place_finish_predicted_gps=None, order_place_finish_real=None, order_place_finish_real_gps=None, predicted_price=None, real_price=None, payment_transaction_id=None, rating_id=None, provider=None, provider_screen_name=None, receiver=None, receiver_screen_name=None, client_id=None, resource_id=None, attempts=None, asap=None):
+#     def __init__(self, id,order_synced, ticket, status, title, note, due_date, id_metaservice, is_global, is_visible, service, service_type, status_changed_date,time_created, time_placed, time_start=None, time_start_predicted=None, time_finish_predicted=None, time_start_real=None, time_finish_real=None, order_place_type=None, order_place_start=None, order_place_start_gps=None, order_place_start_real=None, order_place_start_real_gps=None, order_place_finish_predicted=None, order_place_finish_predicted_gps=None, order_place_finish_real=None, order_place_finish_real_gps=None, predicted_price=None, real_price=None, payment_transaction_id=None, rating_id=None, provider=None, provider_screen_name=None, receiver=None, receiver_screen_name=None, client=None, resource_id=None, attempts=None, asap=None):
 #         self.order_synced = order_synced
 #         self.id = id
 #         self.ticket = ticket
@@ -237,12 +237,12 @@ https://wiki.sharix-app.org/doku.php/open/tech/dev/sharix_open_-_primery_json
 #         self.provider_screen_name = provider_screen_name
 #         self.receiver = receiver
 #         self.receiver_screen_name = receiver_screen_name
-#         self.client_id = client_id
+#         self.client = client
 #         self.resource_id = resource_id
 #         self.attempts = attempts
 #         self.asap = asap
 #         #доделать до конца по аналогии с закоммиченным json
 #     def __str__(self):
-#         return "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32} , {33} ,{34}".format(self.order_synced, self.id, self.ticket, self.status, self.title, self.note, self.due_date, self.id_metaservice, self.is_global, self.is_visible, self.service, self.service_type, self.status_changed_date, self.time_created,self.time_placed, self.time_start, self.time_start_predicted, self.time_finish_predicted, self.time_start_real, self.time_finish_real, self.order_place_type, self.order_place_start, self.order_place_start_gps, self.order_place_start_real, self.order_place_start_real_gps, self.order_place_finish_predicted, self.order_place_finish_predicted_gps, self.order_place_finish_real, self.order_place_finish_real_gps, self.predicted_price, self.real_price, self.payment_transaction_id, self.rating_id, self.provider, self.provider_screen_name, self.receiver, self.receiver_screen_name, self.client_id, self.resource_id, self.attempts, self.asap)
+#         return "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, {21}, {22}, {23}, {24}, {25}, {26}, {27}, {28}, {29}, {30}, {31}, {32} , {33} ,{34}".format(self.order_synced, self.id, self.ticket, self.status, self.title, self.note, self.due_date, self.id_metaservice, self.is_global, self.is_visible, self.service, self.service_type, self.status_changed_date, self.time_created,self.time_placed, self.time_start, self.time_start_predicted, self.time_finish_predicted, self.time_start_real, self.time_finish_real, self.order_place_type, self.order_place_start, self.order_place_start_gps, self.order_place_start_real, self.order_place_start_real_gps, self.order_place_finish_predicted, self.order_place_finish_predicted_gps, self.order_place_finish_real, self.order_place_finish_real_gps, self.predicted_price, self.real_price, self.payment_transaction_id, self.rating_id, self.provider, self.provider_screen_name, self.receiver, self.receiver_screen_name, self.client, self.resource_id, self.attempts, self.asap)
 
 # \n добавляете в местах с пустой строкой в шаблоне

+ 1 - 1
handlers/open_service_request_booked_v2.py

@@ -72,7 +72,7 @@ def open_service_request_booked_process(localtask):
 
     order = jsreq.jsonToOrder(localtask)
     # Пока заглушка
-    balance = get_balance(order.client_id)
+    balance = get_balance(order.client)
 
     price = order.real_price
 

+ 1 - 1
models/favoritecontacts.py

@@ -2,7 +2,7 @@ from django.db import models
 
 
 class Favoritecontacts(models.Model):
-    client_id = models.IntegerField(
+    client = models.IntegerField(
         help_text="id"
     )
     phone_number = models.CharField(

+ 1 - 1
models/frequentaddress.py

@@ -2,7 +2,7 @@ from django.db import models
 
 
 class Frequentaddress(models.Model):
-    client_id = models.IntegerField(
+    client = models.IntegerField(
         help_text="id клиента"
     )
     address = models.CharField(

+ 1 - 1
models/preferreddrivers.py

@@ -2,7 +2,7 @@ from django.db import models
 
 
 class Preferreddrivers(models.Model):
-    client_id = models.IntegerField(
+    client = models.IntegerField(
         help_text="Client id"
     )
     provider_id = models.IntegerField(

+ 1 - 1
serializer/frequentaddress.py

@@ -8,5 +8,5 @@ class FrequentaddressSerializer(serializers.ModelSerializer):
         model = Frequentaddress
         exclude = [
             "id",
-            "client_id"
+            "client"
         ]

+ 2 - 2
serializer/orders_local.py

@@ -52,8 +52,8 @@ class OrdersLocalSerializer(serializers.ModelSerializer):
         allow_null=True
     )
 
-    client_id = serializers.CharField(
-        source="order_synced.client_id.pk",
+    client = serializers.CharField(
+        source="order_synced.client.pk",
         allow_null=True
     )
     client_screen_name = serializers.CharField(

+ 1 - 1
serializer/preferreddrivers.py

@@ -8,6 +8,6 @@ class PreferreddriversSerializer(serializers.ModelSerializer):
         model = Preferreddrivers
         fields = [
             'provider_id',
-            'client_id',
+            'client',
             'id'
         ]