浏览代码

update settings

Mohammed Khan 1 年之前
父节点
当前提交
0a6e96f8aa

+ 1 - 2
backend/UnTube/settings/__init__.py

@@ -1,4 +1,4 @@
-import os.path
+import os
 from pathlib import Path
 from split_settings.tools import include, optional
 
@@ -31,4 +31,3 @@ include(
     'docker.py',
     'pythonanywhere.py',
 )
-

+ 16 - 1
backend/UnTube/settings/allauth.py

@@ -2,10 +2,25 @@
 Django AllAuth package related settings
 """
 
-SITE_ID = 10  # increment/decrement site ID as necessary
+SITE_ID = 2  # increment/decrement site ID as necessary
+LOGIN_REDIRECT_URL = '/'
+LOGOUT_REDIRECT_URL = '/'
+
+# Additional configuration settings
+# ACCOUNT_LOGOUT_ON_GET= True
+SOCIALACCOUNT_LOGIN_ON_GET = True
+SOCIALACCOUNT_STORE_TOKENS = True
+ACCOUNT_UNIQUE_EMAIL = True
+ACCOUNT_EMAIL_REQUIRED = True
 
 SOCIALACCOUNT_PROVIDERS = {
     'google': {
+        # 'APP': {
+        #     'client_id': GOOGLE_OAUTH_CLIENT_ID,  # type: ignore
+        #     'secret': GOOGLE_OAUTH_CLIENT_SECRET,  # type: ignore
+        #     'key': ''
+        # },
+        # 'OAUTH_PKCE_ENABLED': True,  # valid in allauth ver > 0.47.0
         'SCOPE': [
             'profile',
             'email',

+ 6 - 10
backend/UnTube/settings/base.py

@@ -9,9 +9,6 @@ https://docs.djangoproject.com/en/3.2/topics/settings/
 For the full list of settings and their values, see
 https://docs.djangoproject.com/en/3.2/ref/settings/
 """
-import os
-from backend.UnTube.settings import BASE_DIR
-
 DEBUG = False
 SECRET_KEY = NotImplemented
 
@@ -40,6 +37,8 @@ INSTALLED_APPS = [
     'backend.manage_playlists',
     'backend.charts',
     'backend.search',
+
+    'import_export',
 ]
 
 MIDDLEWARE = [
@@ -57,7 +56,7 @@ ROOT_URLCONF = 'backend.UnTube.urls'  # path to the urls.py file in root UnTube
 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
-        'DIRS': [BASE_DIR / 'backend' / 'templates'],
+        'DIRS': [BASE_DIR / 'backend', BASE_DIR / 'backend' / 'templates'],  # type: ignore
         # 'DIRS': [os.path.join(BASE_DIR, "templates")],
         'APP_DIRS': True,
         'OPTIONS': {
@@ -78,9 +77,6 @@ AUTHENTICATION_BACKENDS = [
 
 LOGIN_URL = '/'
 
-LOGIN_REDIRECT_URL = '/home/'
-LOGOUT_REDIRECT_URL = '/home/'
-
 WSGI_APPLICATION = 'backend.UnTube.wsgi.application'  # path to the wsgi.py file in root UnTube app folder
 
 # Database
@@ -88,7 +84,7 @@ WSGI_APPLICATION = 'backend.UnTube.wsgi.application'  # path to the wsgi.py file
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3',
-        'NAME': BASE_DIR / 'db.sqlite3',
+        'NAME': BASE_DIR / 'db.sqlite3',  # type: ignore
     }
 }
 
@@ -124,7 +120,7 @@ USE_TZ = True
 # Static files (CSS, JavaScript, Images)
 # https://docs.djangoproject.com/en/3.2/howto/static-files/
 STATIC_URL = '/static/'
-STATIC_ROOT = os.path.join(BASE_DIR, 'static')
+STATIC_ROOT = BASE_DIR / 'backend' / 'static'  # type: ignore
 # STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
 
 # Default primary key field type
@@ -132,4 +128,4 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 
 MEDIA_URL = '/media/'
-MEDIA_ROOT = os.path.join(BASE_DIR / 'media')
+MEDIA_ROOT = BASE_DIR / 'backend' / 'media'  # type: ignore

+ 1 - 0
backend/UnTube/settings/custom.py

@@ -3,6 +3,7 @@ Settings specific to this application only (no Django or third party settings)
 """
 
 YOUTUBE_V3_API_KEY = NotImplemented
+GOOGLE_OAUTH_URI = NotImplemented
 GOOGLE_OAUTH_CLIENT_ID = NotImplemented
 GOOGLE_OAUTH_CLIENT_SECRET = NotImplemented
 CRISPY_TEMPLATE_PACK = 'bootstrap4'

+ 1 - 1
backend/UnTube/settings/pythonanywhere.py

@@ -3,7 +3,7 @@ if IN_PYTHONANYWHERE:  # type: ignore
     # from dotenv import load_dotenv
     # project_folder = os.path.expanduser('/home/bakaabu')
     # load_dotenv(os.path.join(project_folder, '.env'))
-
+    GOOGLE_OAUTH_URI = os.environ['GOOGLE_OAUTH_URI']  # type: ignore #  "bakaabu.pythonanywhere.com"
     SECRET_KEY = os.environ['SECRET_KEY']  # type: ignore
     YOUTUBE_V3_API_KEY = os.environ['YOUTUBE_V3_API_KEY']   # type: ignore