ob-dj-store 0.0.19__py3-none-any.whl → 0.0.23.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. ob_dj_store/apis/stores/filters.py +42 -19
  2. ob_dj_store/apis/stores/rest/serializers/serializers.py +256 -63
  3. ob_dj_store/apis/stores/urls.py +6 -0
  4. ob_dj_store/apis/stores/views.py +140 -227
  5. ob_dj_store/apis/stripe/__init__.py +0 -0
  6. ob_dj_store/apis/stripe/serializers.py +185 -0
  7. ob_dj_store/apis/stripe/urls.py +25 -0
  8. ob_dj_store/apis/stripe/views.py +191 -0
  9. ob_dj_store/apis/tap/views.py +2 -6
  10. ob_dj_store/core/stores/admin.py +41 -38
  11. ob_dj_store/core/stores/admin_inlines.py +8 -13
  12. ob_dj_store/core/stores/gateway/stripe/__init__.py +2 -0
  13. ob_dj_store/core/stores/gateway/stripe/admin.py +77 -0
  14. ob_dj_store/core/stores/gateway/stripe/apps.py +9 -0
  15. ob_dj_store/core/stores/gateway/stripe/managers.py +35 -0
  16. ob_dj_store/core/stores/gateway/stripe/migrations/0001_initial.py +168 -0
  17. ob_dj_store/core/stores/gateway/stripe/migrations/__init__.py +1 -0
  18. ob_dj_store/core/stores/gateway/stripe/models.py +174 -0
  19. ob_dj_store/core/stores/gateway/stripe/utils.py +170 -0
  20. ob_dj_store/core/stores/gateway/tap/admin.py +1 -3
  21. ob_dj_store/core/stores/gateway/tap/managers.py +1 -6
  22. ob_dj_store/core/stores/gateway/tap/migrations/0001_initial.py +1 -3
  23. ob_dj_store/core/stores/gateway/tap/migrations/0008_alter_tappayment_user.py +25 -0
  24. ob_dj_store/core/stores/gateway/tap/models.py +4 -13
  25. ob_dj_store/core/stores/gateway/tap/utils.py +2 -7
  26. ob_dj_store/core/stores/managers.py +12 -4
  27. ob_dj_store/core/stores/migrations/0001_initial.py +1 -4
  28. ob_dj_store/core/stores/migrations/0005_auto_20220425_2119.py +2 -5
  29. ob_dj_store/core/stores/migrations/0005_auto_20220427_1729.py +1 -2
  30. ob_dj_store/core/stores/migrations/0006_auto_20220428_0100.py +2 -8
  31. ob_dj_store/core/stores/migrations/0007_cart_cartitem_order_orderitem.py +2 -8
  32. ob_dj_store/core/stores/migrations/0010_auto_20220509_1633.py +1 -4
  33. ob_dj_store/core/stores/migrations/0012_auto_20220514_0633.py +1 -4
  34. ob_dj_store/core/stores/migrations/0013_auto_20220518_1539.py +1 -4
  35. ob_dj_store/core/stores/migrations/0014_auto_20220519_0018.py +3 -12
  36. ob_dj_store/core/stores/migrations/0017_auto_20220524_0912.py +3 -10
  37. ob_dj_store/core/stores/migrations/0018_auto_20220524_1613.py +1 -3
  38. ob_dj_store/core/stores/migrations/0021_auto_20220531_1849.py +1 -4
  39. ob_dj_store/core/stores/migrations/0026_auto_20220630_1913.py +8 -32
  40. ob_dj_store/core/stores/migrations/0031_auto_20220811_1733.py +1 -4
  41. ob_dj_store/core/stores/migrations/0033_auto_20220815_0133.py +2 -8
  42. ob_dj_store/core/stores/migrations/0039_auto_20220831_1521.py +1 -4
  43. ob_dj_store/core/stores/migrations/0044_remove_productvariant_has_inventory.py +1 -4
  44. ob_dj_store/core/stores/migrations/0049_auto_20221029_1524.py +2 -8
  45. ob_dj_store/core/stores/migrations/0050_favoriteextra.py +1 -3
  46. ob_dj_store/core/stores/migrations/0052_auto_20221129_1732.py +2 -8
  47. ob_dj_store/core/stores/migrations/0059_auto_20230217_2006.py +2 -8
  48. ob_dj_store/core/stores/migrations/0062_auto_20230226_2005.py +2 -6
  49. ob_dj_store/core/stores/migrations/0064_auto_20230228_1814.py +1 -2
  50. ob_dj_store/core/stores/migrations/0066_auto_20230304_1532.py +2 -8
  51. ob_dj_store/core/stores/migrations/0070_auto_20230323_1628.py +1 -4
  52. ob_dj_store/core/stores/migrations/0071_auto_20230328_1825.py +2 -5
  53. ob_dj_store/core/stores/migrations/0082_auto_20230613_1424.py +1 -4
  54. ob_dj_store/core/stores/migrations/0084_payment_result.py +1 -3
  55. ob_dj_store/core/stores/migrations/0087_auto_20230828_2138.py +1 -4
  56. ob_dj_store/core/stores/migrations/0097_auto_20231108_1939.py +1 -4
  57. ob_dj_store/core/stores/migrations/0100_remove_shippingmethod_type_arabic.py +1 -4
  58. ob_dj_store/core/stores/migrations/0106_alter_paymentmethod_payment_provider.py +35 -0
  59. ob_dj_store/core/stores/migrations/0107_auto_20250425_2059.py +29 -0
  60. ob_dj_store/core/stores/migrations/0108_alter_paymentmethod_payment_provider.py +35 -0
  61. ob_dj_store/core/stores/migrations/0109_wallettransaction_cashback_type.py +27 -0
  62. ob_dj_store/core/stores/migrations/0110_auto_20250923_1714.py +26 -0
  63. ob_dj_store/core/stores/migrations/0111_auto_20251023_1700.py +35 -0
  64. ob_dj_store/core/stores/migrations/0112_auto_20251027_1739.py +98 -0
  65. ob_dj_store/core/stores/migrations/0113_order_tax_value.py +20 -0
  66. ob_dj_store/core/stores/migrations/0114_store_mask_customer_info.py +18 -0
  67. ob_dj_store/core/stores/models/__init__.py +9 -1
  68. ob_dj_store/core/stores/models/_address.py +1 -3
  69. ob_dj_store/core/stores/models/_cart.py +11 -5
  70. ob_dj_store/core/stores/models/_feedback.py +1 -3
  71. ob_dj_store/core/stores/models/_inventory.py +3 -2
  72. ob_dj_store/core/stores/models/_order.py +69 -20
  73. ob_dj_store/core/stores/models/_payment.py +28 -24
  74. ob_dj_store/core/stores/models/_product.py +31 -17
  75. ob_dj_store/core/stores/models/_store.py +9 -13
  76. ob_dj_store/core/stores/models/_wallet.py +34 -26
  77. ob_dj_store/core/stores/receivers.py +43 -27
  78. ob_dj_store/core/stores/utils.py +1 -2
  79. {ob_dj_store-0.0.19.dist-info → ob_dj_store-0.0.23.2.dist-info}/METADATA +3 -2
  80. {ob_dj_store-0.0.19.dist-info → ob_dj_store-0.0.23.2.dist-info}/RECORD +82 -60
  81. {ob_dj_store-0.0.19.dist-info → ob_dj_store-0.0.23.2.dist-info}/WHEEL +1 -1
  82. {ob_dj_store-0.0.19.dist-info → ob_dj_store-0.0.23.2.dist-info}/top_level.txt +0 -0
