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
@@ -1,3 +1,5 @@
1
+ from urllib.parse import unquote
2
+
1
3
  from django.contrib.contenttypes.models import ContentType
2
4
  from django.contrib.postgres.search import SearchVector
3
5
  from django.db.models import Prefetch, Q
@@ -17,6 +19,7 @@ from ob_dj_store.core.stores.models import (
17
19
  Product,
18
20
  ProductVariant,
19
21
  Store,
22
+ Tip,
20
23
  )
21
24
  from ob_dj_store.core.stores.models._inventory import Inventory
22
25
  from ob_dj_store.core.stores.models._wallet import Wallet
@@ -49,11 +52,7 @@ class StoreFilter(filters.FilterSet):
49
52
  return queryset.filter(address__country=value)
50
53
 
51
54
  def by_shipping_methods_names(self, queryset, name, value):
52
- return queryset.filter(
53
- shipping_methods__name__in=[
54
- value,
55
- ]
56
- )
55
+ return queryset.filter(shipping_methods__name__in=[value,])
57
56
 
58
57
  def by_open_stores(self, queryset, name, value):
59
58
  if value:
@@ -91,6 +90,7 @@ class ProductFilter(filters.FilterSet):
91
90
  """Product filters"""
92
91
 
93
92
  category = filters.CharFilter(method="by_category")
93
+ q = filters.CharFilter(method="filter_search")
94
94
 
95
95
  class Meta:
96
96
  model = Product
@@ -103,6 +103,18 @@ class ProductFilter(filters.FilterSet):
103
103
  def by_category(self, queryset, name, value):
104
104
  return queryset.filter(category__name__iexact=value)
105
105
 
106
+ def filter_search(self, queryset, name, value):
107
+ language = self.request.META.get("HTTP_LANGUAGE", "").strip().upper()
108
+ if language == "AR":
109
+ value_ar = unquote(value)
110
+ query = Q(name_arabic__icontains=value_ar) | Q(
111
+ description_arabic__icontains=value_ar
112
+ )
113
+ else:
114
+ query = Q(name__icontains=value) | Q(description__icontains=value)
115
+ qs = queryset.filter(query).distinct()[:5]
116
+ return qs
117
+
106
118
 
107
119
  class VariantFilter(filters.FilterSet):
108
120
  """Variant filters"""
@@ -186,9 +198,7 @@ class CategoryFilter(filters.FilterSet):
186
198
 
187
199
  def by_type(self, queryset, name, value):
188
200
  return (
189
- queryset.filter(
190
- subcategories__products__type=value,
191
- )
201
+ queryset.filter(subcategories__products__type=value,)
192
202
  .prefetch_related(
193
203
  Prefetch(
194
204
  "subcategories",
@@ -198,9 +208,7 @@ class CategoryFilter(filters.FilterSet):
198
208
  ),
199
209
  Prefetch(
200
210
  "subcategories__products",
201
- queryset=Product.objects.filter(
202
- is_active=True,
203
- ).distinct(),
211
+ queryset=Product.objects.filter(is_active=True,).distinct(),
204
212
  ),
205
213
  )
206
214
  .distinct()
@@ -241,15 +249,13 @@ class FavoriteFilter(filters.FilterSet):
241
249
  product_variants__inventories__store__pk=value
242
250
  ).values_list("id", flat=True)
243
251
  content_type = ContentType.objects.get_for_model(Product)
244
- return queryset.filter(
245
- content_type=content_type,
246
- object_id__in=products_ids,
247
- )
252
+ return queryset.filter(content_type=content_type, object_id__in=products_ids,)
248
253
 
249
254
 
250
255
  class PaymentMethodFilter(filters.FilterSet):
251
256
  store = filters.CharFilter(method="by_store")
252
257
  is_digital = filters.BooleanFilter(method="by_digital")
258
+ country = filters.CharFilter(method="by_country")
253
259
 
254
260
  class Meta:
255
261
  models = PaymentMethod
@@ -264,13 +270,16 @@ class PaymentMethodFilter(filters.FilterSet):
264
270
  )
265
271
  return queryset
266
272
 
273
+ def by_country(self, queryset, name, value):
274
+ currency = get_currency_by_country(value)
275
+ if value:
276
+ queryset = queryset.filter(currency=currency)
277
+ return queryset
278
+
267
279
 
268
280
  class WalletFilter(filters.FilterSet):
269
281
  currency = filters.CharFilter(
270
- method="by_currency",
271
- validators=[
272
- validate_currency,
273
- ],
282
+ method="by_currency", validators=[validate_currency,],
274
283
  )
275
284
  country = filters.CharFilter(method="by_country")
276
285
 
@@ -314,3 +323,17 @@ class CountryPaymentMethodFilter(filters.FilterSet):
314
323
  def by_country(self, queryset, name, value):
315
324
  if value:
316
325
  return queryset.filter(country=value)
326
+
327
+
328
+ class TipFilter(filters.FilterSet):
329
+
330
+ country = filters.CharFilter(method="by_country")
331
+
332
+ class Meta:
333
+ model = Tip
334
+ fields = []
335
+
336
+ def by_country(self, queryset, name, value):
337
+ if value:
338
+ queryset = queryset.filter(country=value)
339
+ return queryset