Spaces:
Sleeping
Sleeping
Upload 46 files
Browse files- api/__pycache__/urls.cpython-39.pyc +0 -0
- api/__pycache__/views.cpython-39.pyc +0 -0
- api/urls.py +6 -5
- api/views.py +68 -24
- authentication/__pycache__/admin.cpython-39.pyc +0 -0
- authentication/__pycache__/apps.cpython-39.pyc +0 -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/admin.py +9 -0
- authentication/migrations/0001_initial.py +150 -0
- authentication/migrations/0002_alter_userdata_coupons_alter_userdata_otp.py +24 -0
- authentication/migrations/0003_alter_coupon_expirydate.py +17 -0
- authentication/migrations/0004_coupon_discription.py +17 -0
- authentication/migrations/__pycache__/0001_initial.cpython-39.pyc +0 -0
- authentication/migrations/__pycache__/0002_alter_userdata_coupons_alter_userdata_otp.cpython-39.pyc +0 -0
- authentication/migrations/__pycache__/0003_alter_coupon_expirydate.cpython-39.pyc +0 -0
- authentication/migrations/__pycache__/0004_coupon_discription.cpython-39.pyc +0 -0
- authentication/migrations/__pycache__/__init__.cpython-39.pyc +0 -0
- authentication/models.py +57 -1
- authentication/urls.py +3 -1
- authentication/views.py +55 -3
- oneOone/__pycache__/settings.cpython-311.pyc +0 -0
- oneOone/__pycache__/settings.cpython-39.pyc +0 -0
- oneOone/__pycache__/urls.cpython-311.pyc +0 -0
- oneOone/__pycache__/urls.cpython-39.pyc +0 -0
- oneOone/settings.py +176 -174
- oneOone/urls.py +0 -20
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
@@ -1,9 +1,10 @@
|
|
1 |
from django.urls import path
|
2 |
-
from . import
|
3 |
|
4 |
urlpatterns = [
|
5 |
-
path('',
|
6 |
-
path('establishments',
|
7 |
-
path('resources-forward/<str:resource_name>/<str:image_id>',
|
8 |
-
path('product-category',
|
|
|
9 |
]
|
|
|
1 |
from django.urls import path
|
2 |
+
from .views import *
|
3 |
|
4 |
urlpatterns = [
|
5 |
+
path('', HomeView.as_view(), name='home'),
|
6 |
+
path('establishments', EstablishmentListView.as_view(), name='establishment_List'),
|
7 |
+
path('resources-forward/<str:resource_name>/<str:image_id>', resources_forward, name='resources_forward'),
|
8 |
+
path('product-category', product_category, name='product_category'),
|
9 |
+
path('coupon-list', CouponListView.as_view(), name='coupon_List'),
|
10 |
]
|
api/views.py
CHANGED
@@ -3,35 +3,45 @@ from django.http import JsonResponse, HttpResponse
|
|
3 |
import requests
|
4 |
import json
|
5 |
import base64
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
authToken = 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
|
8 |
|
9 |
-
def home(request):
|
10 |
-
message = "Welcome at home!"
|
11 |
-
return JsonResponse({'message': message})
|
12 |
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
|
|
15 |
global authToken
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
35 |
|
36 |
|
37 |
def resources_forward(request, resource_name,image_id):
|
@@ -52,4 +62,38 @@ def product_category(request):
|
|
52 |
}
|
53 |
response = requests.request("GET", url, headers=headers)
|
54 |
data = response.json()["objects"]
|
55 |
-
return JsonResponse({"data": data})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import requests
|
4 |
import json
|
5 |
import base64
|
6 |
+
from authentication.models import UserData, Coupon
|
7 |
+
from django.views.decorators.csrf import csrf_exempt
|
8 |
+
from django.contrib.auth.decorators import login_required
|
9 |
+
from rest_framework.permissions import IsAuthenticated
|
10 |
+
from rest_framework.views import APIView
|
11 |
|
12 |
authToken = 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
|
13 |
|
|
|
|
|
|
|
14 |
|
15 |
+
class HomeView(APIView):
|
16 |
+
def get(self, request):
|
17 |
+
message = "Welcome at home!"
|
18 |
+
return Response({'message': message})
|
19 |
|
20 |
+
|
21 |
+
class EstablishmentListView(APIView):
|
22 |
global authToken
|
23 |
+
|
24 |
+
def get(self, request):
|
25 |
+
url = "https://101smokeshop-uat.revelup.com/enterprise/Establishment/?order_by=id&limit=10&offset=0"
|
26 |
+
headers = {
|
27 |
+
'API-AUTHENTICATION': authToken
|
28 |
+
}
|
29 |
+
response = requests.get(url, headers=headers)
|
30 |
+
data = response.json().get("objects", [])
|
31 |
+
urlBase = "https://101smokeshop-uat.revelup.com"
|
32 |
+
|
33 |
+
for i in range(len(data)):
|
34 |
+
try:
|
35 |
+
imgData = requests.get(urlBase + data[i]["logo_img"], headers=headers).json()
|
36 |
+
data[i]["logo_img"] = imgData.get("image_url", "")
|
37 |
+
except:
|
38 |
+
pass
|
39 |
+
try:
|
40 |
+
data[i]["address"] = requests.get(urlBase + data[i]["address"], headers=headers).json()
|
41 |
+
except:
|
42 |
+
pass
|
43 |
+
|
44 |
+
return JsonResponse({"data": data})
|
45 |
|
46 |
|
47 |
def resources_forward(request, resource_name,image_id):
|
|
|
62 |
}
|
63 |
response = requests.request("GET", url, headers=headers)
|
64 |
data = response.json()["objects"]
|
65 |
+
return JsonResponse({"data": data})
|
66 |
+
|
67 |
+
|
68 |
+
class CouponListView(APIView):
|
69 |
+
permission_classes = [IsAuthenticated]
|
70 |
+
def get(self, request):
|
71 |
+
discount_functions = ["CORE", "CUSTOMER", "LOYALTY", "GIFT_WITH_PURCHASE"]
|
72 |
+
discount_methods = ["POINT_REDEMPTION", "REDEEMED", "GIVE_AWAY", "BONUS_COUPON", "VOUCHER_GENERIC", "VOUCHER_LOYALTY", "VOUCHER_FUEL", "VOUCHER_THIRDPARTY"]
|
73 |
+
discount_types = ["AMOUNT", "PERCENT", "RE_PRICE", "ALT_PRICE"]
|
74 |
+
how_often_apply = ["ALL_APPLICABLE", "ONCE_PER_ORDER", "ONCE_PER_SELECTION"]
|
75 |
+
qualification_types = ["ALL", "ITEM", "ORDER"]
|
76 |
+
rewards_types = ["PURCHASES", "ITEMS", "VISIT"]
|
77 |
+
|
78 |
+
user = UserData.objects.get(user=request.user)
|
79 |
+
coupons = user.coupons.all()
|
80 |
+
data = []
|
81 |
+
for coupon in coupons:
|
82 |
+
data.append({
|
83 |
+
"name": coupon.name,
|
84 |
+
"discription": coupon.discription,
|
85 |
+
"pointsNeededForRedemption": coupon.pointsNeededForRedemption,
|
86 |
+
"couponCode": coupon.couponCode,
|
87 |
+
"loyaltyCode": coupon.loyaltyCode,
|
88 |
+
"discount": coupon.discount,
|
89 |
+
"isExpired": coupon.isExpired,
|
90 |
+
"expiryDate": coupon.expiryDate,
|
91 |
+
"discountFunction": discount_functions[coupon.discountFunction],
|
92 |
+
"discountMethod": discount_methods[coupon.discountMethod],
|
93 |
+
"discountType": discount_types[coupon.discountType],
|
94 |
+
"howOftenApply": how_often_apply[coupon.howOftenApply],
|
95 |
+
"qualificationType": qualification_types[coupon.qualificationType],
|
96 |
+
"rewardsType": rewards_types[coupon.rewardsType],
|
97 |
+
})
|
98 |
+
|
99 |
+
return JsonResponse({"data": data})
|
authentication/__pycache__/admin.cpython-39.pyc
ADDED
Binary file (762 Bytes). View file
|
|
authentication/__pycache__/apps.cpython-39.pyc
ADDED
Binary file (437 Bytes). View file
|
|
authentication/__pycache__/models.cpython-39.pyc
ADDED
Binary file (2.99 kB). View file
|
|
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/admin.py
CHANGED
@@ -1,3 +1,12 @@
|
|
1 |
from django.contrib import admin
|
|
|
2 |
|
3 |
# Register your models here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from django.contrib import admin
|
2 |
+
from .models import Coupon, UserData
|
3 |
|
4 |
# Register your models here.
|
5 |
+
class UserDataAdmin(admin.ModelAdmin):
|
6 |
+
list_display = ['user', 'phone', 'birthDate', 'rewardPoints']
|
7 |
+
|
8 |
+
class CouponAdmin(admin.ModelAdmin):
|
9 |
+
list_display = ['name', 'pointsNeededForRedemption', 'couponCode', 'loyaltyCode', 'discount', 'isExpired', 'expiryDate',]
|
10 |
+
|
11 |
+
admin.site.register(Coupon, CouponAdmin)
|
12 |
+
admin.site.register(UserData, UserDataAdmin)
|
authentication/migrations/0001_initial.py
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-10-24 12:52
|
2 |
+
|
3 |
+
import authentication.models
|
4 |
+
from django.conf import settings
|
5 |
+
from django.db import migrations, models
|
6 |
+
import django.db.models.deletion
|
7 |
+
|
8 |
+
|
9 |
+
class Migration(migrations.Migration):
|
10 |
+
initial = True
|
11 |
+
|
12 |
+
dependencies = [
|
13 |
+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
14 |
+
]
|
15 |
+
|
16 |
+
operations = [
|
17 |
+
migrations.CreateModel(
|
18 |
+
name="Coupon",
|
19 |
+
fields=[
|
20 |
+
(
|
21 |
+
"id",
|
22 |
+
models.BigAutoField(
|
23 |
+
auto_created=True,
|
24 |
+
primary_key=True,
|
25 |
+
serialize=False,
|
26 |
+
verbose_name="ID",
|
27 |
+
),
|
28 |
+
),
|
29 |
+
("name", models.CharField(max_length=50)),
|
30 |
+
("pointsNeededForRedemption", models.IntegerField()),
|
31 |
+
(
|
32 |
+
"couponCode",
|
33 |
+
models.CharField(
|
34 |
+
default=authentication.models.Coupon.randomCouponCode,
|
35 |
+
max_length=50,
|
36 |
+
),
|
37 |
+
),
|
38 |
+
(
|
39 |
+
"loyaltyCode",
|
40 |
+
models.CharField(
|
41 |
+
default=authentication.models.Coupon.randomLoyaltyCode,
|
42 |
+
max_length=50,
|
43 |
+
),
|
44 |
+
),
|
45 |
+
("discount", models.IntegerField()),
|
46 |
+
("isExpired", models.BooleanField(default=False)),
|
47 |
+
("expiryDate", models.DateTimeField()),
|
48 |
+
(
|
49 |
+
"discountFunction",
|
50 |
+
models.IntegerField(
|
51 |
+
choices=[
|
52 |
+
(0, "CORE"),
|
53 |
+
(1, "CUSTOMER"),
|
54 |
+
(2, "LOYALTY"),
|
55 |
+
(3, "GIFT_WITH_PURCHASE"),
|
56 |
+
],
|
57 |
+
default=2,
|
58 |
+
),
|
59 |
+
),
|
60 |
+
(
|
61 |
+
"discountMethod",
|
62 |
+
models.IntegerField(
|
63 |
+
choices=[
|
64 |
+
(0, "POINT_REDEMPTION"),
|
65 |
+
(1, "REDEEMED"),
|
66 |
+
(2, "GIVE_AWAY"),
|
67 |
+
(3, "BONUS_COUPON"),
|
68 |
+
(4, "VOUCHER_GENERIC"),
|
69 |
+
(5, "VOUCHER_LOYALTY"),
|
70 |
+
(6, "VOUCHER_FUEL"),
|
71 |
+
(7, "VOUCHER_THIRDPARTY"),
|
72 |
+
],
|
73 |
+
default=0,
|
74 |
+
),
|
75 |
+
),
|
76 |
+
(
|
77 |
+
"discountType",
|
78 |
+
models.IntegerField(
|
79 |
+
choices=[
|
80 |
+
(0, "AMOUNT"),
|
81 |
+
(1, "PERCENT"),
|
82 |
+
(2, "RE_PRICE"),
|
83 |
+
(3, "ALT_PRICE"),
|
84 |
+
],
|
85 |
+
default=0,
|
86 |
+
),
|
87 |
+
),
|
88 |
+
(
|
89 |
+
"howOftenApply",
|
90 |
+
models.IntegerField(
|
91 |
+
choices=[
|
92 |
+
(0, "ALL_APPLICABLE"),
|
93 |
+
(1, "ONCE_PER_ORDER"),
|
94 |
+
(2, "ONCE_PER_SELECTION"),
|
95 |
+
],
|
96 |
+
default=1,
|
97 |
+
),
|
98 |
+
),
|
99 |
+
(
|
100 |
+
"qualificationType",
|
101 |
+
models.IntegerField(
|
102 |
+
choices=[(0, "ALL"), (1, "ITEM"), (2, "ORDER")], default=2
|
103 |
+
),
|
104 |
+
),
|
105 |
+
(
|
106 |
+
"rewardsType",
|
107 |
+
models.IntegerField(
|
108 |
+
choices=[(0, "PURCHASES"), (1, "ITEMS"), (2, "VISIT")],
|
109 |
+
default=0,
|
110 |
+
),
|
111 |
+
),
|
112 |
+
],
|
113 |
+
),
|
114 |
+
migrations.CreateModel(
|
115 |
+
name="UserData",
|
116 |
+
fields=[
|
117 |
+
(
|
118 |
+
"id",
|
119 |
+
models.BigAutoField(
|
120 |
+
auto_created=True,
|
121 |
+
primary_key=True,
|
122 |
+
serialize=False,
|
123 |
+
verbose_name="ID",
|
124 |
+
),
|
125 |
+
),
|
126 |
+
("phone", models.CharField(max_length=15)),
|
127 |
+
("birthDate", models.DateField()),
|
128 |
+
("gender", models.CharField(max_length=10)),
|
129 |
+
("streetName", models.CharField(max_length=50)),
|
130 |
+
("city", models.CharField(max_length=50)),
|
131 |
+
("state", models.CharField(max_length=50)),
|
132 |
+
("country", models.CharField(max_length=50)),
|
133 |
+
("pincode", models.IntegerField()),
|
134 |
+
("otp", models.IntegerField()),
|
135 |
+
("rewardPoints", models.IntegerField(default=0)),
|
136 |
+
("isVerified", models.BooleanField(default=False)),
|
137 |
+
("isSubscribed", models.BooleanField(default=False)),
|
138 |
+
("isBlocked", models.BooleanField(default=False)),
|
139 |
+
("isDeleted", models.BooleanField(default=False)),
|
140 |
+
("coupons", models.ManyToManyField(to="authentication.coupon")),
|
141 |
+
(
|
142 |
+
"user",
|
143 |
+
models.ForeignKey(
|
144 |
+
on_delete=django.db.models.deletion.CASCADE,
|
145 |
+
to=settings.AUTH_USER_MODEL,
|
146 |
+
),
|
147 |
+
),
|
148 |
+
],
|
149 |
+
),
|
150 |
+
]
|
authentication/migrations/0002_alter_userdata_coupons_alter_userdata_otp.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-10-24 12:56
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("authentication", "0001_initial"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.AlterField(
|
13 |
+
model_name="userdata",
|
14 |
+
name="coupons",
|
15 |
+
field=models.ManyToManyField(
|
16 |
+
blank=True, related_name="coupons", to="authentication.coupon"
|
17 |
+
),
|
18 |
+
),
|
19 |
+
migrations.AlterField(
|
20 |
+
model_name="userdata",
|
21 |
+
name="otp",
|
22 |
+
field=models.IntegerField(blank=True, null=True),
|
23 |
+
),
|
24 |
+
]
|
authentication/migrations/0003_alter_coupon_expirydate.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-10-24 13:20
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("authentication", "0002_alter_userdata_coupons_alter_userdata_otp"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.AlterField(
|
13 |
+
model_name="coupon",
|
14 |
+
name="expiryDate",
|
15 |
+
field=models.DateTimeField(blank=True, null=True),
|
16 |
+
),
|
17 |
+
]
|
authentication/migrations/0004_coupon_discription.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-10-24 13:53
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("authentication", "0003_alter_coupon_expirydate"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.AddField(
|
13 |
+
model_name="coupon",
|
14 |
+
name="discription",
|
15 |
+
field=models.TextField(default=""),
|
16 |
+
),
|
17 |
+
]
|
authentication/migrations/__pycache__/0001_initial.cpython-39.pyc
ADDED
Binary file (2.59 kB). View file
|
|
authentication/migrations/__pycache__/0002_alter_userdata_coupons_alter_userdata_otp.cpython-39.pyc
ADDED
Binary file (728 Bytes). View file
|
|
authentication/migrations/__pycache__/0003_alter_coupon_expirydate.cpython-39.pyc
ADDED
Binary file (636 Bytes). View file
|
|
authentication/migrations/__pycache__/0004_coupon_discription.cpython-39.pyc
ADDED
Binary file (603 Bytes). View file
|
|
authentication/migrations/__pycache__/__init__.cpython-39.pyc
ADDED
Binary file (155 Bytes). View file
|
|
authentication/models.py
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
# Create your models here.
|
|
|
1 |
from django.db import models
|
2 |
+
import random
|
3 |
+
from django.contrib.auth.models import User
|
4 |
+
import string
|
5 |
+
|
6 |
+
|
7 |
+
class Coupon(models.Model):
|
8 |
+
discount_functions = [(0,"CORE"), (1,"CUSTOMER"), (2,"LOYALTY"), (3,"GIFT_WITH_PURCHASE")]
|
9 |
+
discount_methods = [(0,"POINT_REDEMPTION"), (1,"REDEEMED"), (2,"GIVE_AWAY"), (3,"BONUS_COUPON"), (4,"VOUCHER_GENERIC"), (5,"VOUCHER_LOYALTY"), (6,"VOUCHER_FUEL"), (7,"VOUCHER_THIRDPARTY")]
|
10 |
+
discount_types = [(0,"AMOUNT"), (1,"PERCENT"), (2,"RE_PRICE"), (3,"ALT_PRICE")]
|
11 |
+
how_often_apply = [(0,"ALL_APPLICABLE"), (1,"ONCE_PER_ORDER"), (2,"ONCE_PER_SELECTION")]
|
12 |
+
qualification_types = [(0,"ALL"), (1,"ITEM"), (2,"ORDER")]
|
13 |
+
rewards_types = [(0,"PURCHASES"), (1,"ITEMS"), (2,"VISIT")]
|
14 |
+
|
15 |
+
def randomCouponCode():
|
16 |
+
return ''.join(random.choices(string.ascii_uppercase + string.digits, k=10))
|
17 |
+
|
18 |
+
def randomLoyaltyCode():
|
19 |
+
return ''.join(random.choices(string.digits, k=10))
|
20 |
+
|
21 |
+
name = models.CharField(max_length=50)
|
22 |
+
discription = models.TextField(default="")
|
23 |
+
pointsNeededForRedemption = models.IntegerField()
|
24 |
+
couponCode = models.CharField(max_length=50, default=randomCouponCode)
|
25 |
+
loyaltyCode = models.CharField(max_length=50, default=randomLoyaltyCode)
|
26 |
+
discount = models.IntegerField()
|
27 |
+
isExpired = models.BooleanField(default=False)
|
28 |
+
expiryDate = models.DateTimeField(null=True, blank=True)
|
29 |
+
discountFunction = models.IntegerField(choices=discount_functions, default=2)
|
30 |
+
discountMethod = models.IntegerField(choices=discount_methods, default=0)
|
31 |
+
discountType = models.IntegerField(choices=discount_types, default=0)
|
32 |
+
howOftenApply = models.IntegerField(choices=how_often_apply, default=1)
|
33 |
+
qualificationType = models.IntegerField(choices=qualification_types, default=2)
|
34 |
+
rewardsType = models.IntegerField(choices=rewards_types, default=0)
|
35 |
+
|
36 |
+
def __str__(self):
|
37 |
+
return self.couponCode
|
38 |
+
|
39 |
+
class UserData(models.Model):
|
40 |
+
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
41 |
+
phone = models.CharField(max_length=15)
|
42 |
+
birthDate = models.DateField()
|
43 |
+
gender = models.CharField(max_length=10)
|
44 |
+
streetName = models.CharField(max_length=50)
|
45 |
+
city = models.CharField(max_length=50)
|
46 |
+
state = models.CharField(max_length=50)
|
47 |
+
country = models.CharField(max_length=50)
|
48 |
+
pincode = models.IntegerField()
|
49 |
+
otp = models.IntegerField(null=True, blank=True)
|
50 |
+
rewardPoints = models.IntegerField(default=0)
|
51 |
+
isVerified = models.BooleanField(default=False)
|
52 |
+
isSubscribed = models.BooleanField(default=False)
|
53 |
+
isBlocked = models.BooleanField(default=False)
|
54 |
+
isDeleted = models.BooleanField(default=False)
|
55 |
+
coupons = models.ManyToManyField(Coupon, blank=True, related_name='coupons')
|
56 |
+
|
57 |
+
def __str__(self):
|
58 |
+
return self.user.first_name + " " + self.user.last_name
|
59 |
|
|
authentication/urls.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
from django.urls import path
|
2 |
-
from .views import
|
3 |
|
4 |
urlpatterns = [
|
5 |
path('register/', RegisterView.as_view(), name='register'),
|
6 |
path('login/', LoginView.as_view(), name='login'),
|
|
|
|
|
7 |
path('password-reset/request/', RequestPasswordResetView.as_view(), name='password_reset_request'),
|
8 |
path('password-reset/resend/', ResendOTPView.as_view(), name='password_reset_resend'),
|
9 |
path('password-reset/confirm/', ResetPasswordView.as_view(), name='password_reset_confirm'),
|
|
|
1 |
from django.urls import path
|
2 |
+
from .views import *
|
3 |
|
4 |
urlpatterns = [
|
5 |
path('register/', RegisterView.as_view(), name='register'),
|
6 |
path('login/', LoginView.as_view(), name='login'),
|
7 |
+
path('logout/', LogoutView.as_view(), name='logout'),
|
8 |
+
path('refresh-Token/', refreshTokenView.as_view(), name='refresh_Token'),
|
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'),
|
authentication/views.py
CHANGED
@@ -7,10 +7,12 @@ from rest_framework.views import APIView
|
|
7 |
from django.views.decorators.csrf import csrf_exempt
|
8 |
import json
|
9 |
from rest_framework_simplejwt.tokens import RefreshToken
|
|
|
10 |
from django.core.mail import send_mail
|
11 |
import random
|
12 |
from django.utils import timezone
|
13 |
from datetime import timedelta
|
|
|
14 |
|
15 |
# In-memory storage for OTPs (use a persistent storage in production)
|
16 |
OTP_STORAGE = {}
|
@@ -59,31 +61,69 @@ class RegisterView(APIView):
|
|
59 |
|
60 |
|
61 |
class LoginView(APIView):
|
62 |
-
|
63 |
-
permission_classes = ()
|
64 |
|
65 |
def post(self, request):
|
66 |
try:
|
67 |
data = json.loads(request.body)
|
68 |
username = data.get('username')
|
69 |
password = data.get('password')
|
70 |
-
print(username, password)
|
71 |
|
72 |
user = authenticate(username=username, password=password)
|
73 |
if user is not None:
|
74 |
refresh = RefreshToken.for_user(user)
|
|
|
75 |
userData ={}
|
76 |
userData['email'] = user.email
|
77 |
userData['first_name'] = user.first_name
|
78 |
userData['last_name'] = user.last_name
|
79 |
userData['access'] = str(refresh.access_token)
|
80 |
userData['refresh'] = str(refresh)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
return JsonResponse(userData, status=200)
|
82 |
else:
|
83 |
return JsonResponse({'error': 'Invalid credentials'}, status=401)
|
84 |
except Exception as e:
|
85 |
print(e)
|
86 |
return JsonResponse({'error': str(e)}, status=400)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
|
89 |
class RequestPasswordResetView(APIView):
|
@@ -197,3 +237,15 @@ class ResetPasswordView(APIView):
|
|
197 |
return JsonResponse({'message': 'Password reset successful'}, status=200)
|
198 |
except Exception as e:
|
199 |
return JsonResponse({'error': str(e)}, status=400)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
from django.views.decorators.csrf import csrf_exempt
|
8 |
import json
|
9 |
from rest_framework_simplejwt.tokens import RefreshToken
|
10 |
+
from rest_framework.permissions import IsAuthenticated, AllowAny
|
11 |
from django.core.mail import send_mail
|
12 |
import random
|
13 |
from django.utils import timezone
|
14 |
from datetime import timedelta
|
15 |
+
from .models import UserData
|
16 |
|
17 |
# In-memory storage for OTPs (use a persistent storage in production)
|
18 |
OTP_STORAGE = {}
|
|
|
61 |
|
62 |
|
63 |
class LoginView(APIView):
|
64 |
+
permission_classes = [AllowAny]
|
|
|
65 |
|
66 |
def post(self, request):
|
67 |
try:
|
68 |
data = json.loads(request.body)
|
69 |
username = data.get('username')
|
70 |
password = data.get('password')
|
|
|
71 |
|
72 |
user = authenticate(username=username, password=password)
|
73 |
if user is not None:
|
74 |
refresh = RefreshToken.for_user(user)
|
75 |
+
userDataObj = UserData.objects.get(user=user)
|
76 |
userData ={}
|
77 |
userData['email'] = user.email
|
78 |
userData['first_name'] = user.first_name
|
79 |
userData['last_name'] = user.last_name
|
80 |
userData['access'] = str(refresh.access_token)
|
81 |
userData['refresh'] = str(refresh)
|
82 |
+
userData["phone"] = userDataObj.phone
|
83 |
+
userData["birthDate"] = userDataObj.birthDate
|
84 |
+
userData["gender"] = userDataObj.gender
|
85 |
+
userData["streetName"] = userDataObj.streetName
|
86 |
+
userData["city"] = userDataObj.city
|
87 |
+
userData["state"] = userDataObj.state
|
88 |
+
userData["country"] = userDataObj.country
|
89 |
+
userData["pincode"] = userDataObj.pincode
|
90 |
+
userData["rewardPoints"] = userDataObj.rewardPoints
|
91 |
+
userData["isVerified"] = userDataObj.isVerified
|
92 |
+
userData["isSubscribed"] = userDataObj.isSubscribed
|
93 |
+
userData["isBlocked"] = userDataObj.isBlocked
|
94 |
+
userData["isDeleted"] = userDataObj.isDeleted
|
95 |
return JsonResponse(userData, status=200)
|
96 |
else:
|
97 |
return JsonResponse({'error': 'Invalid credentials'}, status=401)
|
98 |
except Exception as e:
|
99 |
print(e)
|
100 |
return JsonResponse({'error': str(e)}, status=400)
|
101 |
+
|
102 |
+
|
103 |
+
class LogoutView(APIView):
|
104 |
+
permission_classes = [IsAuthenticated]
|
105 |
+
|
106 |
+
def post(self, request):
|
107 |
+
refresh_token = request.data.get('refresh')
|
108 |
+
if not refresh_token:
|
109 |
+
return JsonResponse({
|
110 |
+
'error': 'Refresh token is required',
|
111 |
+
'status': 'error'
|
112 |
+
}, status=400)
|
113 |
+
else:
|
114 |
+
try:
|
115 |
+
refresh = RefreshToken(refresh_token)
|
116 |
+
refresh.blacklist()
|
117 |
+
return JsonResponse({
|
118 |
+
'status': 'success',
|
119 |
+
'message': 'Successfully logged out'
|
120 |
+
})
|
121 |
+
except :
|
122 |
+
return JsonResponse({
|
123 |
+
"error": "Invalid token",
|
124 |
+
"status": "error"
|
125 |
+
}, status=400)
|
126 |
+
|
127 |
|
128 |
|
129 |
class RequestPasswordResetView(APIView):
|
|
|
237 |
return JsonResponse({'message': 'Password reset successful'}, status=200)
|
238 |
except Exception as e:
|
239 |
return JsonResponse({'error': str(e)}, status=400)
|
240 |
+
|
241 |
+
class refreshTokenView(APIView):
|
242 |
+
def post(self, request):
|
243 |
+
try:
|
244 |
+
data = json.loads(request.body)
|
245 |
+
refresh = data.get('refresh')
|
246 |
+
token = RefreshToken(refresh)
|
247 |
+
access = str(token.access_token)
|
248 |
+
return JsonResponse({'access': access}, status=200)
|
249 |
+
except Exception as e:
|
250 |
+
return JsonResponse({'error': str(e)}, status=400)
|
251 |
+
|
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/__pycache__/urls.cpython-311.pyc
CHANGED
Binary files a/oneOone/__pycache__/urls.cpython-311.pyc and b/oneOone/__pycache__/urls.cpython-311.pyc differ
|
|
oneOone/__pycache__/urls.cpython-39.pyc
CHANGED
Binary files a/oneOone/__pycache__/urls.cpython-39.pyc and b/oneOone/__pycache__/urls.cpython-39.pyc differ
|
|
oneOone/settings.py
CHANGED
@@ -1,174 +1,176 @@
|
|
1 |
-
"""
|
2 |
-
Django settings for oneOone project.
|
3 |
-
|
4 |
-
Generated by 'django-admin startproject' using Django 4.2.16.
|
5 |
-
|
6 |
-
For more information on this file, see
|
7 |
-
https://docs.djangoproject.com/en/4.2/topics/settings/
|
8 |
-
|
9 |
-
For the full list of settings and their values, see
|
10 |
-
https://docs.djangoproject.com/en/4.2/ref/settings/
|
11 |
-
"""
|
12 |
-
|
13 |
-
from datetime import timedelta
|
14 |
-
from pathlib import Path
|
15 |
-
|
16 |
-
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
17 |
-
BASE_DIR = Path(__file__).resolve().parent.parent
|
18 |
-
|
19 |
-
|
20 |
-
# Quick-start development settings - unsuitable for production
|
21 |
-
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
22 |
-
|
23 |
-
# SECURITY WARNING: keep the secret key used in production secret!
|
24 |
-
SECRET_KEY = "django-insecure-8&2s2s)--3hof($4+pkt0@$l1tz8so+$t=%yq9y0on=s$2_^$p"
|
25 |
-
|
26 |
-
# SECURITY WARNING: don't run with debug turned on in production!
|
27 |
-
DEBUG = True
|
28 |
-
|
29 |
-
ALLOWED_HOSTS = ["*", "127.0.0.1", "192.168.81.1", "192.168.12.61", "thejagstudio-101.hf.space"]
|
30 |
-
CORS_ALLOWED_ORIGINS = [
|
31 |
-
"http://localhost:8081",
|
32 |
-
"http://localhost:19006",
|
33 |
-
"http://192.168.81.1:8000",
|
34 |
-
"http://192.168.12.61:8000",
|
35 |
-
"https://s4t6xdgk-8000.inc1.devtunnels.ms",
|
36 |
-
"http://thejagstudio-101.hf.space",
|
37 |
-
"https://thejagstudio-101.hf.space"
|
38 |
-
]
|
39 |
-
CSRF_TRUSTED_ORIGINS = [
|
40 |
-
"http://localhost:8081",
|
41 |
-
"http://192.168.81.1:8000",
|
42 |
-
"http://192.168.12.61:8000",
|
43 |
-
"http://localhost:19006",
|
44 |
-
"https://s4t6xdgk-8000.inc1.devtunnels.ms",
|
45 |
-
"http://thejagstudio-101.hf.space",
|
46 |
-
"https://thejagstudio-101.hf.space"
|
47 |
-
]
|
48 |
-
|
49 |
-
# Application definition
|
50 |
-
|
51 |
-
INSTALLED_APPS = [
|
52 |
-
"django.contrib.admin",
|
53 |
-
"django.contrib.auth",
|
54 |
-
"django.contrib.contenttypes",
|
55 |
-
"django.contrib.sessions",
|
56 |
-
"django.contrib.messages",
|
57 |
-
"django.contrib.staticfiles",
|
58 |
-
"rest_framework",
|
59 |
-
"rest_framework_simplejwt",
|
60 |
-
"
|
61 |
-
"
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
"
|
68 |
-
"django.middleware.
|
69 |
-
"
|
70 |
-
"django.
|
71 |
-
"django.
|
72 |
-
"django.middleware.
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
"
|
82 |
-
"
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
"django.
|
87 |
-
"django.
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
'
|
104 |
-
'
|
105 |
-
'
|
106 |
-
'
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
#
|
112 |
-
#
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
'
|
170 |
-
'
|
171 |
-
'
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Django settings for oneOone project.
|
3 |
+
|
4 |
+
Generated by 'django-admin startproject' using Django 4.2.16.
|
5 |
+
|
6 |
+
For more information on this file, see
|
7 |
+
https://docs.djangoproject.com/en/4.2/topics/settings/
|
8 |
+
|
9 |
+
For the full list of settings and their values, see
|
10 |
+
https://docs.djangoproject.com/en/4.2/ref/settings/
|
11 |
+
"""
|
12 |
+
|
13 |
+
from datetime import timedelta
|
14 |
+
from pathlib import Path
|
15 |
+
|
16 |
+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
17 |
+
BASE_DIR = Path(__file__).resolve().parent.parent
|
18 |
+
|
19 |
+
|
20 |
+
# Quick-start development settings - unsuitable for production
|
21 |
+
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
22 |
+
|
23 |
+
# SECURITY WARNING: keep the secret key used in production secret!
|
24 |
+
SECRET_KEY = "django-insecure-8&2s2s)--3hof($4+pkt0@$l1tz8so+$t=%yq9y0on=s$2_^$p"
|
25 |
+
|
26 |
+
# SECURITY WARNING: don't run with debug turned on in production!
|
27 |
+
DEBUG = True
|
28 |
+
|
29 |
+
ALLOWED_HOSTS = ["*", "127.0.0.1", "192.168.81.1", "192.168.12.61", "thejagstudio-101.hf.space"]
|
30 |
+
CORS_ALLOWED_ORIGINS = [
|
31 |
+
"http://localhost:8081",
|
32 |
+
"http://localhost:19006",
|
33 |
+
"http://192.168.81.1:8000",
|
34 |
+
"http://192.168.12.61:8000",
|
35 |
+
"https://s4t6xdgk-8000.inc1.devtunnels.ms",
|
36 |
+
"http://thejagstudio-101.hf.space",
|
37 |
+
"https://thejagstudio-101.hf.space"
|
38 |
+
]
|
39 |
+
CSRF_TRUSTED_ORIGINS = [
|
40 |
+
"http://localhost:8081",
|
41 |
+
"http://192.168.81.1:8000",
|
42 |
+
"http://192.168.12.61:8000",
|
43 |
+
"http://localhost:19006",
|
44 |
+
"https://s4t6xdgk-8000.inc1.devtunnels.ms",
|
45 |
+
"http://thejagstudio-101.hf.space",
|
46 |
+
"https://thejagstudio-101.hf.space"
|
47 |
+
]
|
48 |
+
|
49 |
+
# Application definition
|
50 |
+
|
51 |
+
INSTALLED_APPS = [
|
52 |
+
"django.contrib.admin",
|
53 |
+
"django.contrib.auth",
|
54 |
+
"django.contrib.contenttypes",
|
55 |
+
"django.contrib.sessions",
|
56 |
+
"django.contrib.messages",
|
57 |
+
"django.contrib.staticfiles",
|
58 |
+
"rest_framework",
|
59 |
+
"rest_framework_simplejwt",
|
60 |
+
"rest_framework_simplejwt.token_blacklist",
|
61 |
+
"import_export",
|
62 |
+
"corsheaders",
|
63 |
+
"authentication"
|
64 |
+
]
|
65 |
+
|
66 |
+
MIDDLEWARE = [
|
67 |
+
"django.middleware.security.SecurityMiddleware",
|
68 |
+
"django.contrib.sessions.middleware.SessionMiddleware",
|
69 |
+
"corsheaders.middleware.CorsMiddleware",
|
70 |
+
"django.middleware.common.CommonMiddleware",
|
71 |
+
"django.middleware.csrf.CsrfViewMiddleware",
|
72 |
+
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
73 |
+
"django.contrib.messages.middleware.MessageMiddleware",
|
74 |
+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
75 |
+
]
|
76 |
+
|
77 |
+
ROOT_URLCONF = "oneOone.urls"
|
78 |
+
|
79 |
+
TEMPLATES = [
|
80 |
+
{
|
81 |
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
82 |
+
"DIRS": [],
|
83 |
+
"APP_DIRS": True,
|
84 |
+
"OPTIONS": {
|
85 |
+
"context_processors": [
|
86 |
+
"django.template.context_processors.debug",
|
87 |
+
"django.template.context_processors.request",
|
88 |
+
"django.contrib.auth.context_processors.auth",
|
89 |
+
"django.contrib.messages.context_processors.messages",
|
90 |
+
],
|
91 |
+
},
|
92 |
+
},
|
93 |
+
]
|
94 |
+
|
95 |
+
WSGI_APPLICATION = "oneOone.wsgi.application"
|
96 |
+
|
97 |
+
|
98 |
+
# Database
|
99 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
100 |
+
|
101 |
+
DATABASES = {
|
102 |
+
'default': {
|
103 |
+
'ENGINE': 'django.db.backends.postgresql',
|
104 |
+
'NAME': 'postgres',
|
105 |
+
'USER': 'postgres.psjobjezrtkjvenhsmge',
|
106 |
+
'PORT': 6543,
|
107 |
+
'PASSWORD': 'ErO9vgKcwCA1bdah',
|
108 |
+
'HOST': 'aws-0-us-east-1.pooler.supabase.com',
|
109 |
+
}
|
110 |
+
}
|
111 |
+
# "default": {
|
112 |
+
# "ENGINE": "django.db.backends.sqlite3",
|
113 |
+
# "NAME": BASE_DIR / "db.sqlite3",
|
114 |
+
# }
|
115 |
+
|
116 |
+
|
117 |
+
# Password validation
|
118 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
|
119 |
+
|
120 |
+
AUTH_PASSWORD_VALIDATORS = [
|
121 |
+
{
|
122 |
+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
|
123 |
+
},
|
124 |
+
{
|
125 |
+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
|
126 |
+
},
|
127 |
+
{
|
128 |
+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
|
129 |
+
},
|
130 |
+
{
|
131 |
+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
132 |
+
},
|
133 |
+
]
|
134 |
+
|
135 |
+
|
136 |
+
# Internationalization
|
137 |
+
# https://docs.djangoproject.com/en/4.2/topics/i18n/
|
138 |
+
|
139 |
+
LANGUAGE_CODE = "en-us"
|
140 |
+
|
141 |
+
TIME_ZONE = "UTC"
|
142 |
+
|
143 |
+
USE_I18N = True
|
144 |
+
|
145 |
+
USE_TZ = True
|
146 |
+
|
147 |
+
|
148 |
+
# Static files (CSS, JavaScript, Images)
|
149 |
+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
|
150 |
+
|
151 |
+
STATIC_URL = "static/"
|
152 |
+
|
153 |
+
# Default primary key field type
|
154 |
+
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
155 |
+
|
156 |
+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
157 |
+
|
158 |
+
REST_FRAMEWORK = {
|
159 |
+
'DEFAULT_AUTHENTICATION_CLASSES': (
|
160 |
+
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
161 |
+
),
|
162 |
+
'DEFAULT_PERMISSION_CLASSES': (
|
163 |
+
'rest_framework.permissions.AllowAny',
|
164 |
+
),
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
+
SIMPLE_JWT = {
|
169 |
+
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=60),
|
170 |
+
'REFRESH_TOKEN_LIFETIME': timedelta(days=60),
|
171 |
+
'ROTATE_REFRESH_TOKENS': True,
|
172 |
+
'BLACKLIST_AFTER_ROTATION': True,
|
173 |
+
'UPDATE_LAST_LOGIN': True,
|
174 |
+
}
|
175 |
+
|
176 |
+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
oneOone/urls.py
CHANGED
@@ -1,27 +1,7 @@
|
|
1 |
from django.urls import path, include
|
2 |
from django.contrib import admin
|
3 |
from django.contrib.auth.models import User
|
4 |
-
from rest_framework import routers, serializers, viewsets
|
5 |
|
6 |
-
# Serializers define the API representation.
|
7 |
-
|
8 |
-
|
9 |
-
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
10 |
-
class Meta:
|
11 |
-
model = User
|
12 |
-
fields = ['url', 'username', 'email', 'is_staff']
|
13 |
-
|
14 |
-
# ViewSets define the view behavior.
|
15 |
-
|
16 |
-
|
17 |
-
class UserViewSet(viewsets.ModelViewSet):
|
18 |
-
queryset = User.objects.all()
|
19 |
-
serializer_class = UserSerializer
|
20 |
-
|
21 |
-
|
22 |
-
# Routers provide an easy way of automatically determining the URL conf.
|
23 |
-
router = routers.DefaultRouter()
|
24 |
-
router.register(r'users', UserViewSet)
|
25 |
|
26 |
urlpatterns = [
|
27 |
path("admin/", admin.site.urls),
|
|
|
1 |
from django.urls import path, include
|
2 |
from django.contrib import admin
|
3 |
from django.contrib.auth.models import User
|
|
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
urlpatterns = [
|
7 |
path("admin/", admin.site.urls),
|