feat: initialize Django project configuration, api views, and core url routing
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 23s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 23s
This commit is contained in:
parent
506ff011b1
commit
61561d75bb
3 changed files with 40 additions and 2 deletions
17
api/views.py
17
api/views.py
|
|
@ -40,3 +40,20 @@ class UserProfileView(APIView):
|
|||
profile.default_address = request.data.get('address', profile.default_address)
|
||||
profile.save()
|
||||
return Response({"message": "Profile updated successfully"})
|
||||
|
||||
class SendWhatsAppOTPView(APIView):
|
||||
permission_classes = [permissions.AllowAny]
|
||||
|
||||
def post(self, request):
|
||||
mobile_number = request.data.get('mobile_number')
|
||||
otp_code = request.data.get('otp_code')
|
||||
|
||||
if not mobile_number or not otp_code:
|
||||
return Response({"error": "mobile_number and otp_code are required"}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
audit_logger.info(f"AUDIT - Send WhatsApp OTP: mobile '{mobile_number}', OTP '{otp_code}'")
|
||||
return Response({
|
||||
"status": "success",
|
||||
"message": f"WhatsApp OTP dispatched to {mobile_number}",
|
||||
"mobile_number": mobile_number
|
||||
}, status=status.HTTP_200_OK)
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ INSTALLED_APPS = [
|
|||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'customerwebsitebackend.middleware.RequestLoggingMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
'customerwebsitebackend.middleware.RequestLoggingMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
|
|
@ -173,6 +173,26 @@ REST_FRAMEWORK = {
|
|||
}
|
||||
|
||||
CORS_ALLOW_ALL_ORIGINS = True
|
||||
CORS_ALLOW_CREDENTIALS = True
|
||||
CORS_ALLOW_HEADERS = [
|
||||
'accept',
|
||||
'accept-encoding',
|
||||
'authorization',
|
||||
'content-type',
|
||||
'dnt',
|
||||
'origin',
|
||||
'user-agent',
|
||||
'x-csrftoken',
|
||||
'x-requested-with',
|
||||
]
|
||||
CORS_ALLOW_METHODS = [
|
||||
'DELETE',
|
||||
'GET',
|
||||
'OPTIONS',
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
]
|
||||
|
||||
from datetime import timedelta
|
||||
SIMPLE_JWT = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ def home_view(request):
|
|||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView
|
||||
from api.views import UserRegisterView, UserProfileView
|
||||
from api.views import UserRegisterView, UserProfileView, SendWhatsAppOTPView
|
||||
from products.views import CategoryListView, ProductListView, ProductDetailView
|
||||
from orders.views import CartView, CartItemDetailView, CheckoutView, PaymentSuccessView, OrderHistoryView, OrderDetailView
|
||||
|
||||
|
|
@ -15,6 +15,7 @@ urlpatterns = [
|
|||
path('admin/', admin.site.urls),
|
||||
|
||||
# Auth APIs
|
||||
path('api/v1/customer/auth/send-whatsapp/', SendWhatsAppOTPView.as_view(), name='send_whatsapp'),
|
||||
path('api/v1/customer/auth/register/', UserRegisterView.as_view(), name='register'),
|
||||
path('api/v1/customer/auth/login/', TokenObtainPairView.as_view(), name='login'),
|
||||
path('api/v1/customer/auth/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue