-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(fix): Reconfigured the settings_module using best practices
- Loading branch information
1 parent
b0f1b2b
commit a0362f4
Showing
15 changed files
with
390 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Environment Settings | ||
# Use core.config.local for Dev environment and core.config.production for production environment | ||
DJANGO_SETTINGS_MODULE='core.config.local' | ||
|
||
# Sqlite3 database config | ||
SECRET_KEY='paste db.sqlite3 key here' | ||
|
||
# Production Env Database config | ||
# PostgreSql Credentials | ||
DB_NAME=<enter database name> | ||
DB_USER=<enter username> | ||
DB_PASS=<enter password> | ||
DB_HOST=localhost | ||
DB_PORT=5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
""" | ||
Django settings for core project. | ||
Generated by 'django-admin startproject' using Django 5.0.7. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/5.0/topics/settings/ | ||
For the full list of settings and their values, see | ||
https://docs.djangoproject.com/en/5.0/ref/settings/ | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
from decouple import config | ||
|
||
# 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 = config('SECRET_KEY') | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = bool(config('DJANGO_DEBUG', default=True)) | ||
|
||
ALLOWED_HOSTS = ["*"] | ||
|
||
# Application definition | ||
|
||
DJANGO_APPS = [ | ||
'jazzmin', | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'rest_framework', | ||
] | ||
|
||
LOCAL_APPS = [ | ||
'apps.common', | ||
'apps.research', | ||
] | ||
|
||
THIRD_PARTY_APPS = [ | ||
'corsheaders', | ||
'ckeditor_uploader', | ||
'django_ckeditor_5', | ||
] | ||
|
||
INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS + THIRD_PARTY_APPS | ||
|
||
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', | ||
] | ||
|
||
REST_FRAMEWORK = { | ||
'DEFAULT_PERMISSION_CLASSES': [ | ||
'rest_framework.permissions.IsAuthenticatedOrReadOnly', | ||
], | ||
"NON_FIELD_ERRORS_KEY": "error", | ||
|
||
} | ||
# Possible Permissions to explore based on use case | ||
# 'rest_framework.permissions.AllowAny', | ||
# 'rest_framework.permissions.IsAuthenticated', | ||
# 'rest_framework.permissions.IsAdminUser', | ||
# 'rest_framework.permissions.IsAuthenticatedOrReadOnly', | ||
|
||
CORS_ALLOWED_ORIGINS = [ | ||
"http://localhost:3000", | ||
"http://127.0.0.1:8000", | ||
] | ||
|
||
|
||
ROOT_URLCONF = 'core.urls' | ||
|
||
# configured to serve static files | ||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [ | ||
BASE_DIR / '../../client/build', | ||
BASE_DIR / 'templates', | ||
], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'core.wsgi.application' | ||
|
||
# Database | ||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': BASE_DIR / 'db.sqlite3', | ||
} | ||
} | ||
|
||
# Password validation | ||
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators | ||
|
||
AUTH_PASSWORD_VALIDATORS = [ | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | ||
}, | ||
{ | ||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', | ||
}, | ||
] | ||
|
||
# Internationalization | ||
# https://docs.djangoproject.com/en/5.0/topics/i18n/ | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
|
||
USE_TZ = True | ||
|
||
# Static files (CSS, JavaScript, Images) | ||
# https://docs.djangoproject.com/en/5.0/howto/static-files/ | ||
|
||
STATIC_URL = '/static/' | ||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') | ||
MEDIA_URL = '/media/' | ||
|
||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') | ||
|
||
STATICFILES_DIRS = [ | ||
'../client/build/static/', | ||
os.path.join(BASE_DIR, 'static'), | ||
] | ||
|
||
STORAGES = { | ||
"default": { | ||
"BACKEND": "django.core.files.storage.FileSystemStorage", | ||
}, | ||
"staticfiles": { | ||
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage", | ||
}, | ||
} | ||
|
||
# Default primary key field type | ||
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
||
SILENCED_SYSTEM_CHECKS = [ | ||
"staticfiles.W004" | ||
] | ||
|
||
from .jazzmin import * | ||
from .ckeditor import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# CKEDITOR CONFIGS | ||
CKEDITOR_UPLOAD_PATH = "ckeditor_uploads/" | ||
|
||
CKEDITOR_IMAGE_BACKEND = "pillow" | ||
|
||
customColorPalette = [ | ||
{ | ||
'color': 'hsl(4, 90%, 58%)', | ||
'label': 'Red' | ||
}, | ||
{ | ||
'color': 'hsl(340, 82%, 52%)', | ||
'label': 'Pink' | ||
}, | ||
{ | ||
'color': 'hsl(291, 64%, 42%)', | ||
'label': 'Purple' | ||
}, | ||
{ | ||
'color': 'hsl(262, 52%, 47%)', | ||
'label': 'Deep Purple' | ||
}, | ||
{ | ||
'color': 'hsl(231, 48%, 48%)', | ||
'label': 'Indigo' | ||
}, | ||
{ | ||
'color': 'hsl(207, 90%, 54%)', | ||
'label': 'Blue' | ||
}, | ||
] | ||
|
||
CKEDITOR_5_CONFIGS = { | ||
'default': { | ||
'toolbar': ['undo', 'redo', '|', 'heading', '|', 'bold', 'italic', 'underline', 'strikethrough', 'link', 'horizontalLine', '|', 'fontsize', | ||
'fontfamily', 'fontColor', 'fontBackgroundColor', '|', 'alignment', 'outdent', 'indent', | ||
'linespacing', '|', | ||
'bulletedList', 'numberedList', 'findAndReplace', 'highlight', 'subscript', 'superscript', | ||
'specialCharacters', '|', 'imageInsert', 'code', 'codeBlock', 'insertTable', 'mediaEmbed', '|', | ||
'blockQuote', 'fullscreen', 'removeFormat'], | ||
|
||
'image': { | ||
'toolbar': ['imageTextAlternative', '|', 'imageStyle:alignLeft', | ||
'imageStyle:alignRight', 'imageStyle:alignCenter', 'imageStyle:side', 'imageResize', '|'], | ||
'styles': [ | ||
'full', | ||
'side', | ||
'alignLeft', | ||
'alignRight', | ||
'alignCenter', | ||
] | ||
},'blockToolbar': { | ||
'items': [ | ||
'paragraph', 'heading1', 'heading2', 'heading3', | ||
'|', | ||
'bulletedList', 'numberedList', | ||
'|', | ||
'blockQuote', | ||
], | ||
'location': 'left', # Position the block toolbar on the left | ||
}, | ||
}, | ||
'extends': { | ||
|
||
}, | ||
'list': { | ||
'properties': { | ||
'styles': 'true', | ||
'startIndex': 'true', | ||
'reversed': 'true', | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
JAZZMIN_SETTINGS = { | ||
"site_brand": "2077 Collective Admin", | ||
# title of the window (Will default to current_admin_site.site_title if absent or None) | ||
"site_title": "2077 Collective Admin", | ||
# Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None) | ||
"site_header": "2077 Collective", | ||
# Logo to use for your site, must be present in static files, used for brand on top left | ||
"site_logo": "../staticfiles/images/logo.png", | ||
# Logo to use for your site, must be present in static files, used for login form logo (defaults to site_logo) | ||
"login_logo": "../staticfiles/images/logo.png", | ||
# CSS classes that are applied to the logo above | ||
"site_logo_classes": "img-circle", | ||
# Relative path to a favicon for your site, will default to site_logo if absent (ideally 32x32 px) | ||
"site_icon": "../staticfiles/images/logo.img", | ||
# Welcome text on the login screen | ||
"welcome_sign": "Welcome to the 2077 Collective Admin Section", | ||
# Copyright on the footer | ||
"copyright": "2077 Collective Ltd", | ||
# The model admin to search from the search bar, search bar omitted if excluded | ||
"search_model": [], | ||
# Field name on user model that contains avatar ImageField/URLField/Charfield or a callable that receives the user | ||
# "user_avatar": "avatar", | ||
|
||
############# | ||
# User Menu # | ||
############# | ||
# Additional links to include in the user menu on the top right ("app" url type is not allowed) | ||
"usermenu_links": [{"name": "2077 Collective Platform"}, {"model": "core.user"}], | ||
|
||
############# | ||
# Side Menu # | ||
############# | ||
# Whether to display the side menu | ||
"show_sidebar": True, | ||
# Whether to aut expand the menu | ||
"navigation_expanded": True, | ||
# Hide these apps when generating side menu e.g (auth) | ||
"hide_apps": {"authtoken": ['tokenproxy'], "token_blacklist": ["blacklistedtoken", "outstandingtoken"]}, | ||
# List of apps (and/or models) to base side menu ordering off of (does not need to contain all apps/models) | ||
"order_with_respect_to": ["auth", "research"], | ||
|
||
"related_modal_active": False, | ||
|
||
"icons": { | ||
"auth.group": "fas fa-users", | ||
"auth.user": "fas fa-universal-access", | ||
"research.article": "fas fa-newspaper", | ||
"research.category": "fas fa-list", | ||
}, | ||
# Icons that are used when one is not manually specified | ||
"default_icon_parents": "fas fa-chevron-circle-right", | ||
"default_icon_children": "fas fa-circle", | ||
|
||
############# | ||
# UI Tweaks # | ||
############# | ||
"changeform_format": "carousel", | ||
# override change forms on a per modeladmin basis | ||
"changeform_format_overrides": { | ||
"auth.user": "collapsible", | ||
"auth.group": "vertical_tabs", | ||
"research.article": "horizontal_tabs_bottom_buttons", | ||
}, | ||
} | ||
|
||
JAZZMIN_UI_TWEAKS = { | ||
"navbar_small_text": False, | ||
"footer_small_text": False, | ||
"body_small_text": False, | ||
"brand_small_text": True, | ||
"brand_colour": "navbar-teal", | ||
"accent": "accent-navy", | ||
"navbar": "navbar-teal navbar-dark", | ||
"no_navbar_border": True, | ||
"navbar_fixed": False, | ||
"layout_boxed": False, | ||
"footer_fixed": False, | ||
"sidebar_fixed": False, | ||
"sidebar": "sidebar-light-teal", | ||
"sidebar_nav_small_text": False, | ||
"sidebar_disable_expand": False, | ||
"sidebar_nav_child_indent": False, | ||
"sidebar_nav_compact_style": False, | ||
"sidebar_nav_legacy_style": False, | ||
"sidebar_nav_flat_style": False, | ||
"theme": "yeti", | ||
"dark_mode_theme": "darkly", | ||
"button_classes": { | ||
"primary": "btn-outline-primary", | ||
"secondary": "btn-outline-secondary", | ||
"info": "btn-info", | ||
"warning": "btn-warning", | ||
"danger": "btn-danger", | ||
"success": "btn-success" | ||
}, | ||
"actions_sticky_top": False | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .base import * | ||
|
Oops, something went wrong.