Spaces:
Sleeping
Sleeping
thejagstudio
commited on
Upload 54 files
Browse files- Dockerfile +12 -6
- api/__pycache__/urls.cpython-39.pyc +0 -0
- api/__pycache__/views.cpython-39.pyc +0 -0
- api/urls.py +1 -0
- api/views.py +20 -0
- authentication/__pycache__/models.cpython-39.pyc +0 -0
- authentication/__pycache__/urls.cpython-39.pyc +0 -0
- authentication/__pycache__/views.cpython-39.pyc +0 -0
- authentication/migrations/0006_userdata_activatedcoupons.py +19 -0
- authentication/migrations/__pycache__/0006_userdata_activatedcoupons.cpython-39.pyc +0 -0
- authentication/models.py +1 -0
- authentication/urls.py +1 -0
- authentication/views.py +26 -0
- db.sqlite3 +0 -0
- oneOone/__pycache__/settings.cpython-311.pyc +0 -0
- oneOone/__pycache__/settings.cpython-39.pyc +0 -0
- oneOone/settings.py +2 -2
Dockerfile
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
-
FROM
|
2 |
-
|
3 |
-
|
4 |
-
RUN
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
CMD ["python","./manage.py","runserver","0.0.0.0:7860"]
|
|
|
1 |
+
FROM ubuntu:24.04
|
2 |
+
RUN apt-get update
|
3 |
+
RUN apt-get install -y python3-pip
|
4 |
+
RUN apt-get install -y python3-venv
|
5 |
+
WORKDIR /code
|
6 |
+
RUN python3 -m venv /code/venv
|
7 |
+
COPY ./requirements.txt /code/requirements.txt
|
8 |
+
RUN /code/venv/bin/pip install --upgrade pip
|
9 |
+
RUN /code/venv/bin/pip install -r /code/requirements.txt
|
10 |
+
COPY . .
|
11 |
+
ENV PATH="/code/venv/bin:$PATH"
|
12 |
+
EXPOSE 7860
|
13 |
CMD ["python","./manage.py","runserver","0.0.0.0:7860"]
|
api/__pycache__/urls.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/urls.cpython-39.pyc and b/api/__pycache__/urls.cpython-39.pyc differ
|
|
api/__pycache__/views.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/views.cpython-39.pyc and b/api/__pycache__/views.cpython-39.pyc differ
|
|
api/urls.py
CHANGED
@@ -8,4 +8,5 @@ urlpatterns = [
|
|
8 |
path('resources-forward/<str:resource_name>/<str:image_id>', resources_forward, name='resources_forward'),
|
9 |
path('product-category', product_category, name='product_category'),
|
10 |
path('coupon-list', CouponListView.as_view(), name='coupon_List'),
|
|
|
11 |
]
|
|
|
8 |
path('resources-forward/<str:resource_name>/<str:image_id>', resources_forward, name='resources_forward'),
|
9 |
path('product-category', product_category, name='product_category'),
|
10 |
path('coupon-list', CouponListView.as_view(), name='coupon_List'),
|
11 |
+
path('coupon-redeem', CouponRedeemView.as_view(), name='coupon_redeem'),
|
12 |
]
|
api/views.py
CHANGED
@@ -128,6 +128,7 @@ class CouponListView(APIView):
|
|
128 |
|
129 |
user = UserData.objects.get(user=request.user)
|
130 |
coupons = user.coupons.all()
|
|
|
131 |
data = []
|
132 |
for coupon in coupons:
|
133 |
data.append({
|
@@ -138,6 +139,7 @@ class CouponListView(APIView):
|
|
138 |
"loyaltyCode": coupon.loyaltyCode,
|
139 |
"discount": coupon.discount,
|
140 |
"isExpired": coupon.isExpired,
|
|
|
141 |
"expiryDate": coupon.expiryDate,
|
142 |
"discountFunction": discount_functions[coupon.discountFunction],
|
143 |
"discountMethod": discount_methods[coupon.discountMethod],
|
@@ -148,3 +150,21 @@ class CouponListView(APIView):
|
|
148 |
})
|
149 |
|
150 |
return JsonResponse({"data": data})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
129 |
user = UserData.objects.get(user=request.user)
|
130 |
coupons = user.coupons.all()
|
131 |
+
redeemedCoupons = user.activatedCoupons.all()
|
132 |
data = []
|
133 |
for coupon in coupons:
|
134 |
data.append({
|
|
|
139 |
"loyaltyCode": coupon.loyaltyCode,
|
140 |
"discount": coupon.discount,
|
141 |
"isExpired": coupon.isExpired,
|
142 |
+
"isRedeemed": coupon in redeemedCoupons,
|
143 |
"expiryDate": coupon.expiryDate,
|
144 |
"discountFunction": discount_functions[coupon.discountFunction],
|
145 |
"discountMethod": discount_methods[coupon.discountMethod],
|
|
|
150 |
})
|
151 |
|
152 |
return JsonResponse({"data": data})
|
153 |
+
|
154 |
+
|
155 |
+
class CouponRedeemView(APIView):
|
156 |
+
permission_classes = [IsAuthenticated]
|
157 |
+
def post(self, request):
|
158 |
+
couponCode = request.data["couponCode"]
|
159 |
+
user = UserData.objects.get(user=request.user)
|
160 |
+
coupon = Coupon.objects.get(couponCode=couponCode)
|
161 |
+
if coupon not in user.coupons.all() or coupon == None:
|
162 |
+
return JsonResponse({"message": "Coupon is not available for this user"})
|
163 |
+
if coupon.isExpired:
|
164 |
+
return JsonResponse({"message": "Coupon is expired"})
|
165 |
+
if user.rewardPoints < coupon.pointsNeededForRedemption:
|
166 |
+
return JsonResponse({"message": "You don't have enough points to redeem this coupon"})
|
167 |
+
user.rewardPoints -= coupon.pointsNeededForRedemption
|
168 |
+
user.save()
|
169 |
+
user.activatedCoupons.add(coupon)
|
170 |
+
return JsonResponse({"message": "Coupon redeemed successfully"})
|
authentication/__pycache__/models.cpython-39.pyc
CHANGED
Binary files a/authentication/__pycache__/models.cpython-39.pyc and b/authentication/__pycache__/models.cpython-39.pyc differ
|
|
authentication/__pycache__/urls.cpython-39.pyc
CHANGED
Binary files a/authentication/__pycache__/urls.cpython-39.pyc and b/authentication/__pycache__/urls.cpython-39.pyc differ
|
|
authentication/__pycache__/views.cpython-39.pyc
CHANGED
Binary files a/authentication/__pycache__/views.cpython-39.pyc and b/authentication/__pycache__/views.cpython-39.pyc differ
|
|
authentication/migrations/0006_userdata_activatedcoupons.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-11-12 22:50
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("authentication", "0005_userdata_refcode"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.AddField(
|
13 |
+
model_name="userdata",
|
14 |
+
name="activatedCoupons",
|
15 |
+
field=models.ManyToManyField(
|
16 |
+
blank=True, related_name="activatedCoupons", to="authentication.coupon"
|
17 |
+
),
|
18 |
+
),
|
19 |
+
]
|
authentication/migrations/__pycache__/0006_userdata_activatedcoupons.cpython-39.pyc
ADDED
Binary file (662 Bytes). View file
|
|
authentication/models.py
CHANGED
@@ -54,6 +54,7 @@ class UserData(models.Model):
|
|
54 |
isBlocked = models.BooleanField(default=False)
|
55 |
isDeleted = models.BooleanField(default=False)
|
56 |
coupons = models.ManyToManyField(Coupon, blank=True, related_name='coupons')
|
|
|
57 |
|
58 |
def __str__(self):
|
59 |
return self.user.first_name + " " + self.user.last_name
|
|
|
54 |
isBlocked = models.BooleanField(default=False)
|
55 |
isDeleted = models.BooleanField(default=False)
|
56 |
coupons = models.ManyToManyField(Coupon, blank=True, related_name='coupons')
|
57 |
+
activatedCoupons = models.ManyToManyField(Coupon, blank=True, related_name='activatedCoupons')
|
58 |
|
59 |
def __str__(self):
|
60 |
return self.user.first_name + " " + self.user.last_name
|
authentication/urls.py
CHANGED
@@ -9,4 +9,5 @@ urlpatterns = [
|
|
9 |
path('password-reset/request/', RequestPasswordResetView.as_view(), name='password_reset_request'),
|
10 |
path('password-reset/resend/', ResendOTPView.as_view(), name='password_reset_resend'),
|
11 |
path('password-reset/confirm/', ResetPasswordView.as_view(), name='password_reset_confirm'),
|
|
|
12 |
]
|
|
|
9 |
path('password-reset/request/', RequestPasswordResetView.as_view(), name='password_reset_request'),
|
10 |
path('password-reset/resend/', ResendOTPView.as_view(), name='password_reset_resend'),
|
11 |
path('password-reset/confirm/', ResetPasswordView.as_view(), name='password_reset_confirm'),
|
12 |
+
path('user-detail/', UserDetailView.as_view(), name='user_detail'),
|
13 |
]
|
authentication/views.py
CHANGED
@@ -100,6 +100,32 @@ class LoginView(APIView):
|
|
100 |
print(e)
|
101 |
return JsonResponse({'error': str(e)}, status=400)
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
class LogoutView(APIView):
|
105 |
permission_classes = [IsAuthenticated]
|
|
|
100 |
print(e)
|
101 |
return JsonResponse({'error': str(e)}, status=400)
|
102 |
|
103 |
+
class UserDetailView(APIView):
|
104 |
+
permission_classes = [IsAuthenticated]
|
105 |
+
|
106 |
+
def get(self, request):
|
107 |
+
user = request.user
|
108 |
+
userDataObj = UserData.objects.get(user=user)
|
109 |
+
userData ={}
|
110 |
+
userData['email'] = user.email
|
111 |
+
userData['first_name'] = user.first_name
|
112 |
+
userData['last_name'] = user.last_name
|
113 |
+
userData["phone"] = userDataObj.phone
|
114 |
+
userData["refCode"] = userDataObj.refCode
|
115 |
+
userData["birthDate"] = userDataObj.birthDate
|
116 |
+
userData["gender"] = userDataObj.gender
|
117 |
+
userData["streetName"] = userDataObj.streetName
|
118 |
+
userData["city"] = userDataObj.city
|
119 |
+
userData["state"] = userDataObj.state
|
120 |
+
userData["country"] = userDataObj.country
|
121 |
+
userData["pincode"] = userDataObj.pincode
|
122 |
+
userData["rewardPoints"] = userDataObj.rewardPoints
|
123 |
+
userData["isVerified"] = userDataObj.isVerified
|
124 |
+
userData["isSubscribed"] = userDataObj.isSubscribed
|
125 |
+
userData["isBlocked"] = userDataObj.isBlocked
|
126 |
+
userData["isDeleted"] = userDataObj.isDeleted
|
127 |
+
return JsonResponse(userData, status=200)
|
128 |
+
|
129 |
|
130 |
class LogoutView(APIView):
|
131 |
permission_classes = [IsAuthenticated]
|
db.sqlite3
ADDED
Binary file (246 kB). View file
|
|
oneOone/__pycache__/settings.cpython-311.pyc
CHANGED
Binary files a/oneOone/__pycache__/settings.cpython-311.pyc and b/oneOone/__pycache__/settings.cpython-311.pyc differ
|
|
oneOone/__pycache__/settings.cpython-39.pyc
CHANGED
Binary files a/oneOone/__pycache__/settings.cpython-39.pyc and b/oneOone/__pycache__/settings.cpython-39.pyc differ
|
|
oneOone/settings.py
CHANGED
@@ -102,9 +102,9 @@ DATABASES = {
|
|
102 |
'default': {
|
103 |
'ENGINE': 'django.db.backends.postgresql',
|
104 |
'NAME': 'postgres',
|
105 |
-
'USER': 'postgres.
|
106 |
'PORT': 6543,
|
107 |
-
'PASSWORD': '
|
108 |
'HOST': 'aws-0-us-east-1.pooler.supabase.com',
|
109 |
}
|
110 |
}
|
|
|
102 |
'default': {
|
103 |
'ENGINE': 'django.db.backends.postgresql',
|
104 |
'NAME': 'postgres',
|
105 |
+
'USER': 'postgres.igsosentooipcjyflmnw',
|
106 |
'PORT': 6543,
|
107 |
+
'PASSWORD': 'bfHBTQr6xCAwdbts',
|
108 |
'HOST': 'aws-0-us-east-1.pooler.supabase.com',
|
109 |
}
|
110 |
}
|