thejagstudio commited on
Commit
7c53168
1 Parent(s): 889a906

Upload 39 files

Browse files
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/__init__.py ADDED
File without changes
api/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (133 Bytes). View file
 
api/__pycache__/urls.cpython-39.pyc ADDED
Binary file (471 Bytes). View file
 
api/__pycache__/views.cpython-39.pyc ADDED
Binary file (1.92 kB). View file
 
api/admin.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.contrib import admin
2
+
3
+ # Register your models here.
api/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class ApiConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "api"
api/migrations/__init__.py ADDED
File without changes
api/models.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.db import models
2
+
3
+ # Create your models here.
api/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
api/urls.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ from django.urls import path
2
+ from . import views
3
+
4
+ urlpatterns = [
5
+ path('', views.home, name='home'),
6
+ path('establishments', views.establishment_List, name='establishment_List'),
7
+ path('resources-forward/<str:resource_name>/<str:image_id>', views.resources_forward, name='resources_forward'),
8
+ path('product-category', views.product_category, name='product_category'),
9
+ ]
api/views.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render
2
+ 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
+ def establishment_List(request):
15
+ global authToken
16
+ url = "https://101smokeshop-uat.revelup.com/enterprise/Establishment/?order_by=id&limit=10&offset=0"
17
+ headers = {
18
+ 'API-AUTHENTICATION': authToken
19
+ }
20
+ response = requests.request("GET", url, headers=headers)
21
+ data = response.json()["objects"]
22
+ urlBase = "https://101smokeshop-uat.revelup.com"
23
+ for i in range(len(data)):
24
+ try:
25
+ imgData = requests.request("GET", urlBase+data[i]["logo_img"], headers=headers).json()
26
+ print(imgData)
27
+ data[i]["logo_img"] = imgData["image_url"]
28
+ except:
29
+ pass
30
+ try:
31
+ data[i]["address"] = requests.request("GET", urlBase+data[i]["address"], headers=headers).json()
32
+ except:
33
+ pass
34
+ return JsonResponse({"data": data})
35
+
36
+
37
+ def resources_forward(request, resource_name,image_id):
38
+ url = "https://101smokeshop-uat.revelup.com/resources/"+resource_name+"/"+image_id
39
+ headers = {
40
+ 'API-AUTHENTICATION': authToken
41
+ }
42
+ response = requests.request("GET", url, headers=headers)
43
+ imageUrl = response.json()["image_url"]
44
+ response = requests.request("GET", imageUrl)
45
+ return HttpResponse(response.content, content_type=response.headers['Content-Type'])
46
+
47
+ def product_category(request):
48
+ global authToken
49
+ url = "https://101smokeshop-uat.revelup.com/products/ProductCategory/"
50
+ headers = {
51
+ 'API-AUTHENTICATION': authToken
52
+ }
53
+ response = requests.request("GET", url, headers=headers)
54
+ data = response.json()["objects"]
55
+ return JsonResponse({"data": data})
authentication/__init__.py ADDED
File without changes
authentication/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (147 Bytes). View file
 
authentication/__pycache__/urls.cpython-39.pyc ADDED
Binary file (644 Bytes). View file
 
authentication/__pycache__/views.cpython-39.pyc ADDED
Binary file (5.14 kB). View file
 
