ob-dj-store 0.0.19.9__py3-none-any.whl → 0.0.20__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.
@@ -396,7 +396,7 @@ class OrderSerializer(serializers.ModelSerializer):
396
396
 
397
397
  def _validate_pickup_time(self, store, pickup_time):
398
398
  # validate that the pickup_time is always in the future
399
- print("pickup :", pickup_time)
399
+
400
400
  if pickup_time < localtime(now()):
401
401
  raise serializers.ValidationError(_("Pickup time must be in the future"))
402
402
  pickup_time_time = pickup_time.time()
@@ -440,6 +440,7 @@ class OrderSerializer(serializers.ModelSerializer):
440
440
  attrs["extra_infos"] = {}
441
441
  stores = Store.objects.filter(store_items__cart=user.cart).distinct()
442
442
  gift_details = attrs["extra_infos"].get("gift_details", None)
443
+ unavailable_items = []
443
444
  if gift_details:
444
445
  self._validate_digital_product(gift_details, attrs)
445
446
  currency = gift_details["currency"]
@@ -451,7 +452,14 @@ class OrderSerializer(serializers.ModelSerializer):
451
452
  if len(stores) > 1:
452
453
  raise ValidationError(_("You cannot order from different stores"))
453
454
  for item in user.cart.items.all():
454
- if not item.inventory:
455
+ if item.inventory:
456
+ if (
457
+ not item.inventory.is_uncountable
458
+ and not item.inventory.quantity
459
+ or item.inventory.quantity == 0
460
+ ):
461
+ unavailable_items.append(item)
462
+ elif not item.inventory:
455
463
  if language and item.product_variant.product.name_arabic:
456
464
  product_name = item.product_variant.product.name_arabic
457
465
  else:
@@ -461,8 +469,14 @@ class OrderSerializer(serializers.ModelSerializer):
461
469
  message = (
462
470
  f"{product_name} {variant_name} doesn't exist on this store"
463
471
  )
472
+ unavailable_items.append(item)
464
473
  raise ValidationError(_(message))
465
-
474
+ if unavailable_items:
475
+ raise ValidationError(
476
+ _(
477
+ "The cart has items that are not available in the selected store"
478
+ )
479
+ )
466
480
  if "shipping_method" in attrs:
467
481
  if (
468
482
  attrs["shipping_method"].type
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  from decimal import Decimal
2
3
 
3
4
  from django.contrib.auth import get_user_model
@@ -10,6 +11,8 @@ from ob_dj_store.core.stores.managers import CartItemManager, CartManager
10
11
  from ob_dj_store.core.stores.models._partner import PartnerAuthInfo
11
12
  from ob_dj_store.core.stores.utils import round_up_tie
12
13
 
14
+ logger = logging.getLogger(__name__)
15
+
13
16
 
14
17
  class Cart(models.Model):
15
18
  customer = models.OneToOneField(
@@ -48,8 +51,11 @@ class Cart(models.Model):
48
51
  def total_price(self) -> Decimal:
49
52
  total_price = Decimal(0)
50
53
  for item in self.items.all():
51
- if item.inventory.quantity and item.inventory.quantity > 0:
52
- total_price += item.total_price
54
+ try:
55
+ if item.inventory.quantity and item.inventory.quantity > 0:
56
+ total_price += item.total_price
57
+ except AttributeError:
58
+ logger.error(f"Item {item} has no inventory")
53
59
  return total_price
54
60
 
55
61
  @property
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ob-dj-store
3
- Version: 0.0.19.9
3
+ Version: 0.0.20
4
4
  Summary: OBytes django application for managing ecommerce stores.
5
5
  Home-page: https://www.obytes.com/
6
6
  Author: OBytes
@@ -3,7 +3,7 @@ ob_dj_store/apis/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
3
3
  ob_dj_store/apis/stores/filters.py,sha256=zKBXPBoqIyFlSeZOECp97RTWvSLqNPnlPhEp7p8W5tE,9702
4
4
  ob_dj_store/apis/stores/urls.py,sha256=7vwogfIGcKS0hHYK3iBXKQwi1kCA_vuHY1eZt8rAspg,2021
5
5
  ob_dj_store/apis/stores/views.py,sha256=aE4LFPHzs_CtzZ8K5-vAbDn_51hyhi0KIsi7cV8dpkA,43372
6
- ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=j511ztKSljd8ObdmLTndvp31YEBhJalu6exbOuTa7r4,64623
6
+ ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=IRpWBlEdbPCOX7FnVwxJhq4dXLOB8IcToLK7RM6HxI4,65258
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
@@ -141,7 +141,7 @@ ob_dj_store/core/stores/migrations/0105_store_is_open_after_midnight.py,sha256=8
141
141
  ob_dj_store/core/stores/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
142
  ob_dj_store/core/stores/models/__init__.py,sha256=VeWrDiIbw94ZDSFD-62rz9iTTW87iPdwDW5jcjxm7bs,2045
143
143
  ob_dj_store/core/stores/models/_address.py,sha256=8zV444A8M7P8yqQHjEOCROUykWPQ1ndSdd2IIX8wwWY,2207
144
- ob_dj_store/core/stores/models/_cart.py,sha256=MWwq9wcKv2ZnqxRuaJUXImYg4XUQFp5nmwGTjZLD4O4,7286
144
+ ob_dj_store/core/stores/models/_cart.py,sha256=uImY_F9buKwIQeokl8sooT_AzXHnhD_VFEqmP3Fph2Q,7461
145
145
  ob_dj_store/core/stores/models/_favorite.py,sha256=3yyMCoiftGOPAQwkMI2J29r3x6NJsRYri9f8gXiF1e8,3306
146
146
  ob_dj_store/core/stores/models/_feedback.py,sha256=eCUVgprNK5hSRKOS4M_pdR7QH2-rqhoYevlpykhCOLg,1472
147
147
  ob_dj_store/core/stores/models/_inventory.py,sha256=ZU8xDMQZxLnFehkBEGWr-os4AF1IlCn5XnBxvRq9IAs,4314
@@ -155,7 +155,7 @@ ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
155
155
  ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
156
156
  ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
157
157
  ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
158
- ob_dj_store-0.0.19.9.dist-info/METADATA,sha256=jYEq7WOUzag1zXvtBI19LBc_E6aPEfSIO6MV6rBop3w,2827
159
- ob_dj_store-0.0.19.9.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
160
- ob_dj_store-0.0.19.9.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
161
- ob_dj_store-0.0.19.9.dist-info/RECORD,,
158
+ ob_dj_store-0.0.20.dist-info/METADATA,sha256=GYWfTNybLOa88W3nVp6a8hrulcHsuT65w1Iw61RNR4M,2825
159
+ ob_dj_store-0.0.20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
160
+ ob_dj_store-0.0.20.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
161
+ ob_dj_store-0.0.20.dist-info/RECORD,,