ob-dj-store 0.0.20.8__py3-none-any.whl → 0.0.20.9__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.
@@ -239,6 +239,7 @@ class FavoriteFilter(filters.FilterSet):
239
239
  class PaymentMethodFilter(filters.FilterSet):
240
240
  store = filters.CharFilter(method="by_store")
241
241
  is_digital = filters.BooleanFilter(method="by_digital")
242
+ country = filters.CharFilter(method="by_country")
242
243
 
243
244
  class Meta:
244
245
  models = PaymentMethod
@@ -253,6 +254,12 @@ class PaymentMethodFilter(filters.FilterSet):
253
254
  )
254
255
  return queryset
255
256
 
257
+ def by_country(self, queryset, name, value):
258
+ currency = get_currency_by_country(value)
259
+ if value:
260
+ queryset = queryset.filter(currency=currency)
261
+ return queryset
262
+
256
263
 
257
264
  class WalletFilter(filters.FilterSet):
258
265
  currency = filters.CharFilter(
@@ -1,7 +1,8 @@
1
1
  import calendar
2
2
  import logging
3
3
  import typing
4
- from datetime import timedelta
4
+ from collections import OrderedDict
5
+ from datetime import datetime, timedelta
5
6
  from decimal import Decimal
6
7
 
7
8
  import pycountry
@@ -1646,6 +1647,27 @@ class WalletTransactionSerializer(serializers.ModelSerializer):
1646
1647
  ]
1647
1648
 
1648
1649
 
1650
+ class WalletTransactionListSerializer(serializers.Serializer):
1651
+ def to_representation(self, instance):
1652
+ result_dict = OrderedDict()
1653
+
1654
+ for wallettransaction in instance:
1655
+ year = wallettransaction.created_at.year
1656
+ month = wallettransaction.created_at.month
1657
+ title = f"{datetime(year, month, 1).strftime('%b')}, {year}"
1658
+
1659
+ if title not in result_dict:
1660
+ result_dict[title] = {"title": title, "data": []}
1661
+
1662
+ result_dict[title]["data"].append(
1663
+ WalletTransactionSerializer(
1664
+ wallettransaction, context=self.context
1665
+ ).data
1666
+ )
1667
+
1668
+ return {"Transactions": list(result_dict.values())}
1669
+
1670
+
1649
1671
  class ReorderSerializer(serializers.Serializer):
1650
1672
  force_cart = serializers.BooleanField(default=False)
1651
1673
 
@@ -60,7 +60,7 @@ from ob_dj_store.apis.stores.rest.serializers.serializers import (
60
60
  WalletMediaSerializer,
61
61
  WalletSerializer,
62
62
  WalletTopUpSerializer,
63
- WalletTransactionSerializer,
63
+ WalletTransactionListSerializer,
64
64
  )
65
65
  from ob_dj_store.core.stores.gateway.tap.utils import TapException
66
66
  from ob_dj_store.core.stores.models import (
@@ -1103,7 +1103,7 @@ class WalletViewSet(
1103
1103
  methods=["GET",],
1104
1104
  detail=True,
1105
1105
  url_path="transactions",
1106
- serializer_class=WalletTransactionSerializer,
1106
+ serializer_class=WalletTransactionListSerializer,
1107
1107
  )
1108
1108
  def transactions(
1109
1109
  self, request: Request, *args: typing.Any, **kwargs: typing.Any
@@ -1111,10 +1111,10 @@ class WalletViewSet(
1111
1111
  queryset = self.get_object().transactions.all().order_by("-created_at")
1112
1112
  page = self.paginate_queryset(queryset)
1113
1113
  if page is not None:
1114
- serializer = self.get_serializer(page, many=True)
1114
+ serializer = self.get_serializer(page)
1115
1115
  return self.get_paginated_response(serializer.data)
1116
1116
 
1117
- serializer = self.get_serializer(queryset, many=True)
1117
+ serializer = self.get_serializer(queryset)
1118
1118
  return Response(serializer.data)
1119
1119
 
1120
1120
  @swagger_auto_schema(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ob-dj-store
3
- Version: 0.0.20.8
3
+ Version: 0.0.20.9
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=kbKtrg9ba9R5ptN9xOOEo-ZZ2IZbQfGH6BJCGUzF1bc,9510
3
+ ob_dj_store/apis/stores/filters.py,sha256=lDb-wS7dEsSS0XL2qN4XqoRKYSEDgxhVZLBPGL0pPM4,9764
4
4
  ob_dj_store/apis/stores/urls.py,sha256=7vwogfIGcKS0hHYK3iBXKQwi1kCA_vuHY1eZt8rAspg,2021
5
- ob_dj_store/apis/stores/views.py,sha256=P8hkpMxC080QlPGFXaQXV2wKoo-B0aUg-hToHtMG24s,41612
6
- ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=HeUvpFUz8DMOLCmiSEPmitlsoNfjUJq9h2zaXqZKi7w,66013
5
+ ob_dj_store/apis/stores/views.py,sha256=3uhbSZ9IJ0-t73NgYqepd0X3RlddtF24b9h9Q-GseFQ,41598
6
+ ob_dj_store/apis/stores/rest/serializers/serializers.py,sha256=zsrEyB86eHbMEK2_3xMLOZkoYTdAoqjberqY-NM4p8c,66787
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
@@ -159,7 +159,7 @@ ob_dj_store/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
159
159
  ob_dj_store/utils/helpers.py,sha256=o7wgypM7mI2vZqZKkhxnTcnHJC8GMQDOuYMnRwXr6tY,2058
160
160
  ob_dj_store/utils/model.py,sha256=DV7hOhTaZL3gh9sptts2jTUFlTArKG3i7oPioq9HLFE,303
161
161
  ob_dj_store/utils/utils.py,sha256=8UVAFB56qUSjJJ5f9vnermtw638gdFy4CFRCuMbns_M,1342
162
- ob_dj_store-0.0.20.8.dist-info/METADATA,sha256=9FsAIsFu8qFF8RmriRXcPKwHq9krgPwQyJx6Ph-E9oQ,2850
163
- ob_dj_store-0.0.20.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
- ob_dj_store-0.0.20.8.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
165
- ob_dj_store-0.0.20.8.dist-info/RECORD,,
162
+ ob_dj_store-0.0.20.9.dist-info/METADATA,sha256=gbT3fMY8JgAOJxAbCb2o9Ub-T8bDU-esMeaXCvKwqvU,2850
163
+ ob_dj_store-0.0.20.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
164
+ ob_dj_store-0.0.20.9.dist-info/top_level.txt,sha256=CZG3G0ptTkzGnc0dFYN-ZD7YKdJBmm47bsmGwofD_lk,12
165
+ ob_dj_store-0.0.20.9.dist-info/RECORD,,