@@ -32,6 +32,7 @@ from ob_dj_store.apis.stores.filters import (
32
32
  PaymentMethodFilter,
33
33
  ProductFilter,
34
34
  StoreFilter,
35
+ TipFilter,
35
36
  VariantFilter,
36
37
  WalletFilter,
37
38
  )
@@ -51,15 +52,18 @@ from ob_dj_store.apis.stores.rest.serializers.serializers import (
51
52
  PaymentMethodSerializer,
52
53
  PaymentSerializer,
53
54
  ProductListSerializer,
55
+ ProductSearchSerializer,
54
56
  ProductSerializer,
55
57
  ProductVariantSerializer,
56
58
  ReorderSerializer,
57
59
  ShippingMethodSerializer,
58
60
  StoreSerializer,
59
61
  TaxSerializer,
62
+ TipSerializer,
60
63
  WalletMediaSerializer,
61
64
  WalletSerializer,
62
65
  WalletTopUpSerializer,
66
+ WalletTransactionListSerializer,
63
67
  WalletTransactionSerializer,
64
68
  )
65
69
  from ob_dj_store.core.stores.gateway.tap.utils import TapException
@@ -83,6 +87,7 @@ from ob_dj_store.core.stores.models import (
83
87
  ShippingMethod,
84
88
  Store,
85
89
  Tax,
90
+ Tip,
86
91
  Wallet,
87
92
  WalletMedia,
88
93
  )
