Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#42 feat: implement doi's, format code with black #43

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/backend/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "backend.settings")

application = get_asgi_application()
205 changes: 94 additions & 111 deletions backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-6dns-bbp&433ugro&j+z6p-w943$uhsax%f1245@7vfo3eyuw2'
SECRET_KEY = "django-insecure-6dns-bbp&433ugro&j+z6p-w943$uhsax%f1245@7vfo3eyuw2"

# SECURITY WARNING: don't run with debug turned on in production!
PRODUCTION = True if os.environ.get("PRODUCTION", None) else False
Expand All @@ -30,86 +30,85 @@
ALLOWED_HOSTS = [
"*",
]
CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "https://*.metacell.us",]
CSRF_TRUSTED_ORIGINS = [
"http://localhost:8000",
"https://*.metacell.us",
]

INTERNAL_IPS = [
'127.0.0.1',
"127.0.0.1",
]

# Application definition

INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions','django.contrib.messages',
'django.contrib.staticfiles',

'fsm_admin',
'adminsortable2',
'django_filters',

'drf_spectacular',
'drf_spectacular_sidecar',

'debug_toolbar',

'composer',

'jazzmin',

'django.contrib.admin',
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"fsm_admin",
"adminsortable2",
"django_filters",
"drf_spectacular",
"drf_spectacular_sidecar",
"debug_toolbar",
"composer",
"nested_admin",
"jazzmin",
"django.contrib.admin",
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
]

ROOT_URLCONF = 'backend.urls'
ROOT_URLCONF = "backend.urls"

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"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 = 'backend.wsgi.application'
WSGI_APPLICATION = "backend.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
if PRODUCTION:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get('DB_NAME'),
'USER': os.environ.get('DB_USER'),
'PASSWORD': os.environ.get('DB_PASSWORD'),
'HOST': os.environ.get('DB_HOST'),
'PORT': os.environ.get('DB_PORT'),
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'persistent', 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "persistent", "db.sqlite3"),
}
}

Expand All @@ -118,26 +117,26 @@

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = "en-us"

TIME_ZONE = 'UTC'
TIME_ZONE = "UTC"

USE_I18N = True

Expand All @@ -147,113 +146,97 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/

STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static', )
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(
BASE_DIR,
"static",
)

# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

X_FRAME_OPTIONS = 'SAMEORIGIN'
X_FRAME_OPTIONS = "SAMEORIGIN"

