ob-dj-store 0.0.21.2__py3-none-any.whl → 0.0.21.4__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.
@@ -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
@@ -103,8 +105,9 @@ class ProductFilter(filters.FilterSet):
103
105
  def filter_search(self, queryset, name, value):
104
106
  language = self.request.META.get("HTTP_LANGUAGE", "").strip().upper()
105
107
  if language == "AR":
106
- query = Q(name_arabic__icontains=value) | Q(
107
- description_arabic__icontains=value
108
+ value_ar = unquote(value)
109
+ query = Q(name_arabic__icontains=value_ar) | Q(
110
+ description_arabic__icontains=value_ar
108
111
  )
109
112
  else:
110
113
  query = Q(name__icontains=value) | Q(description__icontains=value)
@@ -967,22 +967,22 @@ class ProductSearchSerializer(
967
967
  )
968
968
 
969
969
  def get_store_id(self):
970
- return self.context["request"].query_params.get("store")
970
+ return self.context["view"].kwargs["store_pk"]
971
971
 
972
- def get_inventory_for_store(self, store_id):
973
- if hasattr(self, "get_inventory"):
974
- return self.get_inventory(store_id)
972
+ def get_inventory_for_store(self, product, store_id):
973
+ if store_id:
974
+ return product.get_inventory(store_id)
975
975
  return None
976
976
 
977
977
  def get_is_snoozed(self, obj):
978
978
  store_id = self.get_store_id()
979
- inventory = self.get_inventory_for_store(store_id)
979
+ inventory = self.get_inventory_for_store(obj, store_id)
980
980
  return obj.is_snoozed(store_id=store_id) if inventory else False
981
981
 
982
982
  def get_is_available(self, obj):
983
983
  store_id = self.get_store_id()
984
- inventory = self.get_inventory_for_store(store_id)
985
- return bool(inventory and inventory.quantity)
984
+ inventory = self.get_inventory_for_store(obj, store_id)
985
+ return bool(inventory and (inventory.quantity or inventory.is_uncountable))
986
986
 
987
987
 
988
988
  class ProductListSerializer(ArabicFieldsMixin, serializers.ModelSerializer):
@@ -250,13 +250,14 @@ class Product(DjangoModelCleanMixin, models.Model):
250
250
 
251
251
  def get_inventory(self, store_id):
252
252
  try:
253
- inventory = self.product_variants.inventories.get(store=store_id)
253
+ inventory = self.product_variants.first().inventories.get(store_id=store_id)
254
254
  except ObjectDoesNotExist:
255
255
  return None
256
+ return inventory
256
257
 
257
258
  def is_snoozed(self, store_id):
258
259
  try:
259
- inventory = self.product_variants.inventories.get(store=store_id)
260
+ inventory = self.product_variants.first().inventories.get(store=store_id)
260
261
  except ObjectDoesNotExist:
261
262
  return False
262
263
  return inventory.is_snoozed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ob-dj-store
3
- Version: 0.0.21.2
3
+ Version: 0.0.21.4
4
4
  Summary: OBytes django application for managing ecommerce stores.
5
5
  Home-page: https://www.obytes.com/
6
6
  Author: OBytes
@@ -1,9 +1,9 @@
1
1
  ob_dj_store/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  ob_dj_store/apis/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- ob_dj_store/apis/stores/filters.py,sha256=cJ7OnNLFT1N5lp3IXFUpGMgqm-jhS24g-Y8pZmEMe58,10260
3
+ ob_dj_store/apis/stores/filters.py,sha256=JeUtcicJ3cFnZc71aUMEwn2jaVj1oNQsZOCZfdxGDu8,10338
4
4
  ob_dj_store/apis/stores/urls.py,sha256=W9sNJ7ST9pGnfVCf7GmduDO-_zK9MGTI6ybV8n-lzSc,2111
5
5
  ob_dj_store/apis/stores/views.py,sha256=cwDFNY2rtTfjl_F9PpR5zOJy2DPmGidOjIlJ9fsgSYI,42744
6
- ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=GUsUTN4MTXq92Uriv6Ql9MzjZJsSbmFDC3lZhSmB7vE,68219
6
+ ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=R_FGdD98iLWsb0dsI-kdq9_60yPkwahT_kMpfNPUzmQ,68239
7
7
  ob_dj_store/apis/tap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  ob_dj_store/apis/tap/serializers.py,sha256=KPrBK4h2-fWvEVf6vOj2ww5-USV9WqpyYicIqoHIiXI,1065
9
9
  ob_dj_store/apis/tap/urls.py,sha256=bnOTv6an11kxpo_FdqlhsizlGPLVpNxBjCyKcf3_C9M,367
@@ -153,14 +153,14 @@ ob_dj_store/core/stores/models/_inventory.py,sha256=_rGlVL5HjOlHQVB8CI0776CPcE5r
153
153
  ob_dj_store/core/stores/models/_order.py,sha256=_08lqX5p4brCdUilqfbT--6Ao2TMsqnzXaWoV_7IYL8,9758
154
154
  ob_dj_store/core/stores/models/_partner.py,sha256=OuYvevUWn1sYHs9PcFf51EUUC1uqytQss8Bx91aMOH8,4732
155
155
  ob_dj_store/core/stores/models/_payment.py,sha256=FTV-NmvQjxwwR5C5X7qYWV-ZUIZfqMMEjkBNaS-drLs,6421
156
- ob_dj_store/core/stores/models/_product.py,sha256=iBSXZcZdtCXFINiOFqbnaZot9rWPkFdzySXwKJO5h6I,18239
156
+ ob_dj_store/core/stores/models/_product.py,sha256=cYMsCtcYoJJ-kdmDmHGm2AGBo2cn6qWuF9g7zQJ_p2g,18283
157
157
  ob_dj_store/core/stores/models/_store.py,sha256=0K-CNJWuXNqeyULL1J0M9hiNcVla0UNNjdCdN_nzNEE,9833
158
158
  ob_dj_store/core/stores/models/_wallet.py,sha256=YvT-rvED-jrYjePLJpvdLXXoBudR6TGPu5cNE0m2fWo,5643
159
159
  ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
160
160
  ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
161
161
  ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
162
162
  ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
163
- ob_dj_store-0.0.21.2.dist-info/METADATA,sha256=3N8bQGyJNEAIPzgZDu-MpfFdHHNPmEo3Uv4pTjgtK84,2850
164
- ob_dj_store-0.0.21.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
165
- ob_dj_store-0.0.21.2.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
166
- ob_dj_store-0.0.21.2.dist-info/RECORD,,
163
+ ob_dj_store-0.0.21.4.dist-info/METADATA,sha256=qhdG-tlBDz4MV9ybB8VQwDWe5t-2eKMTacinZNLizjo,2850
164
+ ob_dj_store-0.0.21.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
165
+ ob_dj_store-0.0.21.4.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
166
+ ob_dj_store-0.0.21.4.dist-info/RECORD,,