@@ -139,10 +144,7 @@ class StoreView(
139
144
  queryset = (
140
145
  queryset.filter(
141
146
  orders__customer=self.request.user,
142
- orders__status__in=[
143
- "PAID",
144
- "DELIVERED",
145
- ],
147
+ orders__status__in=["PAID", "DELIVERED",],
146
148
  )
147
149
  .annotate(latest_order_date=Max("orders__created_at"))
148
150
  .prefetch_related(
@@ -163,9 +165,7 @@ class StoreView(
163
165
  operation_description="""
164
166
  List Stores
165
167
  """,
166
- tags=[
167
- "Store",
168
- ],
168
+ tags=["Store",],
169
169
  )
170
170
  def list(self, request, *args, **kwargs):
171
171
  return super().list(request, *args, **kwargs)
@@ -175,9 +175,7 @@ class StoreView(
175
175
  operation_description="""
176
176
  List Stores
177
177
  """,
178
- tags=[
179
- "Store",
180
- ],
178
+ tags=["Store",],
181
179
  )
182
180
  def retrieve(self, request, *args, **kwargs):
183
181
  return super().retrieve(request, *args, **kwargs)
@@ -187,9 +185,7 @@ class StoreView(
187
185
  operation_description="""
188
186
  Retrieve user favorite stores
189
187
  """,
190
- tags=[
191
- "Store",
192
- ],
188
+ tags=["Store",],
193
189
  )
194
190
  @action(
195
191
  detail=False,
@@ -208,9 +204,7 @@ class StoreView(
208
204
  operation_description="""
209
205
  Stores that the user has recently ordered from
210
206
  """,
211
- tags=[
212
- "Store",
213
- ],
207
+ tags=["Store",],
214
208
  )
215
209
  @action(
216
210
  detail=False,
@@ -229,14 +223,10 @@ class StoreView(
229
223
  operation_description="""
230
224
  Retrieve count of store's products
231
225
  """,
232
- tags=[
233
- "Store",
234
- ],
226
+ tags=["Store",],
235
227
  )
236
228
  @action(
237
- detail=True,
238
- methods=["GET"],
239
- url_path="menu-count",
229
+ detail=True, methods=["GET"], url_path="menu-count",
240
230
  )
241
231
  def menu_count(self, request, *args, **kwargs):
242
232
  store = self.get_object()
@@ -268,14 +258,10 @@ class StoreView(
268
258
  operation_description="""
269
259
  Retrieve count of stores (Nearby,previous,favorites)
270
260
  """,
271
- tags=[
272
- "Store",
273
- ],
261
+ tags=["Store",],
274
262
  )
275
263
  @action(
276
- detail=False,
277
- methods=["GET"],
278
- url_path="count",
264
+ detail=False, methods=["GET"], url_path="count",
279
265
  )
280
266
  def count(self, request, *args, **kwargs):
281
267
  previous_count = (
@@ -283,10 +269,7 @@ class StoreView(
283
269
  .get_queryset()
284
270
  .filter(
285
271
  orders__customer=self.request.user,
286
- orders__status__in=[
287
- "PAID",
288
- "DELIVERED",
289
- ],
272
+ orders__status__in=["PAID", "DELIVERED",],
290
273
  )
291
274
  .distinct()
292
275
  .count()
@@ -330,9 +313,7 @@ class CartView(
330
313
  operation_description="""
331
314
  Retrieve the current customer's cart /store/cart/me
332
315
  """,
333
- tags=[
334
- "Cart",
335
- ],
316
+ tags=["Cart",],
336
317
  )
337
318
  def retrieve(self, request, *args, **kwargs):
338
319
  store_id = request.query_params.get("store", None)
@@ -350,9 +331,7 @@ class CartView(
350
331
  operation_description="""
351
332
  Updates the current customer's cart /store/cart/me
352
333
  """,
353
- tags=[
354
- "Cart",
355
- ],
334
+ tags=["Cart",],
356
335
  )
357
336
  def update(self, request, *args, **kwargs):
358
337
  return super().update(request, *args, **kwargs)
@@ -371,17 +350,13 @@ class CartView(
371
350
  required=not store_settings.DIFFERENT_STORE_ORDERING,
372
351
  ),
373
352
  ],
374
- tags=[
375
- "Cart",
376
- ],
353
+ tags=["Cart",],
377
354
  )
378
355
  @action(
379
356
  methods=["POST"],
380
357
  detail=False,
381
358
  url_path=r"validate",
382
- permission_classes=[
383
- permissions.IsAuthenticated,
384
- ],
359
+ permission_classes=[permissions.IsAuthenticated,],
385
360
  serializer_class=OrderSerializer,
386
361
  )
387
362
  def validate(self, request, *args, **kwargs):
@@ -413,9 +388,7 @@ class CartItemView(
413
388
  operation_description="""
414
389
  Retrieve the current cart's cart item
415
390
  """,
416
- tags=[
417
- "CartItem",
418
- ],
391
+ tags=["CartItem",],
419
392
  )
420
393
  def retrieve(self, request, *args, **kwargs):
421
394
  return super().retrieve(request, *args, **kwargs)
@@ -425,9 +398,7 @@ class CartItemView(
425
398
  operation_description="""
426
399
  Updates the current customer's cart item
427
400
  """,
428
- tags=[
429
- "CartItem",
430
- ],
401
+ tags=["CartItem",],
431
402
  )
432
403
  def update(self, request, *args, **kwargs):
433
404
  return super().update(request, *args, **kwargs)
@@ -437,9 +408,7 @@ class CartItemView(
437
408
  operation_description="""
438
409
  Deletes the current customer's cart item
439
410
  """,
440
- tags=[
441
- "CartItem",
442
- ],
411
+ tags=["CartItem",],
443
412
  )
444
413
  def delete(self, request, *args, **kwargs):
445
414
  return self.destroy(request, *args, **kwargs)
@@ -475,9 +444,7 @@ class OrderView(
475
444
  operation_description="""
476
445
  Retrieve an order by id
477
446
  """,
478
- tags=[
479
- "Order",
480
- ],
447
+ tags=["Order",],
481
448
  )
482
449
  def retrieve(self, request, *args, **kwargs):
483
450
  return super().retrieve(request, *args, **kwargs)
@@ -487,9 +454,7 @@ class OrderView(
487
454
  operation_description="""
488
455
  List Orders
489
456
  """,
490
- tags=[
491
- "Order",
492
- ],
457
+ tags=["Order",],
493
458
  )
494
459
  def list(self, request, *args, **kwargs):
495
460
  return super().list(request, *args, **kwargs)
@@ -499,9 +464,7 @@ class OrderView(
499
464
  operation_description="""
500
465
  Create a customer order
501
466
  """,
502
- tags=[
503
- "Order",
504
- ],
467
+ tags=["Order",],
505
468
  )
506
469
  def create(self, request, *args, **kwargs):
507
470
  context = self.get_serializer_context()
@@ -523,18 +486,14 @@ class OrderView(
523
486
  methods=["POST"],
524
487
  detail=True,
525
488
  url_path=r"feedback",
526
- permission_classes=[
527
- permissions.IsAuthenticated,
528
- ],
489
+ permission_classes=[permissions.IsAuthenticated,],
529
490
  )
530
491
  def feedback(
531
492
  self, request: Request, pk=None, *args: typing.Any, **kwargs: typing.Any
532
493
  ):
533
494
  """Action for users to submit a feedback on successful order;"""
534
495
  serializer = FeedbackSerializer(
535
- data=request.data,
536
- instance=self.get_object(),
537
- context={"request": request},
496
+ data=request.data, instance=self.get_object(), context={"request": request},
538
497
  )
539
498
  serializer.is_valid(raise_exception=True)
540
499
  try:
@@ -550,8 +509,7 @@ class OrderView(
550
509
 
551
510
 
552
511
  class ReorderViewSet(
553
- mixins.CreateModelMixin,
554
- viewsets.GenericViewSet,
512
+ mixins.CreateModelMixin, viewsets.GenericViewSet,
555
513
  ):
556
514
  serializer_class = ReorderSerializer
557
515
  permission_classes = [
@@ -571,26 +529,20 @@ class ReorderViewSet(
571
529
  operation_description="""
572
530
  re-order a customer order
573
531
  """,
574
- tags=[
575
- "Order",
576
- ],
532
+ tags=["Order",],
577
533
  )
578
534
  @action(
579
535
  methods=["POST"],
580
536
  detail=True,
581
537
  url_path=r"",
582
- permission_classes=[
583
- permissions.IsAuthenticated,
584
- ],
538
+ permission_classes=[permissions.IsAuthenticated,],
585
539
  )
586
540
  def reorder(self, request: Request, *args: typing.Any, **kwargs: typing.Any):
587
541
  context = self.get_serializer_context()
588
542
  serializer = self.get_serializer(data=request.data, context=context)
589
543
  serializer.is_valid(raise_exception=True)
590
544
  request.user.cart.fill(self.get_object())
591
- return Response(
592
- status=status.HTTP_200_OK,
593
- )
545
+ return Response(status=status.HTTP_200_OK,)
594
546
 
595
547
 
596
548
  class VariantView(mixins.ListModelMixin, viewsets.GenericViewSet):
@@ -606,9 +558,7 @@ class VariantView(mixins.ListModelMixin, viewsets.GenericViewSet):
606
558
  operation_description="""
607
559
  List Variants
608
560
  """,
609
- tags=[
610
- "Variant",
611
- ],
561
+ tags=["Variant",],
612
562
  )
613
563
  def list(self, request, *args, **kwargs):
614
564
  return super().list(request, *args, **kwargs)
@@ -630,6 +580,11 @@ class ProductView(
630
580
  filterset_class = ProductFilter
631
581
  queryset = Product.objects.active()
632
582
 
583
+ def get_serializer_class(self):
584
+ if self.request.query_params.get("q"):
585
+ return ProductSearchSerializer
586
+ return ProductSerializer
587
+
633
588
  def apply_prefetch(self, queryset):
634
589
 
635
590
  qs = queryset.prefetch_related(
@@ -663,13 +618,7 @@ class ProductView(
663
618
  return qs
664
619
 
665
620
  def get_queryset(self):
666
- queryset = (
667
- super()
668
- .get_queryset()
669
- .prefetch_related(
670
- "images",
671
- )
672
- )
621
+ queryset = super().get_queryset().prefetch_related("images",)
673
622
  if self.action == "favorites":
674
623
  favorite_product_ids = Favorite.objects.favorites_for_model(
675
624
  Product, self.request.user
@@ -690,9 +639,7 @@ class ProductView(
690
639
  operation_description="""
691
640
  Retrieve a Product by id
692
641
  """,
693
- tags=[
694
- "Product",
695
- ],
642
+ tags=["Product",],
696
643
  )
697
644
  def retrieve(self, request, *args, **kwargs):
698
645
  return super().retrieve(request, *args, **kwargs)
@@ -702,9 +649,7 @@ class ProductView(
702
649
  operation_description="""
703
650
  List Products
704
651
  """,
705
- tags=[
706
- "Product",
707
- ],
652
+ tags=["Product",],
708
653
  )
709
654
  def list(self, request, *args, **kwargs):
710
655
  return super().list(request, *args, **kwargs)
@@ -714,9 +659,7 @@ class ProductView(
714
659
  operation_description="""
715
660
  Retrieve user favorite products
716
661
  """,
717
- tags=[
718
- "Product",
719
- ],
662
+ tags=["Product",],
720
663
  )
721
664
  @action(
722
665
  detail=False,
@@ -735,14 +678,10 @@ class ProductView(
735
678
  operation_description="""
736
679
  Add or Remove Product from Favorites
737
680
  """,
738
- tags=[
739
- "Product",
740
- ],
681
+ tags=["Product",],
741
682
  )
742
683
  @action(
743
- detail=True,
744
- methods=["GET"],
745
- url_path="favorite",
684
+ detail=True, methods=["GET"], url_path="favorite",
746
685
  )
747
686
  def favorite(self, request, *args, **kwargs):
748
687
  instance = self.get_object()
@@ -758,14 +697,10 @@ class ProductView(
758
697
  operation_description="""
759
698
  List user's featured products
760
699
  """,
761
- tags=[
762
- "Product",
763
- ],
700
+ tags=["Product",],
764
701
  )
765
702
  @action(
766
- detail=False,
767
- methods=["GET"],
768
- url_path="featured",
703
+ detail=False, methods=["GET"], url_path="featured",
769
704
  )
770
705
  def featured(self, request, *args, **kwargs):
771
706
  instance = self.get_queryset().filter(is_featured=True)
@@ -795,8 +730,7 @@ class CategoryViewSet(
795
730
  Prefetch(
796
731
  "availability_hours",
797
732
  queryset=AvailabilityHours.objects.filter(
798
- weekday=localtime(now()).weekday() + 1,
799
- store=store_id,
733
+ weekday=localtime(now()).weekday() + 1, store=store_id,
800
734
  ),
801
735
  ),
802
736
  )
@@ -837,13 +771,9 @@ class CategoryViewSet(
837
771
  ).distinct(),
838
772
  ),
839
773
  Prefetch(
840
- "subcategories__products",
841
- queryset=product_queryset.distinct(),
842
- ),
843
- Prefetch(
844
- "products",
845
- queryset=product_queryset.distinct(),
774
+ "subcategories__products", queryset=product_queryset.distinct(),
846
775
  ),
776
+ Prefetch("products", queryset=product_queryset.distinct(),),
847
777
  "subcategories__products__images",
848
778
  ).get(pk=instance_pk)
849
779
  except Category.DoesNotExist:
@@ -853,10 +783,7 @@ class CategoryViewSet(
853
783
  @method_decorator(
854
784
  name="retrieve",
855
785
  decorator=swagger_auto_schema(
856
- operation_summary="Retrieve Category",
857
- tags=[
858
- "Category",
859
- ],
786
+ operation_summary="Retrieve Category", tags=["Category",],
860
787
  ),
861
788
  )
862
789
  def retrieve(self, request, *args, **kwargs):
@@ -865,10 +792,7 @@ class CategoryViewSet(
865
792
  @method_decorator(
866
793
  name="list",
867
794
  decorator=swagger_auto_schema(
868
- operation_summary="List Categories",
869
- tags=[
870
- "Category",
871
- ],
795
+ operation_summary="List Categories", tags=["Category",],
872
796
  ),
873
797
  )
874
798
  def list(self, request, *args, **kwargs):
@@ -888,10 +812,7 @@ class InventoryView(
888
812
  @method_decorator(
889
813
  name="list",
890
814
  decorator=swagger_auto_schema(
891
- operation_summary="List Inventories",
892
- tags=[
893
- "Inventory",
894
- ],
815
+ operation_summary="List Inventories", tags=["Inventory",],
895
816
  ),
896
817
  )
897
818
  def list(self, request, *args, **kwargs):
@@ -900,10 +821,7 @@ class InventoryView(
900
821
  @method_decorator(
901
822
  name="retrieve",
902
823
  decorator=swagger_auto_schema(
903
- operation_summary="Retrieve Inventory",
904
- tags=[
905
- "Inventory",
906
- ],
824
+ operation_summary="Retrieve Inventory", tags=["Inventory",],
907
825
  ),
908
826
  )
909
827
  def retrieve(self, request, *args, **kwargs):
@@ -911,8 +829,7 @@ class InventoryView(
911
829
 
912
830
 
913
831
  class TransactionsViewSet(
914
- mixins.ListModelMixin,
915
- viewsets.GenericViewSet,
832
+ mixins.ListModelMixin, viewsets.GenericViewSet,
916
833
  ):
917
834
  serializer_class = PaymentSerializer
918
835
  permission_classes = [
@@ -930,17 +847,14 @@ class TransactionsViewSet(
930
847
  operation_description="""
931
848
  List Users's Captured Transactions
932
849
  """,
933
- tags=[
934
- "payment",
935
- ],
850
+ tags=["payment",],
936
851
  )
937
852
  def list(self, request, *args, **kwargs):
938
853
  return super().list(request, *args, **kwargs)
939
854
 
940
855
 
941
856
  class PaymentMethodViewSet(
942
- mixins.ListModelMixin,
943
- viewsets.GenericViewSet,
857
+ mixins.ListModelMixin, viewsets.GenericViewSet,
944
858
  ):
945
859
  serializer_class = PaymentMethodSerializer
946
860
  permission_classes = [
@@ -955,17 +869,14 @@ class PaymentMethodViewSet(
955
869
  operation_description="""
956
870
  List Payment methods
957
871
  """,
958
- tags=[
959
- "Payment Method",
960
- ],
872
+ tags=["Payment Method",],
961
873
  )
962
874
  def list(self, request, *args, **kwargs):
963
875
  return super().list(request, *args, **kwargs)
964
876
 
965
877
 
966
878
  class ShippingMethodViewSet(
967
- mixins.ListModelMixin,
968
- viewsets.GenericViewSet,
879
+ mixins.ListModelMixin, viewsets.GenericViewSet,
969
880
  ):
970
881
  serializer_class = ShippingMethodSerializer
971
882
  permission_classes = [
@@ -990,17 +901,14 @@ class ShippingMethodViewSet(
990
901
  operation_description="""
991
902
  List Shipping methods
992
903
  """,
993
- tags=[
994
- "Store",
995
- ],
904
+ tags=["Store",],
996
905
  )
997
906
  def list(self, request, *args, **kwargs):
998
907
  return super().list(request, *args, **kwargs)
999
908
 
1000
909
 
1001
910
  class TaxViewSet(
1002
- mixins.ListModelMixin,
1003
- viewsets.GenericViewSet,
911
+ mixins.ListModelMixin, viewsets.GenericViewSet,
1004
912
  ):
1005
913
  serializer_class = TaxSerializer
1006
914
  permission_classes = [
@@ -1013,9 +921,7 @@ class TaxViewSet(
1013
921
  operation_description="""
1014
922
  List Taxes
1015
923
  """,
1016
- tags=[
1017
- "Tax",
1018
- ],
924
+ tags=["Tax",],
1019
925
  )
1020
926
  def list(self, request, *args, **kwargs):
1021
927
  return super().list(request, *args, **kwargs)
@@ -1069,9 +975,7 @@ class FavoriteViewSet(
1069
975
  required=True,
1070
976
  ),
1071
977
  ],
1072
- tags=[
1073
- "Favorite",
1074
- ],
978
+ tags=["Favorite",],
1075
979
  )
1076
980
  def list(self, request, *args, **kwargs):
1077
981
  return super().list(request, *args, **kwargs)
@@ -1081,9 +985,7 @@ class FavoriteViewSet(
1081
985
  operation_description="""
1082
986
  Retreive Item To Favorites
1083
987
  """,
1084
- tags=[
1085
- "Favorite",
1086
- ],
988
+ tags=["Favorite",],
1087
989
  )
1088
990
  def retrieve(self, request, *args, **kwargs):
1089
991
  return super().retrieve(request, *args, **kwargs)
@@ -1093,9 +995,7 @@ class FavoriteViewSet(
1093
995
  operation_description="""
1094
996
  Add Item To Favorites
1095
997
  """,
1096
- tags=[
1097
- "Favorite",
1098
- ],
998
+ tags=["Favorite",],
1099
999
  )
1100
1000
  def create(self, request, *args, **kwargs):
1101
1001
  return super().create(request, *args, **kwargs)
@@ -1105,9 +1005,7 @@ class FavoriteViewSet(
1105
1005
  operation_description="""
1106
1006
  Update Item From Favorites
1107
1007
  """,
1108
- tags=[
1109
- "Favorite",
1110
- ],
1008
+ tags=["Favorite",],
1111
1009
  )
1112
1010
  def update(self, request, *args, **kwargs):
1113
1011
  return super().update(request, *args, **kwargs)
@@ -1117,9 +1015,7 @@ class FavoriteViewSet(
1117
1015
  operation_description="""
1118
1016
  Remove Item From Favorites
1119
1017
  """,
1120
- tags=[
1121
- "Favorite",
1122
- ],
1018
+ tags=["Favorite",],
1123
1019
  )
1124
1020
  def destroy(self, request, *args, **kwargs):
1125
1021
  return super().destroy(request, *args, **kwargs)
@@ -1148,9 +1044,7 @@ class WalletViewSet(
1148
1044
  operation_description="""
1149
1045
  Get User Wallet
1150
1046
  """,
1151
- tags=[
1152
- "Wallet",
1153
- ],
1047
+ tags=["Wallet",],
1154
1048
  )
1155
1049
  def retrieve(
1156
1050
  self, request: Request, *args: typing.Any, **kwargs: typing.Any
@@ -1162,9 +1056,7 @@ class WalletViewSet(
1162
1056
  operation_description="""
1163
1057
  Update a wallet
1164
1058
  """,
1165
- tags=[
1166
- "Wallet",
1167
- ],
1059
+ tags=["Wallet",],
1168
1060
  )
1169
1061
  def partial_update(self, request: Request, *args: typing.Any, **kwargs: typing.Any):
1170
1062
  return super().partial_update(request, *args, **kwargs)
@@ -1174,9 +1066,7 @@ class WalletViewSet(
1174
1066
  operation_description="""
1175
1067
  List User Wallets
1176
1068
  """,
1177
- tags=[
1178
- "Wallet",
1179
- ],
1069
+ tags=["Wallet",],
1180
1070
  )
1181
1071
  def list(
1182
1072
  self, request: Request, *args: typing.Any, **kwargs: typing.Any
@@ -1188,9 +1078,7 @@ class WalletViewSet(
1188
1078
  operation_description="""
1189
1079
  top up a user wallet with tap payment
1190
1080
  """,
1191
- tags=[
1192
- "Wallet",
1193
- ],
1081
+ tags=["Wallet",],
1194
1082
  )
1195
1083
  @action(
1196
1084
  methods=["POST"],
@@ -1219,14 +1107,10 @@ class WalletViewSet(
1219
1107
  operation_description="""
1220
1108
  list user's wallet transactions(debit,credit)
1221
1109
  """,
1222
- tags=[
1223
- "Wallet",
1224
- ],
1110
+ tags=["Wallet",],
1225
1111
  )
1226
1112
  @action(
1227
- methods=[
1228
- "GET",
1229
- ],
1113
+ methods=["GET"],
1230
1114
  detail=True,
1231
1115
  url_path="transactions",
1232
1116
  serializer_class=WalletTransactionSerializer,
@@ -1248,14 +1132,10 @@ class WalletViewSet(
1248
1132
  operation_description="""
1249
1133
  list wallet selection images
1250
1134
  """,
1251
- tags=[
1252
- "Wallet",
1253
- ],
1135
+ tags=["Wallet",],
1254
1136
  )
1255
1137
  @action(
1256
- methods=[
1257
- "GET",
1258
- ],
1138
+ methods=["GET",],
1259
1139
  detail=False,
1260
1140
  url_path="images",
1261
1141
  serializer_class=WalletMediaSerializer,
@@ -1273,6 +1153,34 @@ class WalletViewSet(
1273
1153
  return Response(serializer.data)
1274
1154
 
1275
1155
 
1156
+ class WalletV2ViewSet(
1157
+ mixins.ListModelMixin, viewsets.GenericViewSet,
1158
+ ):
1159
+ def get_queryset(self):
1160
+ return Wallet.objects.filter(
1161
+ user=self.request.user, is_active=True
1162
+ ).select_related("media_image")
1163
+
1164
+ @swagger_auto_schema(
1165
+ operation_summary="List Wallet's transactions",
1166
+ operation_description="""
1167
+ list user's wallet transactions(debit,credit)
1168
+ """,
1169
+ tags=["Wallet",],
1170
+ )
1171
+ @action(
1172
+ methods=["GET"],
1173
+ detail=True,
1174
+ url_path="transactions",
1175
+ serializer_class=WalletTransactionListSerializer,
1176
+ )
1177
+ def transactions(self, request, *args, **kwargs):
1178
+ wallet = self.get_object()
1179
+ queryset = wallet.transactions.all().order_by("-created_at")
1180
+ serializer = WalletTransactionListSerializer(queryset, many=True)
1181
+ return Response({"results": serializer.data})
1182
+
1183
+
1276
1184
  class PartnerAuthInfoViewSet(
1277
1185
  mixins.CreateModelMixin,
1278
1186
  mixins.RetrieveModelMixin,
@@ -1294,14 +1202,10 @@ class PartnerAuthInfoViewSet(
1294
1202
  operation_description="""
1295
1203
  Send an OTP for PartnerAuthInfo
1296
1204
  """,
1297
- tags=[
1298
- "Partner",
1299
- ],
1205
+ tags=["Partner",],
1300
1206
  )
1301
1207
  @action(
1302
- methods=[
1303
- "POST",
1304
- ],
1208
+ methods=["POST",],
1305
1209
  detail=False,
1306
1210
  url_path="send-otp",
1307
1211
  serializer_class=PartnerOTPRequestSerializer,
@@ -1322,14 +1226,10 @@ class PartnerAuthInfoViewSet(
1322
1226
  operation_description="""
1323
1227
  verify Partner's Authentication for different auth methods
1324
1228
  """,
1325
- tags=[
1326
- "Partner",
1327
- ],
1229
+ tags=["Partner",],
1328
1230
  )
1329
1231
  @action(
1330
- methods=[
1331
- "POST",
1332
- ],
1232
+ methods=["POST",],
1333
1233
  detail=False,
1334
1234
  url_path="",
1335
1235
  serializer_class=PartnerAuthInfoSerializer,
@@ -1350,9 +1250,7 @@ class PartnerAuthInfoViewSet(
1350
1250
  operation_description="""
1351
1251
  Retrieve User partner Auth
1352
1252
  """,
1353
- tags=[
1354
- "Partner",
1355
- ],
1253
+ tags=["Partner",],
1356
1254
  )
1357
1255
  def retrieve(
1358
1256
  self, request: Request, *args: typing.Any, **kwargs: typing.Any
@@ -1364,20 +1262,16 @@ class PartnerAuthInfoViewSet(
1364
1262
  operation_description="""
1365
1263
  Delete User partner Auth
1366
1264
  """,
1367
- tags=[
1368
- "Partner",
1369
- ],
1265
+ tags=["Partner",],
1370
1266
  )
1371
1267
  def destroy(self, request, *args, **kwargs):
1372
1268
  return super().destroy(request, *args, **kwargs)
1373
1269
 
1374
1270
 
1375
1271
  class PartnerViewSet(
1376
- mixins.ListModelMixin,
1377
- mixins.RetrieveModelMixin,
1378
- viewsets.GenericViewSet,
1272
+ mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet,
1379
1273
  ):
1380
- queryset = Partner.objects.all()
1274
+ queryset = Partner.objects.all().order_by("name")
1381
1275
  permission_classes = [
1382
1276
  permissions.IsAuthenticated,
1383
1277
  ]
@@ -1389,9 +1283,7 @@ class PartnerViewSet(
1389
1283
  operation_description="""
1390
1284
  retireve a partner
1391
1285
  """,
1392
- tags=[
1393
- "Partner",
1394
- ],
1286
+ tags=["Partner",],
1395
1287
  )
1396
1288
  def retrieve(
1397
1289
  self, request: Request, *args: typing.Any, **kwargs: typing.Any
@@ -1403,9 +1295,7 @@ class PartnerViewSet(
1403
1295
  operation_description="""
1404
1296
  List partners
1405
1297
  """,
1406
- tags=[
1407
- "Partner",
1408
- ],
1298
+ tags=["Partner",],
1409
1299
  )
1410
1300
  def list(self, request, *args, **kwargs):
1411
1301
  return super().list(request, *args, **kwargs)
@@ -1426,9 +1316,7 @@ class CountryPaymentMethodsViewSet(
1426
1316
  operation_description="""
1427
1317
  List Country Payment Methods
1428
1318
  """,
1429
- tags=[
1430
- "Store",
1431
- ],
1319
+ tags=["Store",],
1432
1320
  )
1433
1321
  def list(self, request, *args, **kwargs):
1434
1322
  return super().list(request, *args, **kwargs)
@@ -1438,9 +1326,34 @@ class CountryPaymentMethodsViewSet(
1438
1326
  operation_description="""
1439
1327
  Retrieve Country Payment Method
1440
1328
  """,
1441
- tags=[
1442
- "Store",
1443
- ],
1329
+ tags=["Store",],
1444
1330
  )
1445
1331
  def retrieve(self, request, *args, **kwargs):
1446
1332
  return super().retrieve(request, *args, **kwargs)
1333
+
1334
+
1335
+ class TipsViewSet(
1336
+ mixins.ListModelMixin, viewsets.GenericViewSet,
1337
+ ):
1338
+ queryset = Tip.objects.active()
1339
+ serializer_class = TipSerializer
1340
+ filterset_class = TipFilter
1341
+ filter_backends = [DjangoFilterBackend]
1342
+ permission_classes = [
1343
+ permissions.IsAuthenticated,
1344
+ ]
1345
+
1346
+ def get_queryset(self):
1347
+ return self.filter_queryset(super().get_queryset())
1348
+
1349
+ @swagger_auto_schema(
1350
+ operation_summary="list al tips",
1351
+ operation_description="""
1352
+ list all tips
1353
+ """,
1354
+ tags=["Tip",],
1355
+ )
1356
+ def list(
1357
+ self, request: Request, *args: typing.Any, **kwargs: typing.Any
1358
+ ) -> Response:
1359
+ return super().list(request=request, *args, **kwargs)