Skip to content

Commit 4de335e

Browse files
committed
resolved issue in merging (forgot to git add before)
2 parents 2d4d8eb + 803a38b commit 4de335e

41 files changed

Lines changed: 1266 additions & 60 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

auth/account/migrations/0001_initial.py

Lines changed: 0 additions & 29 deletions
This file was deleted.
-1.4 KB
Binary file not shown.
Binary file not shown.
-169 Bytes
Binary file not shown.

auth/account/views.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ def post(self, request, format=None):
100100

101101

102102
class VerifyRegistrationOTPView(APIView):
103-
@extend_schema(
104-
request=VerifyOTPSerializer,
105-
responses={
106-
200: OpenApiResponse(
103+
@extend_schema(request=VerifyOTPSerializer,
104+
responses={200: OpenApiResponse(
107105
response=OpenApiTypes.OBJECT,
108106
description="Email verified and JWT tokens issued",
109107
examples=[
@@ -112,14 +110,10 @@ class VerifyRegistrationOTPView(APIView):
112110
value={
113111
"status": "success",
114112
"message": "Email verified successfully!",
115-
"data": {
116-
"user": {
117-
"id": 1,
118-
"email": "user@example.com",
119-
"is_email_verified": True
120-
},
121-
"tokens": {
122-
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
113+
"data": {"user": {"id": 1,
114+
"email": "user@example.com",
115+
"is_email_verified": True},
116+
"tokens": {"refresh": "eyJ0eXAiOiJKV1QiLCJhbGc...",
123117
"access": "eyJ0eXAiOiJKV1QiLCJhbGc..."}}})]),
124118
400: OpenApiResponse(description="Invalid or expired OTP"),
125119
429: OpenApiResponse(description="Too many failed attempts"),},

auth/auth/settings.py

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,22 @@
1111
# DEBUG = config('DEBUG', default=False, cast=bool)
1212
DEBUG = True
1313

14-
# ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "localhost,127.0.0.1,51.20.254.52").split(',')
15-
ALLOWED_HOSTS = ["*"]
16-
INSTALLED_APPS = ['channels','daphne','django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'account.apps.AccountConfig', 'rest_framework', 'rest_framework_simplejwt', 'rest_framework_simplejwt.token_blacklist', 'corsheaders', 'drf_spectacular','chat.apps.ChatConfig']
14+
INSTALLED_APPS = ['django.contrib.admin',
15+
'django.contrib.auth',
16+
'django.contrib.contenttypes',
17+
'django.contrib.sessions',
18+
'django.contrib.messages',
19+
'django.contrib.staticfiles',
20+
'account.apps.AccountConfig',
21+
'community',
22+
'chatbot',
23+
'rest_framework',
24+
'rest_framework_simplejwt',
25+
'rest_framework_simplejwt.token_blacklist',
26+
'corsheaders',
27+
'drf_spectacular',
28+
'cloudinary',
29+
'cloudinary_storage',]
1730

1831
MIDDLEWARE = ['django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
1932

@@ -45,6 +58,12 @@
4558
else:
4659
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3'}}
4760

61+
CLOUDINARY_STORAGE = {
62+
'CLOUD_NAME': config('CLOUD_NAME'),
63+
'API_KEY': config('API_KEY'),
64+
'API_SECRET': config('API_SECRET')
65+
}
66+
4867
REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework_simplejwt.authentication.JWTAuthentication',), 'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema', 'DEFAULT_RENDERER_CLASSES': ['rest_framework.renderers.JSONRenderer', 'rest_framework.renderers.BrowsableAPIRenderer']}
4968

5069
SPECTACULAR_SETTINGS = {'TITLE': 'TripSync API', 'DESCRIPTION': 'TripSync - API Documentation', 'VERSION': '1.0.0', 'SERVE_INCLUDE_SCHEMA': False, 'CONTACT': {'name': 'TripSync Support', 'email': 'support@tripsync.com'}, 'LICENSE': {'name': 'MIT License'}, 'TAGS': [{'name': 'Authentication', 'description': 'User registration, login and token management'}, {'name': 'Password Reset', 'description': 'Password reset functionality with OTP'}], 'SERVERS': [{'url': 'http://127.0.0.1:8000', 'description': 'Development server'}, {'url': 'https://tripsync-backend-ruak.onrender.com', 'description': 'Production server'}], 'COMPONENT_SPLIT_REQUEST': True, 'SWAGGER_UI_SETTINGS': {'deepLinking': True, 'persistAuthorization': True, 'displayOperationId': False, 'filter': True}}
@@ -56,27 +75,17 @@
5675
USE_I18N = True
5776
USE_TZ = True
5877

59-
STATIC_URL = '/static/'
60-
STATIC_ROOT = BASE_DIR / 'staticfiles'
61-
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
62-
63-
MEDIA_URL = '/media/'
64-
MEDIA_ROOT = BASE_DIR / 'media'
65-
6678
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
6779

6880
AUTH_USER_MODEL = 'account.User'
6981

7082
SIMPLE_JWT = {'ACCESS_TOKEN_LIFETIME': timedelta(hours=1), 'REFRESH_TOKEN_LIFETIME': timedelta(days=7), 'ROTATE_REFRESH_TOKENS': True, 'BLACKLIST_AFTER_ROTATION': True, 'UPDATE_LAST_LOGIN': True, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'AUTH_HEADER_TYPES': ('Bearer',), 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type'}
7183

7284
CORS_ALLOWED_ORIGINS = config('CORS_ALLOWED_ORIGINS', default='http://localhost:3000,http://localhost:5173').split(',')
73-
7485
CORS_ALLOW_ALL_ORIGINS = DEBUG
7586
CORS_ALLOW_CREDENTIALS = True
76-
7787
CORS_ALLOW_METHODS = ['DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT']
78-
79-
CORS_ALLOW_HEADERS = ['accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with','sec-websocket-key','sec-websocket-version','sec-websocket-extensions' ]
88+
CORS_ALLOW_HEADERS = ['accept', 'accept-encoding', 'authorization', 'content-type', 'dnt', 'origin', 'user-agent', 'x-csrftoken', 'x-requested-with']
8089

8190
if not DEBUG:
8291
SECURE_SSL_REDIRECT = False
@@ -116,5 +125,36 @@
116125
OTP_EXPIRY_MINUTES = 10
117126
MAX_OTP_ATTEMPTS = 5
118127
OTP_LOCKOUT_HOURS = 1
119-
120-
LOGGING = {'version': 1, 'disable_existing_loggers': False, 'formatters': {'verbose': {'format': '{levelname} {asctime} {module} {message}', 'style': '{'}}, 'handlers': {'console': {'class': 'logging.StreamHandler', 'formatter': 'verbose'}}, 'root': {'handlers': ['console'], 'level': 'INFO'}, 'loggers': {'django': {'handlers': ['console'], 'level': 'INFO', 'propagate': False}, 'account': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False}}}
128+
OTP_LOCKOUT_MINUTES = 15
129+
130+
LOGGING = {'version': 1, 'disable_existing_loggers': False, 'formatters': {'verbose': {'format': '{levelname} {asctime} {module} {message}', 'style': '{'}}, 'handlers': {'console': {'class': 'logging.StreamHandler', 'formatter': 'verbose'}}, 'root': {'handlers': ['console'], 'level': 'INFO'}, 'loggers': {'django': {'handlers': ['console'], 'level': 'INFO', 'propagate': False}, 'account': {'handlers': ['console'], 'level': 'DEBUG', 'propagate': False}}}
131+
132+
TWILIO_ACCOUNT_SID = config('TWILIO_ACCOUNT_SID', '')
133+
TWILIO_AUTH_TOKEN = config('TWILIO_AUTH_TOKEN', '')
134+
TWILIO_PHONE_NUMBER = config('TWILIO_PHONE_NUMBER', '')
135+
136+
USE_S3 = config('USE_S3', default=False, cast=bool)
137+
if USE_S3:
138+
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
139+
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
140+
AWS_BUCKET = config('AWS_STORAGE_BUCKET_NAME')
141+
S3_REGION = config('AWS_S3_REGION_NAME')
142+
S3_DOMAIN = f'tripsync-media.s3.amazonaws.com'
143+
144+
AWS_S3_OBJECT_PARAMETERS = {'CacheControl': 'max-age=86400',}
145+
AWS_DEFAULT_ACL = 'public-read'
146+
AWS_S3_FILE_OVERWRITE = False
147+
AWS_QUERYSTRING_AUTH = False
148+
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
149+
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
150+
STATIC_URL = f'https://{S3_DOMAIN}/static/'
151+
MEDIA_URL = f'https://{S3_DOMAIN}/media/'
152+
else:
153+
STATIC_URL = '/static/'
154+
STATIC_ROOT = BASE_DIR / 'staticfiles'
155+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
156+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
157+
MEDIA_URL = '/media/'
158+
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
159+
160+
GOOGLE_API_KEY=config('GOOGLE_API_KEY')

auth/auth/urls.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
from django.contrib import admin
22
from django.urls import path, include
3+
from django.conf import settings
4+
from django.conf.urls.static import static
35
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
46
from rest_framework.decorators import api_view
57
from rest_framework.response import Response
68
from django.http import JsonResponse
9+
from django.conf import settings
10+
from django.conf.urls.static import static
711

812
@api_view(['GET'])
913
def root_redirect(request):
1014
return Response({
1115
'message': 'Welcome to TripSync API',
12-
'documentation': request.build_absolute_uri('/api/docs/'),
13-
'admin': request.build_absolute_uri('/admin/'),
14-
})
16+
'swagger link': request.build_absolute_uri('/api/docs/'),
17+
'admin link': request.build_absolute_uri('/admin/'),})
1518
def health_check(request):
1619
return JsonResponse({'status': 'ok'})
1720

1821
urlpatterns = [
1922
path('', root_redirect),
2023
path('health/', health_check, name='health-check'),
2124
path('admin/', admin.site.urls),
25+
path('api/chatbot/', include('chatbot.urls')),
2226
path('api/account/', include('account.urls')),
2327
path('api/chat/', include('chat.urls')),
28+
path('api/personal/', include('personal.urls')),
29+
path('api/community/',include('community.urls')),
2430
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
2531
path('api/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
2632
path('api/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
2733
]
34+
35+
36+
if settings.DEBUG:
37+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

auth/chatbot/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

auth/chatbot/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ChatbotConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'chatbot'

0 commit comments

Comments
 (0)