ob-dj-store 0.0.20__py3-none-any.whl → 0.0.20.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.
@@ -362,7 +362,7 @@ class OrderSerializer(serializers.ModelSerializer):
362
362
  raise serializers.ValidationError(errors)
363
363
  email = gift_details.get("email")
364
364
  phone_number = gift_details.get("phone_number")
365
-
365
+ user = self.context["request"].user
366
366
  if email and phone_number:
367
367
  raise serializers.ValidationError(
368
368
  _("Both Email and Phone number cannot be provided.")
@@ -376,7 +376,12 @@ class OrderSerializer(serializers.ModelSerializer):
376
376
  validate_email(email)
377
377
  except ValidationError:
378
378
  raise serializers.ValidationError(_("Invalid Email format."))
379
+ try:
380
+ if not gift_details["currency"]:
381
+ gift_details["currency"] = get_currency_by_country(user.country.code)
379
382
 
383
+ except Exception:
384
+ raise serializers.ValidationError("Currency is required")
380
385
  if not pycountry.currencies.get(alpha_3=gift_details["currency"]):
381
386
  raise serializers.ValidationError("Gift currency is not valid")
382
387
  try:
@@ -453,12 +458,15 @@ class OrderSerializer(serializers.ModelSerializer):
453
458
  raise ValidationError(_("You cannot order from different stores"))
454
459
  for item in user.cart.items.all():
455
460
  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
+ if item.inventory.is_snoozed:
461
462
  unavailable_items.append(item)
463
+ elif not item.inventory.is_uncountable:
464
+ if (
465
+ not item.inventory.quantity
466
+ or item.inventory.quantity == 0
467
+ ):
468
+ unavailable_items.append(item)
469
+
462
470
  elif not item.inventory:
463
471
  if language and item.product_variant.product.name_arabic:
464
472
  product_name = item.product_variant.product.name_arabic
@@ -848,10 +856,19 @@ class CartSerializer(ArabicFieldsMixin, serializers.ModelSerializer):
848
856
  # update or create instance items
849
857
  for item in validated_data["items"]:
850
858
  attribute_choices = item.pop("attribute_choices", None)
851
- cart_item = CartItem.objects.create(
859
+ logger.info("cart item :", item)
860
+ cart_item, created = CartItem.objects.get_or_create(
852
861
  cart=instance,
853
- **item,
862
+ pk=item.pop("id", None),
863
+ defaults={
864
+ "cart": instance,
865
+ "product_variant": item.pop("product_variant", None),
866
+ "store": item.pop("store", None),
867
+ "notes": item.pop("notes", None),
868
+ "quantity": item.pop("quantity", None),
869
+ },
854
870
  )
871
+
855
872
  if attribute_choices:
856
873
  cart_item.attribute_choices.set(attribute_choices)
857
874
  cart_item.save()
@@ -1425,7 +1442,7 @@ class FavoriteSerializer(ArabicFieldsMixin, serializers.ModelSerializer):
1425
1442
  else:
1426
1443
  if inventory.is_uncountable:
1427
1444
  return True
1428
- return inventory.quantity > 0
1445
+ return False
1429
1446
  except ObjectDoesNotExist:
1430
1447
  return False
1431
1448
  return None
@@ -288,6 +288,7 @@ class CartAdmin(admin.ModelAdmin):
288
288
  search_fields = [
289
289
  "customer__email",
290
290
  ]
291
+ autocomplete_fields = ["customer"]
291
292
 
292
293
  def get_queryset(self, request):
293
294
  queryset = super().get_queryset(request)
@@ -380,6 +381,7 @@ class OrderAdmin(ImportExportModelAdmin, admin.ModelAdmin):
380
381
  "status",
381
382
  WeekNumberFilter, # Include the filter instance instead of the class name
382
383
  ]
384
+ autocomplete_fields = ["customer"]
383
385
 
384
386
  def get_queryset(self, request):
385
387
  queryset = (
@@ -419,6 +421,7 @@ class PaymentAdmin(ImportExportModelAdmin, admin.ModelAdmin):
419
421
  search_fields = ["orders__store__name", "user__email"]
420
422
  readonly_fields = ("orders",)
421
423
  date_hierarchy = "created_at"
424
+ autocomplete_fields = ["user"]
422
425
 
423
426
 
424
427
  class InventoryAdmin(admin.ModelAdmin):
@@ -107,12 +107,7 @@ class CartItemInlineAdmin(admin.TabularInline):
107
107
  class OrderItemInline(admin.TabularInline):
108
108
  model = models.OrderItem
109
109
  extra = 0
110
- fields = (
111
- "product_variant",
112
- "quantity",
113
- "unit_value",
114
- "total_amount",
115
- )
110
+ fields = ("product_variant", "quantity", "unit_value", "total_amount", "notes")
116
111
  readonly_fields = (
117
112
  "unit_value",
118
113
  "total_amount",
@@ -97,7 +97,8 @@ class Cart(models.Model):
97
97
  def fill(self, order):
98
98
  from ob_dj_store.core.stores.models._cart import CartItem
99
99
 
100
- for item in order.items.all():
100
+ order_items = order.items.all()
101
+ for item in order_items:
101
102
  cart_item = CartItem.objects.create(
102
103
  cart=self,
103
104
  product_variant=item.product_variant,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ob-dj-store
3
- Version: 0.0.20
3
+ Version: 0.0.20.2
4
4
  Summary: OBytes django application for managing ecommerce stores.
5
5
  Home-page: https://www.obytes.com/
6
6
  Author: OBytes
@@ -3,15 +3,15 @@ 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=IRpWBlEdbPCOX7FnVwxJhq4dXLOB8IcToLK7RM6HxI4,65258
6
+ ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=16tyWBbwC9NGEvfGDz8WdQe6QJo8GYPPzTdpb1Tdlvs,66061
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
10
10
  ob_dj_store/apis/tap/views.py,sha256=vG0rC-PQHCnrbNsPW1gClx0rkaIjALEAuj5cQKmCTo0,2664
11
11
  ob_dj_store/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  ob_dj_store/core/stores/__init__.py,sha256=-izNGrxNn_nn3IQXd5pkuES9lSF-AHYb14yhNPozYCI,65
13
- ob_dj_store/core/stores/admin.py,sha256=GWFVIzP4pUjY-57QBXrIhbK27JlY6EDatqsM97sGtZo,14533
14
- ob_dj_store/core/stores/admin_inlines.py,sha256=2K8iDmP4h0CLIOqy3x-ZXXpgYnT2jqL4cg5YFdiho8s,2976
13
+ ob_dj_store/core/stores/admin.py,sha256=IbkkC8ILwFDzWD1vxNfBwRpbSm4fGZOR8yya-ZbSJho,14646
14
+ ob_dj_store/core/stores/admin_inlines.py,sha256=2EOyWvl5ebm9kxHB8HXixAzUSx7FpGubPTwxGEJ66E0,2946
15
15
  ob_dj_store/core/stores/apps.py,sha256=ZadmEER_dNcQTH617b3fAsYZJSyRw0g46Kjp4eOAsOU,498
16
16
  ob_dj_store/core/stores/managers.py,sha256=lz2CE4PJCI1ViO-CU61LqTr43O41aGRQkbWZUR5Fmfg,9909
17
17
  ob_dj_store/core/stores/receivers.py,sha256=DljYC97C_e1mHduKw9Un6YQmxIdwSIter7yVVZwggFA,3768
@@ -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=uImY_F9buKwIQeokl8sooT_AzXHnhD_VFEqmP3Fph2Q,7461
144
+ ob_dj_store/core/stores/models/_cart.py,sha256=UKN_rBf9G0RAe5C1JplnEi6zTtc5toB-Dsq5Xl0rvN4,7495
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.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,,
158
+ ob_dj_store-0.0.20.2.dist-info/METADATA,sha256=_yjSTgCVEnJmDq9qsRD0HOIz3d4B1ucy1FkEiPU53ls,2827
159
+ ob_dj_store-0.0.20.2.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
160
+ ob_dj_store-0.0.20.2.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
161
+ ob_dj_store-0.0.20.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5