authentication/admin.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.contrib import admin
2
+
3
+ # Register your models here.
authentication/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class AuthenticationConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "authentication"
authentication/migrations/__init__.py ADDED
File without changes
authentication/models.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.db import models
2
+
3
+ # Create your models here.
authentication/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
authentication/urls.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.urls import path
2
+ from .views import RegisterView, LoginView, RequestPasswordResetView, ResendOTPView, ResetPasswordView
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'),
10
+ ]
authentication/views.py ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # authentication/views.py
2
+
3
+ from django.contrib.auth.models import User
4
+ from django.contrib.auth import authenticate
5
+ from django.http import JsonResponse
6
+ 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 = {}
17
+
18
+
19
+ class RegisterView(APIView):
20
+ authentication_classes = ()
21
+ permission_classes = () # Allow any
22
+
23
+ def post(self, request):
24
+ try:
25
+ data = json.loads(request.body)
26
+ email = data.get('email')
27
+ password = data.get('password')
28
+ first_name = data.get('first_name')
29
+ last_name = data.get('last_name')
30
+
31
+ if User.objects.filter(email=email).exists():
32
+ return JsonResponse({'error': 'Email already exists'}, status=400)
33
+
34
+ user = User.objects.create_user(
35
+ username=email,
36
+ email=email,
37
+ password=password,
38
+ first_name=first_name,
39
+ last_name=last_name
40
+ )
41
+ user.save()
42
+ otp = random.randint(100000, 999999)
43
+ OTP_STORAGE[email] = {
44
+ 'otp': otp,
45
+ 'expires_at': timezone.now() + timedelta(minutes=10) # OTP valid for 10 minutes
46
+ }
47
+ print(otp)
48
+ # Send OTP via email
49
+ send_mail(
50
+ 'Password Reset OTP',
51
+ f'Your OTP for password reset is {otp}',
52
+ 'noreply@example.com', # Replace with your email
53
+ [email],
54
+ fail_silently=False,
55
+ )
56
+ return JsonResponse({'message': 'User registered successfully'}, status=201)
57
+ except Exception as e:
58
+ return JsonResponse({'error': str(e)}, status=400)
59
+
60
+
61
+ class LoginView(APIView):
62
+ authentication_classes = ()
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):
90
+ authentication_classes = ()
91
+ permission_classes = () # Allow any
92
+
93
+ def post(self, request):
94
+ try:
95
+ data = json.loads(request.body)
96
+ email = data.get('email')
97
+ if not email:
98
+ return JsonResponse({'error': 'Email is required'}, status=400)
99
+ try:
100
+ user = User.objects.get(email=email)
101
+ except User.DoesNotExist:
102
+ return JsonResponse({'error': 'User with this email does not exist'}, status=400)
103
+
104
+ # Generate OTP
105
+ otp = random.randint(100000, 999999)
106
+ OTP_STORAGE[email] = {
107
+ 'otp': otp,
108
+ 'expires_at': timezone.now() + timedelta(minutes=10) # OTP valid for 10 minutes
109
+ }
110
+ print(otp)
111
+ # Send OTP via email
112
+ send_mail(
113
+ 'Password Reset OTP',
114
+ f'Your OTP for password reset is {otp}',
115
+ 'noreply@example.com', # Replace with your email
116
+ [email],
117
+ fail_silently=False,
118
+ )
119
+
120
+ return JsonResponse({'message': 'OTP sent to email'}, status=200)
121
+ except Exception as e:
122
+ return JsonResponse({'error': str(e)}, status=400)
123
+
124
+
125
+ class ResendOTPView(APIView):
126
+ authentication_classes = ()
127
+ permission_classes = () # Allow any
128
+
129
+ def post(self, request):
130
+ try:
131
+ data = json.loads(request.body)
132
+ email = data.get('email')
133
+ if not email:
134
+ return JsonResponse({'error': 'Email is required'}, status=400)
135
+ try:
136
+ user = User.objects.get(email=email)
137
+ except User.DoesNotExist:
138
+ return JsonResponse({'error': 'User with this email does not exist'}, status=400)
139
+
140
+ # Generate new OTP
141
+ otp = random.randint(100000, 999999)
142
+ OTP_STORAGE[email] = {
143
+ 'otp': otp,
144
+ 'expires_at': timezone.now() + timedelta(minutes=10) # OTP valid for 10 minutes
145
+ }
146
+ print(otp)
147
+ # Send OTP via email
148
+ send_mail(
149
+ 'Password Reset OTP',
150
+ f'Your new OTP for password reset is {otp}',
151
+ 'noreply@example.com', # Replace with your email
152
+ [email],
153
+ fail_silently=False,
154
+ )
155
+
156
+ return JsonResponse({'message': 'OTP resent to email'}, status=200)
157
+ except Exception as e:
158
+ return JsonResponse({'error': str(e)}, status=400)
159
+
160
+
161
+ class ResetPasswordView(APIView):
162
+ authentication_classes = ()
163
+ permission_classes = () # Allow any
164
+
165
+ def post(self, request):
166
+ try:
167
+ data = json.loads(request.body)
168
+ email = data.get('email')
169
+ otp = data.get('otp')
170
+ new_password = data.get('new_password')
171
+
172
+ if not all([email, otp, new_password]):
173
+ return JsonResponse({'error': 'All fields are required'}, status=400)
174
+
175
+ otp_record = OTP_STORAGE.get(email)
176
+ if not otp_record:
177
+ return JsonResponse({'error': 'OTP not found. Please request a new one.'}, status=400)
178
+
179
+ if timezone.now() > otp_record['expires_at']:
180
+ del OTP_STORAGE[email]
181
+ return JsonResponse({'error': 'OTP has expired. Please request a new one.'}, status=400)
182
+
183
+ if int(otp) != otp_record['otp']:
184
+ return JsonResponse({'error': 'Invalid OTP'}, status=400)
185
+
186
+ try:
187
+ user = User.objects.get(email=email)
188
+ except User.DoesNotExist:
189
+ return JsonResponse({'error': 'User with this email does not exist'}, status=400)
190
+
191
+ user.set_password(new_password)
192
+ user.save()
193
+
194
+ # Remove OTP after successful reset
195
+ del OTP_STORAGE[email]
196
+
197
+ return JsonResponse({'message': 'Password reset successful'}, status=200)
198
+ except Exception as e:
199
+ return JsonResponse({'error': str(e)}, status=400)
data.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [{"model": "admin.logentry", "pk": 1, "fields": {"action_time": "2024-10-15T16:53:16.187Z", "user": 1, "content_type": 11, "object_id": "1", "object_repr": "Jagrat Patel", "action_flag": 1, "change_message": "[{\"added\": {}}]"}}, {"model": "admin.logentry", "pk": 2, "fields": {"action_time": "2024-10-15T17:29:01.388Z", "user": 1, "content_type": 4, "object_id": "1", "object_repr": "thejagstudio@gmail.com", "action_flag": 2, "change_message": "[{\"changed\": {\"fields\": [\"password\"]}}]"}}, {"model": "admin.logentry", "pk": 3, "fields": {"action_time": "2024-10-15T17:30:11.229Z", "user": 1, "content_type": 4, "object_id": "1", "object_repr": "thejagstudio@gmail.com", "action_flag": 2, "change_message": "[{\"changed\": {\"fields\": [\"First name\", \"Last name\"]}}]"}}, {"model": "auth.permission", "pk": 1, "fields": {"name": "Can add log entry", "content_type": 1, "codename": "add_logentry"}}, {"model": "auth.permission", "pk": 2, "fields": {"name": "Can change log entry", "content_type": 1, "codename": "change_logentry"}}, {"model": "auth.permission", "pk": 3, "fields": {"name": "Can delete log entry", "content_type": 1, "codename": "delete_logentry"}}, {"model": "auth.permission", "pk": 4, "fields": {"name": "Can view log entry", "content_type": 1, "codename": "view_logentry"}}, {"model": "auth.permission", "pk": 5, "fields": {"name": "Can add permission", "content_type": 2, "codename": "add_permission"}}, {"model": "auth.permission", "pk": 6, "fields": {"name": "Can change permission", "content_type": 2, "codename": "change_permission"}}, {"model": "auth.permission", "pk": 7, "fields": {"name": "Can delete permission", "content_type": 2, "codename": "delete_permission"}}, {"model": "auth.permission", "pk": 8, "fields": {"name": "Can view permission", "content_type": 2, "codename": "view_permission"}}, {"model": "auth.permission", "pk": 9, "fields": {"name": "Can add group", "content_type": 3, "codename": "add_group"}}, {"model": "auth.permission", "pk": 10, "fields": {"name": "Can change group", "content_type": 3, "codename": "change_group"}}, {"model": "auth.permission", "pk": 11, "fields": {"name": "Can delete group", "content_type": 3, "codename": "delete_group"}}, {"model": "auth.permission", "pk": 12, "fields": {"name": "Can view group", "content_type": 3, "codename": "view_group"}}, {"model": "auth.permission", "pk": 13, "fields": {"name": "Can add user", "content_type": 4, "codename": "add_user"}}, {"model": "auth.permission", "pk": 14, "fields": {"name": "Can change user", "content_type": 4, "codename": "change_user"}}, {"model": "auth.permission", "pk": 15, "fields": {"name": "Can delete user", "content_type": 4, "codename": "delete_user"}}, {"model": "auth.permission", "pk": 16, "fields": {"name": "Can view user", "content_type": 4, "codename": "view_user"}}, {"model": "auth.permission", "pk": 17, "fields": {"name": "Can add content type", "content_type": 5, "codename": "add_contenttype"}}, {"model": "auth.permission", "pk": 18, "fields": {"name": "Can change content type", "content_type": 5, "codename": "change_contenttype"}}, {"model": "auth.permission", "pk": 19, "fields": {"name": "Can delete content type", "content_type": 5, "codename": "delete_contenttype"}}, {"model": "auth.permission", "pk": 20, "fields": {"name": "Can view content type", "content_type": 5, "codename": "view_contenttype"}}, {"model": "auth.permission", "pk": 21, "fields": {"name": "Can add session", "content_type": 6, "codename": "add_session"}}, {"model": "auth.permission", "pk": 22, "fields": {"name": "Can change session", "content_type": 6, "codename": "change_session"}}, {"model": "auth.permission", "pk": 23, "fields": {"name": "Can delete session", "content_type": 6, "codename": "delete_session"}}, {"model": "auth.permission", "pk": 24, "fields": {"name": "Can view session", "content_type": 6, "codename": "view_session"}}, {"model": "auth.permission", "pk": 25, "fields": {"name": "Can add category", "content_type": 7, "codename": "add_category"}}, {"model": "auth.permission", "pk": 26, "fields": {"name": "Can change category", "content_type": 7, "codename": "change_category"}}, {"model": "auth.permission", "pk": 27, "fields": {"name": "Can delete category", "content_type": 7, "codename": "delete_category"}}, {"model": "auth.permission", "pk": 28, "fields": {"name": "Can view category", "content_type": 7, "codename": "view_category"}}, {"model": "auth.permission", "pk": 29, "fields": {"name": "Can add product", "content_type": 8, "codename": "add_product"}}, {"model": "auth.permission", "pk": 30, "fields": {"name": "Can change product", "content_type": 8, "codename": "change_product"}}, {"model": "auth.permission", "pk": 31, "fields": {"name": "Can delete product", "content_type": 8, "codename": "delete_product"}}, {"model": "auth.permission", "pk": 32, "fields": {"name": "Can view product", "content_type": 8, "codename": "view_product"}}, {"model": "auth.permission", "pk": 33, "fields": {"name": "Can add revel establishment", "content_type": 9, "codename": "add_revelestablishment"}}, {"model": "auth.permission", "pk": 34, "fields": {"name": "Can change revel establishment", "content_type": 9, "codename": "change_revelestablishment"}}, {"model": "auth.permission", "pk": 35, "fields": {"name": "Can delete revel establishment", "content_type": 9, "codename": "delete_revelestablishment"}}, {"model": "auth.permission", "pk": 36, "fields": {"name": "Can view revel establishment", "content_type": 9, "codename": "view_revelestablishment"}}, {"model": "auth.permission", "pk": 37, "fields": {"name": "Can add revel product category", "content_type": 10, "codename": "add_revelproductcategory"}}, {"model": "auth.permission", "pk": 38, "fields": {"name": "Can change revel product category", "content_type": 10, "codename": "change_revelproductcategory"}}, {"model": "auth.permission", "pk": 39, "fields": {"name": "Can delete revel product category", "content_type": 10, "codename": "delete_revelproductcategory"}}, {"model": "auth.permission", "pk": 40, "fields": {"name": "Can view revel product category", "content_type": 10, "codename": "view_revelproductcategory"}}, {"model": "auth.permission", "pk": 41, "fields": {"name": "Can add revel user", "content_type": 11, "codename": "add_reveluser"}}, {"model": "auth.permission", "pk": 42, "fields": {"name": "Can change revel user", "content_type": 11, "codename": "change_reveluser"}}, {"model": "auth.permission", "pk": 43, "fields": {"name": "Can delete revel user", "content_type": 11, "codename": "delete_reveluser"}}, {"model": "auth.permission", "pk": 44, "fields": {"name": "Can view revel user", "content_type": 11, "codename": "view_reveluser"}}, {"model": "auth.permission", "pk": 45, "fields": {"name": "Can add reward", "content_type": 12, "codename": "add_reward"}}, {"model": "auth.permission", "pk": 46, "fields": {"name": "Can change reward", "content_type": 12, "codename": "change_reward"}}, {"model": "auth.permission", "pk": 47, "fields": {"name": "Can delete reward", "content_type": 12, "codename": "delete_reward"}}, {"model": "auth.permission", "pk": 48, "fields": {"name": "Can view reward", "content_type": 12, "codename": "view_reward"}}, {"model": "auth.permission", "pk": 49, "fields": {"name": "Can add voucher", "content_type": 13, "codename": "add_voucher"}}, {"model": "auth.permission", "pk": 50, "fields": {"name": "Can change voucher", "content_type": 13, "codename": "change_voucher"}}, {"model": "auth.permission", "pk": 51, "fields": {"name": "Can delete voucher", "content_type": 13, "codename": "delete_voucher"}}, {"model": "auth.permission", "pk": 52, "fields": {"name": "Can view voucher", "content_type": 13, "codename": "view_voucher"}}, {"model": "auth.permission", "pk": 53, "fields": {"name": "Can add transaction", "content_type": 14, "codename": "add_transaction"}}, {"model": "auth.permission", "pk": 54, "fields": {"name": "Can change transaction", "content_type": 14, "codename": "change_transaction"}}, {"model": "auth.permission", "pk": 55, "fields": {"name": "Can delete transaction", "content_type": 14, "codename": "delete_transaction"}}, {"model": "auth.permission", "pk": 56, "fields": {"name": "Can view transaction", "content_type": 14, "codename": "view_transaction"}}, {"model": "auth.permission", "pk": 57, "fields": {"name": "Can add revel inventory", "content_type": 15, "codename": "add_revelinventory"}}, {"model": "auth.permission", "pk": 58, "fields": {"name": "Can change revel inventory", "content_type": 15, "codename": "change_revelinventory"}}, {"model": "auth.permission", "pk": 59, "fields": {"name": "Can delete revel inventory", "content_type": 15, "codename": "delete_revelinventory"}}, {"model": "auth.permission", "pk": 60, "fields": {"name": "Can view revel inventory", "content_type": 15, "codename": "view_revelinventory"}}, {"model": "auth.permission", "pk": 61, "fields": {"name": "Can add cart", "content_type": 16, "codename": "add_cart"}}, {"model": "auth.permission", "pk": 62, "fields": {"name": "Can change cart", "content_type": 16, "codename": "change_cart"}}, {"model": "auth.permission", "pk": 63, "fields": {"name": "Can delete cart", "content_type": 16, "codename": "delete_cart"}}, {"model": "auth.permission", "pk": 64, "fields": {"name": "Can view cart", "content_type": 16, "codename": "view_cart"}}, {"model": "auth.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$600000$v2VLP6IFmEVfyexsZmuKVe$NCLz6kv77gvxOaxP/4oaL7do9t0JtwI/nKclP/Vg7Dc=", "last_login": "2024-10-08T15:10:40Z", "is_superuser": true, "username": "thejagstudio@gmail.com", "first_name": "Jagrat", "last_name": "Patel", "email": "thejagstudio@gmail.com", "is_staff": true, "is_active": true, "date_joined": "2024-10-08T15:10:28Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 2, "fields": {"password": "pbkdf2_sha256$600000$pFXWfOnCXOfPzEf5Kmjl1x$TbVFmWd0I+KNnZ3i702kyKrUg2oc/4Pp4G7y55wuvZI=", "last_login": null, "is_superuser": false, "username": "dfafdfaf@gmail.com", "first_name": "asfasfasf", "last_name": "asfsafasf", "email": "dfafdfaf@gmail.com", "is_staff": false, "is_active": true, "date_joined": "2024-10-08T16:20:59.397Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 3, "fields": {"password": "pbkdf2_sha256$600000$syMS5tGBvO3aw7bYAZ7Pth$MCLslfEHzeNDJOOeFStzta9Nwoh1Nhitx7j/y5tWWwQ=", "last_login": null, "is_superuser": false, "username": "dfcsscsafdfaf@gmail.com", "first_name": "asfasfasf", "last_name": "asfsafasf", "email": "dfcsscsafdfaf@gmail.com", "is_staff": false, "is_active": true, "date_joined": "2024-10-08T16:22:27.237Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 4, "fields": {"password": "pbkdf2_sha256$600000$eLlV3iUnCYbFebfd6JDJ3E$+RbiPMiJhe3RAllYojtKP+zrpxzOv2r3rA4QUW7DhIY=", "last_login": null, "is_superuser": false, "username": "Shshsh@gamil.com", "first_name": "Zhzjzj", "last_name": "Hhshs", "email": "Shshsh@gamil.com", "is_staff": false, "is_active": true, "date_joined": "2024-10-08T16:50:24.258Z", "groups": [], "user_permissions": []}}, {"model": "auth.user", "pk": 5, "fields": {"password": "pbkdf2_sha256$600000$qxvgAfZ3Y9m3IZ3zDpTw0h$8KKIaVIheUgSef115VuKqdkGN+Oh3BR1Dz4Rm0VWxh4=", "last_login": null, "is_superuser": false, "username": "Cbbcvds@gamil.com", "first_name": "Zhzjzj", "last_name": "Hhshs", "email": "Cbbcvds@gamil.com", "is_staff": false, "is_active": true, "date_joined": "2024-10-08T16:52:24.521Z", "groups": [], "user_permissions": []}}, {"model": "contenttypes.contenttype", "pk": 1, "fields": {"app_label": "admin", "model": "logentry"}}, {"model": "contenttypes.contenttype", "pk": 2, "fields": {"app_label": "auth", "model": "permission"}}, {"model": "contenttypes.contenttype", "pk": 3, "fields": {"app_label": "auth", "model": "group"}}, {"model": "contenttypes.contenttype", "pk": 4, "fields": {"app_label": "auth", "model": "user"}}, {"model": "contenttypes.contenttype", "pk": 5, "fields": {"app_label": "contenttypes", "model": "contenttype"}}, {"model": "contenttypes.contenttype", "pk": 6, "fields": {"app_label": "sessions", "model": "session"}}, {"model": "contenttypes.contenttype", "pk": 7, "fields": {"app_label": "products", "model": "category"}}, {"model": "contenttypes.contenttype", "pk": 8, "fields": {"app_label": "products", "model": "product"}}, {"model": "contenttypes.contenttype", "pk": 9, "fields": {"app_label": "products", "model": "revelestablishment"}}, {"model": "contenttypes.contenttype", "pk": 10, "fields": {"app_label": "products", "model": "revelproductcategory"}}, {"model": "contenttypes.contenttype", "pk": 11, "fields": {"app_label": "products", "model": "reveluser"}}, {"model": "contenttypes.contenttype", "pk": 12, "fields": {"app_label": "products", "model": "reward"}}, {"model": "contenttypes.contenttype", "pk": 13, "fields": {"app_label": "products", "model": "voucher"}}, {"model": "contenttypes.contenttype", "pk": 14, "fields": {"app_label": "products", "model": "transaction"}}, {"model": "contenttypes.contenttype", "pk": 15, "fields": {"app_label": "products", "model": "revelinventory"}}, {"model": "contenttypes.contenttype", "pk": 16, "fields": {"app_label": "products", "model": "cart"}}, {"model": "sessions.session", "pk": "oqrfu8qrto22qjoig1wwabclziccxuz0", "fields": {"session_data": ".eJxVjMEOwiAQRP-FsyHQBSEevfsNZNkFqRpISnsy_rs06UGP8-bNvEXAbS1h62kJM4uL0OL0yyLSM9W94AfWe5PU6rrMUe6KPNoub43T63q4fwcFexlr4zU4ss4ozjYBcI7gogEg4pHQK0qKJwtnskbZODE70j4PmA2jE58v4NY4UQ:1t0lLx:w8Itfv6-uLHlhxKamJTP_gBsPcquJToQUPhLU7-UFZ0", "expire_date": "2024-10-29T17:29:01.604Z"}}]
manage.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
3
+ import os
4
+ import sys
5
+
6
+
7
+ def main():
8
+ """Run administrative tasks."""
9
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "oneOone.settings")
10
+ try:
11
+ from django.core.management import execute_from_command_line
12
+ except ImportError as exc:
13
+ raise ImportError(
14
+ "Couldn't import Django. Are you sure it's installed and "
15
+ "available on your PYTHONPATH environment variable? Did you "
16
+ "forget to activate a virtual environment?"
17
+ ) from exc
18
+ execute_from_command_line(sys.argv)
19
+
20
+
21
+ if __name__ == "__main__":
22
+ main()
oneOone/__init__.py ADDED
File without changes
oneOone/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (155 Bytes). View file
 
oneOone/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (140 Bytes). View file
 
oneOone/__pycache__/settings.cpython-311.pyc ADDED
Binary file (3.63 kB). View file
 
oneOone/__pycache__/settings.cpython-39.pyc ADDED
Binary file (3.29 kB). View file
 
oneOone/__pycache__/urls.cpython-311.pyc ADDED
Binary file (1.95 kB). View file
 
oneOone/__pycache__/urls.cpython-39.pyc ADDED
Binary file (1.24 kB). View file
 
oneOone/__pycache__/wsgi.cpython-39.pyc ADDED
Binary file (543 Bytes). View file
 
oneOone/asgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ASGI config for oneOone project.
3
+
4
+ It exposes the ASGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.asgi import get_asgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "oneOone.settings")
15
+
16
+ application = get_asgi_application()
oneOone/settings.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]
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
+ ]
37
+ CSRF_TRUSTED_ORIGINS = [
38
+ "http://localhost:8081",
39
+ "http://192.168.81.1:8000",
40
+ "http://192.168.12.61:8000",
41
+ "http://localhost:19006",
42
+ "https://s4t6xdgk-8000.inc1.devtunnels.ms"
43
+ ]
44
+
45
+ # Application definition
46
+
47
+ INSTALLED_APPS = [
48
+ "django.contrib.admin",
49
+ "django.contrib.auth",
50
+ "django.contrib.contenttypes",
51
+ "django.contrib.sessions",
52
+ "django.contrib.messages",
53
+ "django.contrib.staticfiles",
54
+ "rest_framework",
55
+ "rest_framework_simplejwt",
56
+ "import_export",
57
+ "corsheaders"
58
+ ]
59
+
60
+ MIDDLEWARE = [
61
+ "django.middleware.security.SecurityMiddleware",
62
+ "django.contrib.sessions.middleware.SessionMiddleware",
63
+ "corsheaders.middleware.CorsMiddleware",
64
+ "django.middleware.common.CommonMiddleware",
65
+ "django.middleware.csrf.CsrfViewMiddleware",
66
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
67
+ "django.contrib.messages.middleware.MessageMiddleware",
68
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
69
+ ]
70
+
71
+ ROOT_URLCONF = "oneOone.urls"
72
+
73
+ TEMPLATES = [
74
+ {
75
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
76
+ "DIRS": [],
77
+ "APP_DIRS": True,
78
+ "OPTIONS": {
79
+ "context_processors": [
80
+ "django.template.context_processors.debug",
81
+ "django.template.context_processors.request",
82
+ "django.contrib.auth.context_processors.auth",
83
+ "django.contrib.messages.context_processors.messages",
84
+ ],
85
+ },
86
+ },
87
+ ]
88
+
89
+ WSGI_APPLICATION = "oneOone.wsgi.application"
90
+
91
+
92
+ # Database
93
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
94
+
95
+ DATABASES = {
96
+ 'default': {
97
+ 'ENGINE': 'django.db.backends.postgresql',
98
+ 'NAME': 'postgres',
99
+ 'USER': 'postgres.psjobjezrtkjvenhsmge',
100
+ 'PORT': 6543,
101
+ 'PASSWORD': 'ErO9vgKcwCA1bdah',
102
+ 'HOST': 'aws-0-us-east-1.pooler.supabase.com',
103
+ }
104
+ }
105
+ # "default": {
106
+ # "ENGINE": "django.db.backends.sqlite3",
107
+ # "NAME": BASE_DIR / "db.sqlite3",
108
+ # }
109
+
110
+
111
+ # Password validation
112
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
113
+
114
+ AUTH_PASSWORD_VALIDATORS = [
115
+ {
116
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
117
+ },
118
+ {
119
+ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
120
+ },
121
+ {
122
+ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
123
+ },
124
+ {
125
+ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
126
+ },
127
+ ]
128
+
129
+
130
+ # Internationalization
131
+ # https://docs.djangoproject.com/en/4.2/topics/i18n/
132
+
133
+ LANGUAGE_CODE = "en-us"
134
+
135
+ TIME_ZONE = "UTC"
136
+
137
+ USE_I18N = True
138
+
139
+ USE_TZ = True
140
+
141
+
142
+ # Static files (CSS, JavaScript, Images)
143
+ # https://docs.djangoproject.com/en/4.2/howto/static-files/
144
+
145
+ STATIC_URL = "static/"
146
+
147
+ # Default primary key field type
148
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
149
+
150
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
151
+
152
+ REST_FRAMEWORK = {
153
+ 'DEFAULT_AUTHENTICATION_CLASSES': (
154
+ 'rest_framework_simplejwt.authentication.JWTAuthentication',
155
+ ),
156
+ 'DEFAULT_PERMISSION_CLASSES': (
157
+ 'rest_framework.permissions.AllowAny',
158
+ ),
159
+ }
160
+
161
+
162
+ SIMPLE_JWT = {
163
+ 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
164
+ 'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
165
+ 'ROTATE_REFRESH_TOKENS': True,
166
+ 'BLACKLIST_AFTER_ROTATION': True,
167
+ 'UPDATE_LAST_LOGIN': False,
168
+ }
169
+
170
+ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
oneOone/urls.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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),
28
+ path('api-auth/', include('rest_framework.urls')),
29
+ path('api/auth/', include('authentication.urls')),
30
+ path('api/', include('api.urls')),
31
+ ]
oneOone/wsgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ WSGI config for oneOone project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "oneOone.settings")
15
+
16
+ application = get_wsgi_application()
requirements.txt ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ asgiref==3.8.1
2
+ certifi==2024.8.30
3
+ charset-normalizer==3.4.0
4
+ diff-match-patch==20230430
5
+ Django==4.2.16
6
+ django-cors-headers==4.4.0
7
+ django-filter==24.3
8
+ django-import-export==4.1.1
9
+ djangorestframework==3.15.2
10
+ djangorestframework-simplejwt==5.3.1
11
+ idna==3.10
12
+ importlib_metadata==8.5.0
13
+ Markdown==3.7
14
+ psycopg2==2.9.10
15
+ PyJWT==2.9.0
16
+ requests==2.32.3
17
+ sqlparse==0.5.1
18
+ tablib==3.5.0
19
+ typing_extensions==4.12.2
20
+ tzdata==2024.2
21
+ urllib3==2.2.3
22
+ zipp==3.20.2
revelAPI.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import json
3
+
4
+ url = "https://101smokeshop-uat.revelup.com/enterprise/User/?is_active=true&limit=20&offset=0&order_by=last_login"
5
+
6
+ payload = {}
7
+ headers = {
8
+ 'content-type': 'application/json',
9
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
10
+ }
11
+
12
+ response = requests.request("GET", url, headers=headers, data=payload)
13
+
14
+ print(response.text)
15
+
16
+
17
+ url = "https://101smokeshop-uat.revelup.com/resources/Product/53/"
18
+
19
+ payload = {}
20
+ headers = {
21
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
22
+ }
23
+
24
+ response = requests.request("GET", url, headers=headers, data=payload)
25
+
26
+ print(response.text)
27
+
28
+
29
+ url = "https://101smokeshop-uat.revelup.com/products/ProductCategory/"
30
+
31
+ payload = {}
32
+ headers = {
33
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
34
+ }
35
+
36
+ response = requests.request("GET", url, headers=headers, data=payload)
37
+
38
+ print(response.text)
39
+
40
+
41
+ url = "https://101smokeshop-uat.revelup.com/enterprise/Establishment/?order_by=id&limit=20&offset=0"
42
+
43
+ payload = {}
44
+ headers = {
45
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
46
+ }
47
+
48
+ response = requests.request("GET", url, headers=headers, data=payload)
49
+
50
+ print(response.text)
51
+
52
+
53
+ url = "https://101smokeshop-uat.revelup.com/enterprise/Establishment/3/"
54
+
55
+ payload = {}
56
+ headers = {
57
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
58
+ }
59
+
60
+ response = requests.request("GET", url, headers=headers, data=payload)
61
+
62
+ print(response.text)
63
+
64
+
65
+ url = "https://101smokeshop-uat.revelup.com/resources/Inventory/?limit=20&offset=0"
66
+
67
+ payload = {}
68
+ headers = {
69
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
70
+ }
71
+
72
+ response = requests.request("GET", url, headers=headers, data=payload)
73
+
74
+ print(response.text)
75
+
76
+
77
+ url = "https://101smokeshop-uat.revelup.com/resources/Product/1/"
78
+
79
+ payload = {}
80
+ headers = {
81
+ 'API-AUTHENTICATION': 'fab57498544244e38bfc2741880f8d61:ed9628295b0642e1b38308795c9cdadd58012df4ceb84a3b9d441c017a1eeac0'
82
+ }
83
+
84
+ response = requests.request("GET", url, headers=headers, data=payload)
85
+
86
+ print(response.text)