ob-dj-store 0.0.13.9__py3-none-any.whl → 0.0.13.11__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.
@@ -715,15 +715,26 @@ class SubCategorySerializer(serializers.ModelSerializer):
715
715
  if store_id:
716
716
  try:
717
717
  current_availability_hours = AvailabilityHours.objects.get(
718
- weekday=now().weekday() + 1,
718
+ weekday=localtime(now()).weekday() + 1,
719
719
  store=store_id,
720
720
  category=obj,
721
721
  )
722
- return (
722
+ parent_availability_hours = AvailabilityHours.objects.get(
723
+ weekday=localtime(now()).weekday() + 1,
724
+ store=store_id,
725
+ category=obj.parent,
726
+ )
727
+ is_available_sub = (
723
728
  current_availability_hours.from_hour
724
- <= now().time()
729
+ <= localtime(now()).time()
725
730
  <= current_availability_hours.to_hour
726
731
  )
732
+ is_available_parent = (
733
+ parent_availability_hours.from_hour
734
+ <= localtime(now()).time()
735
+ <= parent_availability_hours.to_hour
736
+ )
737
+ return is_available_sub and is_available_parent
727
738
  except ObjectDoesNotExist:
728
739
  pass
729
740
  return False
@@ -56,6 +56,7 @@ from ob_dj_store.apis.stores.rest.serializers.serializers import (
56
56
  )
57
57
  from ob_dj_store.core.stores.gateway.tap.utils import TapException
58
58
  from ob_dj_store.core.stores.models import (
59
+ AttributeChoice,
59
60
  Cart,
60
61
  CartItem,
61
62
  Category,
@@ -595,6 +596,19 @@ class ProductView(
595
596
  )
596
597
  ).distinct(),
597
598
  ),
599
+ Prefetch(
600
+ "product_variants__product_attributes__attribute_choices",
601
+ queryset=AttributeChoice.objects.filter(
602
+ Q(
603
+ attribute_inventory__snooze_start_date__gt=now(),
604
+ attribute_inventory__store__pk=self.kwargs["store_pk"],
605
+ )
606
+ | Q(
607
+ attribute_inventory__snooze_end_date__lt=now(),
608
+ attribute_inventory__store__pk=self.kwargs["store_pk"],
609
+ )
610
+ ).distinct(),
611
+ ),
598
612
  ).distinct()
599
613
  return qs
600
614
 
@@ -0,0 +1,64 @@
1
+ # Generated by Django 3.2.8 on 2023-05-15 11:10
2
+
3
+ import django.db.models.deletion
4
+ import django.utils.timezone
5
+ from django.db import migrations, models
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ dependencies = [
11
+ ("stores", "0080_productvariant_description"),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.CreateModel(
16
+ name="StoreAttributeChoice",
17
+ fields=[
18
+ (
19
+ "id",
20
+ models.AutoField(
21
+ auto_created=True,
22
+ primary_key=True,
23
+ serialize=False,
24
+ verbose_name="ID",
25
+ ),
26
+ ),
27
+ (
28
+ "snooze_start_date",
29
+ models.DateTimeField(
30
+ default=django.utils.timezone.now,
31
+ help_text="When snooze status should begin",
32
+ ),
33
+ ),
34
+ (
35
+ "snooze_end_date",
36
+ models.DateTimeField(
37
+ default=django.utils.timezone.now,
38
+ help_text="When snooze status should end",
39
+ ),
40
+ ),
41
+ (
42
+ "attribute",
43
+ models.ForeignKey(
44
+ on_delete=django.db.models.deletion.CASCADE,
45
+ related_name="attribute_inventory",
46
+ to="stores.attributechoice",
47
+ ),
48
+ ),
49
+ (
50
+ "store",
51
+ models.ForeignKey(
52
+ on_delete=django.db.models.deletion.CASCADE,
53
+ related_name="attribute_inventory",
54
+ to="stores.store",
55
+ ),
56
+ ),
57
+ ],
58
+ options={
59
+ "verbose_name": "Store Attribute Choice",
60
+ "verbose_name_plural": "Store Attribute Choices",
61
+ "unique_together": {("store", "attribute")},
62
+ },
63
+ ),
64
+ ]
@@ -19,6 +19,7 @@ from ob_dj_store.core.stores.models._product import (
19
19
  ProductMedia,
20
20
  ProductTag,
21
21
  ProductVariant,
22
+ StoreAttributeChoice,
22
23
  )
