diff --git a/backend/.gitignore b/backend/.gitignore index 69efed3..f883399 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -147,4 +147,4 @@ GitHub.sublime-settings videoflix/users/migrations # Statics -videoflix/staticfiles \ No newline at end of file +staticfiles \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index 85afc18..4dec55e 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -5,6 +5,7 @@ click==8.1.7 diff-match-patch==20230430 Django==5.0.8 django-cors-headers==4.4.0 +django-environ==0.12.0 django-grip==3.5.0 django-import-export==4.1.1 django-redis==5.4.0 @@ -23,7 +24,6 @@ psutil==6.0.0 psycopg==3.2.6 pubcontrol==3.5.0 PyJWT==2.9.0 -python-decouple==3.8 redis==5.0.8 requests==2.32.3 rq==1.16.2 diff --git a/backend/templates/forgot_password_mail.html b/backend/templates/forgot_password_mail.html index 9c687d3..22020d4 100644 --- a/backend/templates/forgot_password_mail.html +++ b/backend/templates/forgot_password_mail.html @@ -34,7 +34,7 @@ }
-

Dear {{ name }},
We recently received a request to reset your password. If you made this request, please click on the following link to reset your password: diff --git a/backend/templates/register_mail.html b/backend/templates/register_mail.html index 60f0b74..4796b7b 100644 --- a/backend/templates/register_mail.html +++ b/backend/templates/register_mail.html @@ -34,7 +34,7 @@ }
-

Dear {{ name }},
Thank you for registering with Videoflix. To complete your registration diff --git a/backend/videoflix/.env_example b/backend/videoflix/.env_example new file mode 100644 index 0000000..05bf344 --- /dev/null +++ b/backend/videoflix/.env_example @@ -0,0 +1,13 @@ +# General settings + +DEBUG=False +SECRET_KEY=secret_key + +# E-mail settings + +EMAIL_HOST_USER=example@gmail.com +EMAIL_HOST_PASSWORD=password + +# Sentry settings + +SENTRY_DSN=sentry_dns diff --git a/backend/videoflix/settings.py b/backend/videoflix/settings.py index db6811b..25a3dd9 100644 --- a/backend/videoflix/settings.py +++ b/backend/videoflix/settings.py @@ -11,32 +11,14 @@ https://docs.djangoproject.com/en/5.0/ref/settings/ """ import os -from pathlib import Path -from decouple import config import sentry_sdk +from pathlib import Path +from environ import Env +from sentry_sdk.integrations.django import DjangoIntegration # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-*o%q)*3l+9^fs!m0z_h=z9bc)su=%)fv$@ktb#pza-pvi^z*en' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -# EMAIL -EMAIL_USE_TLS = True -EMAIL_HOST = 'smtp.gmail.com' -EMAIL_PORT = 587 -EMAIL_HOST_USER = config('EMAIL_HOST_USER', default='') -EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD', default='') -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' -DEFAULT_FROM_EMAIL = 'noreply@videoflix.com' - ALLOWED_HOSTS = [ 'videoflix-api.andre-kempf.com', '45.157.177.172', @@ -189,7 +171,7 @@ USE_TZ = True STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') -STATIC_URL = 'static/' +STATIC_URL = '/static/' IMPORT_EXPORT_USE_TRANSACTIONS = True @@ -217,10 +199,29 @@ AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) +# Environment variables + +env = Env() +Env.read_env() + +DEBUG = env.bool('DEBUG', default=False) +SECRET_KEY = env('SECRET_KEY') + +# Mail + +EMAIL_USE_TLS = True +EMAIL_HOST = 'smtp.gmail.com' +EMAIL_PORT = 587 +EMAIL_HOST_USER = env('EMAIL_HOST_USER', default='') +EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD', default='') +EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +DEFAULT_FROM_EMAIL = 'noreply@videoflix.andre-kempf.com' + # Sentry sentry_sdk.init( - dsn="https://f9cac097dbb7a0d104f07d347e1bd470@o4507955559464960.ingest.de.sentry.io/4507955586138192", + dsn=os.getenv("SENTRY_DSN"), + integrations=[DjangoIntegration()], traces_sample_rate=1.0, profiles_sample_rate=1.0, ) \ No newline at end of file diff --git a/backend/videoflix/urls.py b/backend/videoflix/urls.py index d52b664..4cf1ade 100644 --- a/backend/videoflix/urls.py +++ b/backend/videoflix/urls.py @@ -1,23 +1,8 @@ -""" -URL configuration for videoflix project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/5.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" from django.contrib import admin from django.urls import path, include from django.conf import settings from django.conf.urls.static import static +from django.contrib.staticfiles.urls import staticfiles_urlpatterns from user_app import views as user_views from auth_app.views import ( LoginView, @@ -29,7 +14,6 @@ from auth_app.views import ( ChangePasswordView ) from video_app import views as video_views -from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns = [ path('admin/', admin.site.urls), @@ -54,4 +38,10 @@ urlpatterns = [ path('auth/verify-email/', VerifyEmailView.as_view(), name='verify_email'), path('auth/forgot-password/', ForgotPasswordView.as_view(), name='forgot_password'), path('auth/change-password/', ChangePasswordView.as_view(), name='change_password'), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + staticfiles_urlpatterns() \ No newline at end of file +] + +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + +urlpatterns += staticfiles_urlpatterns() \ No newline at end of file