JAZZMIN_SETTINGS = {
# title of the window (Will default to current_admin_site.site_title if absent or None)
"site_title": "SCKAN Composer",

# Title on the login screen (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_header": "SCKAN Composer",

# Title on the brand (19 chars max) (defaults to current_admin_site.site_header if absent or None)
"site_brand": "SCKAN Composer",

# Logo to use for your site, must be present in static files, used for brand on top left
"site_logo": "/img/composer-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": None,

# Logo to use for login form in dark themes (defaults to login_logo)
"login_logo_dark": None,

# 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": None,

# Welcome text on the login screen
"welcome_sign": "Welcome to the SCKAN Composer Admin",

# Copyright on the footer
"copyright": "UCSD",

# List of model admins to search from the search bar, search bar omitted if excluded
# If you want to use a single search field you dont need to use a list, you can use a simple string
# If you want to use a single search field you dont need to use a list, you can use a simple string
"search_model": ["auth.User", "auth.Group"],

# Field name on user model that contains avatar ImageField/URLField/Charfield or a callable that receives the user
"user_avatar": None,

############
# Top Menu #
############

# Links to put along the top menu
"topmenu_links": [

# Url that gets reversed (Permissions can be added)
{"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]},

{"name": "Home", "url": "admin:index", "permissions": ["auth.view_user"]},
# external url that opens in a new window (Permissions can be added)
{"name": "Support", "url": "https://github.com/MetaCell/sckan-composer/issues", "new_window": True},

{
"name": "Support",
"url": "https://github.com/MetaCell/sckan-composer/issues",
"new_window": True,
},
# model admin to link to (Permissions checked against model)
{"model": "auth.User"},

# App with dropdown menu to all its models pages (Permissions checked against models)
{"app": "composer"},
],

#############
# User Menu #
#############

# Additional links to include in the user menu on the top right ("app" url type is not allowed)
"usermenu_links": [
{"name": "Support", "url": "https://github.com/MetaCell/sckan-composer/issues", "new_window": True},
{"model": "auth.user"}
{
"name": "Support",
"url": "https://github.com/MetaCell/sckan-composer/issues",
"new_window": True,
},
{"model": "auth.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": [],

# Hide these models when generating side menu (e.g auth.user)
"hide_models": [],

# 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", "composer"],

# # Custom links to append to app groups, keyed on app name
# "custom_links": {
# "provenance": [{
# "name": "Make a new Provenance",
# "url": "make_messages",
# "name": "Make a new Provenance",
# "url": "make_messages",
# "icon": "fas fa-comments",
# "permissions": ["books.view_book"]
# }]
# },

# Custom icons for side menu apps/models See https://fontawesome.com/icons?d=gallery&m=free&v=5.0.0,5.0.1,5.0.10,5.0.11,5.0.12,5.0.13,5.0.2,5.0.3,5.0.4,5.0.5,5.0.6,5.0.7,5.0.8,5.0.9,5.1.0,5.1.1,5.2.0,5.3.0,5.3.1,5.4.0,5.4.1,5.4.2,5.13.0,5.12.0,5.11.2,5.11.1,5.10.0,5.9.0,5.8.2,5.8.1,5.7.2,5.7.1,5.7.0,5.6.3,5.5.0,5.4.2
# for the full list of 5.13.0 free icon classes
"icons": {
Expand All @@ -264,13 +247,11 @@
# Icons that are used when one is not manually specified
"default_icon_parents": "fas fa-chevron-circle-right",
"default_icon_children": "fas fa-circle",

#################
# Related Modal #
#################
# Use modals instead of popups
"related_modal_active": True,

#############
# UI Tweaks #
#############
Expand All @@ -281,7 +262,6 @@
"use_google_fonts_cdn": True,
# Whether to show the UI customizer on the sidebar
"show_ui_builder": False,

###############
# Change view #
###############
Expand All @@ -293,7 +273,10 @@
# - carousel
"changeform_format": "horizontal_tabs",
# override change forms on a per modeladmin basis
"changeform_format_overrides": {"auth.user": "collapsible", "auth.group": "vertical_tabs"},
"changeform_format_overrides": {
"auth.user": "collapsible",
"auth.group": "vertical_tabs",
},
# Add a language dropdown into the admin
"language_chooser": False,
}
Expand Down Expand Up @@ -326,24 +309,24 @@
"info": "btn-info",
"warning": "btn-warning",
"danger": "btn-danger",
"success": "btn-success"
"success": "btn-success",
},
"actions_sticky_top": True
"actions_sticky_top": True,
}

REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
'PAGE_SIZE': 1,
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": 1,
}

SPECTACULAR_SETTINGS = {
'TITLE': 'SCKAN Composer API',
'DESCRIPTION': 'SCKAN Composer API',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'SWAGGER_UI_DIST': 'SIDECAR', # shorthand to use the sidecar instead
'SWAGGER_UI_FAVICON_HREF': 'SIDECAR',
'REDOC_DIST': 'SIDECAR',
"TITLE": "SCKAN Composer API",
"DESCRIPTION": "SCKAN Composer API",
"VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False,
"SWAGGER_UI_DIST": "SIDECAR", # shorthand to use the sidecar instead
"SWAGGER_UI_FAVICON_HREF": "SIDECAR",
"REDOC_DIST": "SIDECAR",
# OTHER SETTINGS
}
Loading