23
24
  from ob_dj_store.core.stores.models._store import (
24
25
  OpeningHours,
@@ -67,4 +68,5 @@ __all__ = [
67
68
  "FavoriteExtra",
68
69
  "WalletMedia",
69
70
  "AvailabilityHours",
71
+ "StoreAttributeChoice",
70
72
  ]
@@ -1,6 +1,7 @@
1
1
  from django.core.exceptions import ObjectDoesNotExist, ValidationError
2
2
  from django.core.validators import RegexValidator
3
3
  from django.db import models
4
+ from django.utils.timezone import now
4
5
  from django.utils.translation import gettext_lazy as _
5
6
 
6
7
  from ob_dj_store.core.stores.managers import (
@@ -263,6 +264,33 @@ class AttributeChoice(DjangoModelCleanMixin, models.Model):
263
264
  return f"{self.name}: Attribute Choice (PK={self.pk})"
264
265
 
265
266
 
267
+ class StoreAttributeChoice(models.Model):
268
+ store = models.ForeignKey(
269
+ Store, on_delete=models.CASCADE, related_name="attribute_inventory"
270
+ )
271
+ attribute = models.ForeignKey(
272
+ AttributeChoice, on_delete=models.CASCADE, related_name="attribute_inventory"
273
+ )
274
+ snooze_start_date = models.DateTimeField(
275
+ default=now, help_text=_("When snooze status should begin")
276
+ )
277
+ snooze_end_date = models.DateTimeField(
278
+ default=now, help_text=_("When snooze status should end")
279
+ )
280
+
281
+ class Meta:
282
+ verbose_name = _("Store Attribute Choice")
283
+ verbose_name_plural = _("Store Attribute Choices")
284
+ unique_together = (("store", "attribute"),)
285
+
286
+ def __str__(self) -> str:
287
+ return f"StoreProductAttribute(PK={self.pk})"
288
+
289
+ @property
290
+ def is_snoozed(self):
291
+ return self.snooze_start_date <= now() <= self.snooze_end_date
292
+
293
+
266
294
  class ProductAttribute(DjangoModelCleanMixin, models.Model):
267
295
  """
268
296
  ProductAttribute represent a characteristic -attribute- with is choices -attribute_choices-
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ob-dj-store
3
- Version: 0.0.13.9
3
+ Version: 0.0.13.11
4
4
  Summary: OBytes django application for managing ecommerce stores.
5
5
  Home-page: https://www.obytes.com/
6
6
  Author: OBytes
@@ -2,8 +2,8 @@ ob_dj_store/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
2
2
  ob_dj_store/apis/stores/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  ob_dj_store/apis/stores/filters.py,sha256=O5DAzet_WGNoWSEnqbPtwrKy3sbe1HzTtx8jcTLz1dk,7680
4
4
  ob_dj_store/apis/stores/urls.py,sha256=P4d0iamg2R5lTwc5DTIuhLzJTMSH4f5QpHzGR1_PWE0,1676
5
- ob_dj_store/apis/stores/views.py,sha256=dbWLI9dx9Nox_xugOTYqxrDUFrM_9tcJvmPMApvwzeE,35467
6
- ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=AhoxEMqCcYEIhVUL1OjIRvuAFsxeZEMVECPmVBugQ0c,45893
5
+ ob_dj_store/apis/stores/views.py,sha256=Umdt1Lu1q4V5R6XasCLpTKjmM2VFco1qa-Z8Ba5Fsuk,36085
6
+ ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=R4ppx2eEHxU2zrYhi2muxHG3sJN0RIYQaTMDbpWyEyY,46439
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
@@ -109,8 +109,9 @@ ob_dj_store/core/stores/migrations/0077_auto_20230502_2005.py,sha256=BFuRrr73q3n
109
109
  ob_dj_store/core/stores/migrations/0078_auto_20230503_1259.py,sha256=Svf1krUGKEsv0MZxgyH0nOkP4ROGs0ESTChHZoCdzIk,1820
110
110
  ob_dj_store/core/stores/migrations/0079_auto_20230504_1919.py,sha256=W5hEiToK5bapvxwHheNtZKXEaHsgCvj3K5JahgcDMME,1347
111
111
  ob_dj_store/core/stores/migrations/0080_productvariant_description.py,sha256=m7QgiqQwfGYJgXcWWuk12aCZtfZERKllYhh4MPOyEyo,404
112
+ ob_dj_store/core/stores/migrations/0081_storeattributechoice.py,sha256=guZBDV-DKfOssqnhUPixspjRzaZtHw3f70eCK4Eqo2c,2089
112
113
  ob_dj_store/core/stores/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
113
- ob_dj_store/core/stores/models/__init__.py,sha256=0y1o_Rh7axEbk9BNkE4JcAgSQkYgGBLG2jt9pNgsvPY,1665
114
+ ob_dj_store/core/stores/models/__init__.py,sha256=cVP-nOcpfmK-usCyUrUciLqu9kRE85ooBKpV1Kk0JgE,1719
114
115
  ob_dj_store/core/stores/models/_address.py,sha256=qS5TQ9Z12zx_4CrrHvG8PoYVkdiOq_MtbKR14WKh3Hw,1661
115
116
  ob_dj_store/core/stores/models/_cart.py,sha256=SmlOczSZ2UnEIFcCR107-pcCMlkOL0oWb22h6--x_1k,4779
116
117
  ob_dj_store/core/stores/models/_favorite.py,sha256=J29ECDsotIgduPpmUmieYTndymReWHkfdsZyQzz6A4g,3042
@@ -118,14 +119,14 @@ ob_dj_store/core/stores/models/_feedback.py,sha256=eCUVgprNK5hSRKOS4M_pdR7QH2-rq
118
119
  ob_dj_store/core/stores/models/_inventory.py,sha256=ZU8xDMQZxLnFehkBEGWr-os4AF1IlCn5XnBxvRq9IAs,4314
119
120
  ob_dj_store/core/stores/models/_order.py,sha256=jJF1Mq2hg9IVle_D66hc5dBkyqtzhV3ZYM1u_lWJevQ,8679
120
121
  ob_dj_store/core/stores/models/_payment.py,sha256=30yKIsJgdG93Dsbi6xcMa7QwF8dr8O4zWG-fq735GRc,6240
121
- ob_dj_store/core/stores/models/_product.py,sha256=tJ3Jcdgh_NWKxCPQ6xZMJ-ZKrREpLVi9k8Ttocxt1Pg,13979
122
+ ob_dj_store/core/stores/models/_product.py,sha256=u1hfat7mYa3iql8NlUFjPtZOmbU-qpibsQbfNl_xM9Q,14913
122
123
  ob_dj_store/core/stores/models/_store.py,sha256=FG-_bfi-7gUo6MHLtbXwFsiXpgvRafJzRdatgE6ZBbE,8005
123
124
  ob_dj_store/core/stores/models/_wallet.py,sha256=fTL1iLA7Gpqv_14XiCyNq2HCHgAe6sUSE6GBaHakvu0,5091
124
125
  ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
126
  ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
126
127
  ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
127
128
  ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
128
- ob_dj_store-0.0.13.9.dist-info/METADATA,sha256=qrJ0LDEedUzwKjFB1IjpyH7qF4jQUbje9XfaoL7ERfU,2827
129
- ob_dj_store-0.0.13.9.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
130
- ob_dj_store-0.0.13.9.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
131
- ob_dj_store-0.0.13.9.dist-info/RECORD,,
129
+ ob_dj_store-0.0.13.11.dist-info/METADATA,sha256=Rztx3a8uLPB-0Xv8GCvclKk66dos3KEGw3tPvRbBKXs,2828
130
+ ob_dj_store-0.0.13.11.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
131
+ ob_dj_store-0.0.13.11.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
132
+ ob_dj_store-0.0.13.11.dist-info/RECORD,,