Skip to content
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
14 changes: 13 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repos:
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
Expand Down Expand Up @@ -45,7 +46,7 @@ repos:

# runs the ruff linter and formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.11
rev: v0.14.14
hooks:
# linter
- id: ruff-check # runs ruff check --force-exclude
Expand Down Expand Up @@ -85,6 +86,17 @@ repos:
args: ["-f"]
stages: [pre-commit]

- repo: local
# add deptry rule exceptions to pyproject.toml [tool.deptry.ignore_rules]
# instead of using arguments here.
hooks:
- id: deptry
name: deptry
entry: bash -c "cd sdk && uv run deptry .; cd ../gateway && uv run deptry ."
language: system
pass_filenames: false # run once per commit, not per file
types: [python]

# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date
ci:
autoupdate_schedule: weekly
Expand Down
2 changes: 1 addition & 1 deletion gateway/.envs/example/django.prod-example.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CLIENT_SECRET=
# EMAIL SERVER
# ------------------------------------------------------------------------------
# institution whitelisted server email host
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
# https://docs.djangoproject.com/en/4.2/ref/settings/#email-backend
DJANGO_EMAIL_HOST=
DJANGO_EMAIL_PORT=25
DJANGO_EMAIL_HOST_USER=
Expand Down
2 changes: 1 addition & 1 deletion gateway/config/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/asgi/
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/

"""

Expand Down
90 changes: 47 additions & 43 deletions gateway/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,38 +88,38 @@ def __get_random_token(length: int) -> str:

# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
# https://docs.djangoproject.com/en/4.2/ref/settings/#debug
DEBUG: bool = env.bool("DJANGO_DEBUG", False)
# Local time zone. Choices are
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# though not all of them may be available with every OS.
# In Windows, this must be set to your system time zone.
TIME_ZONE: str = "America/New_York"
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
# https://docs.djangoproject.com/en/4.2/ref/settings/#language-code
LANGUAGE_CODE: str = "en-us"
# https://docs.djangoproject.com/en/dev/ref/settings/#languages
# https://docs.djangoproject.com/en/4.2/ref/settings/#languages
# from django.utils.translation import gettext_lazy as _
# LANGUAGES = [
# ('en', _('English')),
# ('fr-fr', _('French')),
# ('pt-br', _('Portuguese')),
# ]
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
# https://docs.djangoproject.com/en/4.2/ref/settings/#site-id
SITE_ID: int = 1
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
# https://docs.djangoproject.com/en/4.2/ref/settings/#use-i18n
USE_I18N: bool = True
# https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
# https://docs.djangoproject.com/en/4.2/ref/settings/#use-tz
USE_TZ: bool = True
# https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths
# https://docs.djangoproject.com/en/4.2/ref/settings/#locale-paths
LOCALE_PATHS: list[str] = [str(BASE_DIR / "locale")]

# DATABASES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES: dict[str, Any] = {"default": env.dj_db_url("DATABASE_URL")}
DATABASES["default"]["ATOMIC_REQUESTS"] = True
# TODO: enable connection pools when upgrading to Django 5.1+ and psycopg3
# https://docs.djangoproject.com/en/dev/ref/databases/#connection-pool
# https://docs.djangoproject.com/en/4.2/ref/databases/#connection-pool
# DATABASES["default"]["OPTIONS"] = {
# "pool": True,
# }
Expand All @@ -128,9 +128,9 @@ def __get_random_token(length: int) -> str:

# URLS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf
# https://docs.djangoproject.com/en/4.2/ref/settings/#root-urlconf
ROOT_URLCONF: str = "config.urls"
# https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
# https://docs.djangoproject.com/en/4.2/ref/settings/#wsgi-application
WSGI_APPLICATION: str = "config.wsgi.application"

# APPS
Expand Down Expand Up @@ -173,40 +173,44 @@ def __get_random_token(length: int) -> str:
"sds_gateway.visualizations",
# Your stuff: custom apps go here
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
# https://docs.djangoproject.com/en/4.2/ref/settings/#installed-apps
INSTALLED_APPS: list[str] = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS

# MIGRATIONS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#migration-modules
# https://docs.djangoproject.com/en/4.2/ref/settings/#migration-modules
MIGRATION_MODULES: dict[str, str] = {"sites": "sds_gateway.contrib.sites.migrations"}

# AUTHENTICATION
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#authentication-backends
# https://docs.djangoproject.com/en/4.2/ref/settings/#authentication-backends
AUTHENTICATION_BACKENDS: list[str] = [
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-user-model
# see sds_gateway/users/models.py
AUTH_USER_MODEL: str = "users.User"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url
# https://docs.djangoproject.com/en/4.2/ref/settings/#login-redirect-url
LOGIN_REDIRECT_URL: str = "users:redirect"
# https://docs.djangoproject.com/en/dev/ref/settings/#login-url
# https://docs.djangoproject.com/en/4.2/ref/settings/#login-url
LOGIN_URL: str = "account_login"

# PASSWORDS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
# https://docs.djangoproject.com/en/4.2/ref/settings/#password-hashers
# For storing passwords, Django will use the first hasher in PASSWORD_HASHERS.
# To store new passwords with a different algorithm, put
# your preferred algorithm first in PASSWORD_HASHERS.
PASSWORD_HASHERS: list[str] = [
# https://docs.djangoproject.com/en/dev/topics/auth/passwords/#using-argon2-with-django
# https://docs.djangoproject.com/en/4.2/topics/auth/passwords/#using-argon2-with-django
# requires 'argon2-cffi' package
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS: list[dict[str, str]] = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa: E501
Expand All @@ -218,7 +222,7 @@ def __get_random_token(length: int) -> str:

# MIDDLEWARE
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#middleware
# https://docs.djangoproject.com/en/4.2/ref/settings/#middleware
MIDDLEWARE: list[str] = [
"django.middleware.security.SecurityMiddleware",
"corsheaders.middleware.CorsMiddleware",
Expand All @@ -235,38 +239,38 @@ def __get_random_token(length: int) -> str:

# STATIC
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#static-root
# https://docs.djangoproject.com/en/4.2/ref/settings/#static-root
STATIC_ROOT: str = str(BASE_DIR / "staticfiles")
# https://docs.djangoproject.com/en/dev/ref/settings/#static-url
# https://docs.djangoproject.com/en/4.2/ref/settings/#static-url
STATIC_URL: str = "/static/"
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
# https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS: list[str] = [str(APPS_DIR / "static")]
# https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders
# https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#staticfiles-finders
STATICFILES_FINDERS: list[str] = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

# MEDIA
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#media-root
# https://docs.djangoproject.com/en/4.2/ref/settings/#media-root
MEDIA_ROOT: str = str(APPS_DIR / "media")
# https://docs.djangoproject.com/en/dev/ref/settings/#media-url
# https://docs.djangoproject.com/en/4.2/ref/settings/#media-url
MEDIA_URL: str = "/media/"

# TEMPLATES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#templates
# https://docs.djangoproject.com/en/4.2/ref/settings/#templates
TEMPLATES: list[dict[str, Any]] = [
{
# https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-TEMPLATES-BACKEND
# https://docs.djangoproject.com/en/4.2/ref/settings/#std:setting-TEMPLATES-BACKEND
"BACKEND": "django.template.backends.django.DjangoTemplates",
# https://docs.djangoproject.com/en/dev/ref/settings/#dirs
# https://docs.djangoproject.com/en/4.2/ref/settings/#dirs
"DIRS": [str(APPS_DIR / "templates")],
# https://docs.djangoproject.com/en/dev/ref/settings/#app-dirs
# https://docs.djangoproject.com/en/4.2/ref/settings/#app-dirs
"APP_DIRS": True,
"OPTIONS": {
# https://docs.djangoproject.com/en/dev/topics/templates/#module-django.template.backends.django
# https://docs.djangoproject.com/en/4.2/topics/templates/#module-django.template.backends.django
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
Expand All @@ -283,7 +287,7 @@ def __get_random_token(length: int) -> str:
},
]

# https://docs.djangoproject.com/en/dev/ref/settings/#form-renderer
# https://docs.djangoproject.com/en/4.2/ref/settings/#form-renderer
FORM_RENDERER: str = "django.forms.renderers.TemplatesSetting"

# http://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs
Expand All @@ -292,21 +296,21 @@ def __get_random_token(length: int) -> str:

# FIXTURES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#fixture-dirs
# https://docs.djangoproject.com/en/4.2/ref/settings/#fixture-dirs
FIXTURE_DIRS: tuple[str] = (str(APPS_DIR / "fixtures"),)

# SECURITY
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-httponly
# https://docs.djangoproject.com/en/4.2/ref/settings/#session-cookie-httponly
SESSION_COOKIE_HTTPONLY: bool = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-httponly
# https://docs.djangoproject.com/en/4.2/ref/settings/#csrf-cookie-httponly
CSRF_COOKIE_HTTPONLY: bool = True
# https://docs.djangoproject.com/en/dev/ref/settings/#x-frame-options
# https://docs.djangoproject.com/en/4.2/ref/settings/#x-frame-options
X_FRAME_OPTIONS: str = "DENY"

# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
# https://docs.djangoproject.com/en/4.2/ref/settings/#email-backend
EMAIL_BACKEND: str = env(
"DJANGO_EMAIL_BACKEND",
default="django.core.mail.backends.smtp.EmailBackend",
Expand All @@ -318,30 +322,30 @@ def __get_random_token(length: int) -> str:
EMAIL_USE_TLS: bool = env("DJANGO_EMAIL_USE_TLS", default=False)
EMAIL_USE_SSL: bool = env("DJANGO_EMAIL_USE_SSL", default=False)

# https://docs.djangoproject.com/en/dev/ref/settings/#email-timeout
# https://docs.djangoproject.com/en/4.2/ref/settings/#email-timeout
EMAIL_TIMEOUT: int = 5

# ADMIN
# ------------------------------------------------------------------------------
# Django Admin URL.
ADMIN_URL: str = "admin/"
# https://docs.djangoproject.com/en/dev/ref/settings/#admins
# https://docs.djangoproject.com/en/4.2/ref/settings/#admins
ADMINS: list[tuple[str, ...]] = [
(
"""Center for Research Computing | University of Notre Dame""",
"crc-sds-list@nd.edu",
),
]
# https://docs.djangoproject.com/en/dev/ref/settings/#managers
# https://docs.djangoproject.com/en/4.2/ref/settings/#managers
MANAGERS: list[tuple[str, ...]] = ADMINS
# https://cookiecutter-django.readthedocs.io/en/latest/settings.html#other-environment-settings
# Force the `admin` sign in process to go through the `django-allauth` workflow
DJANGO_ADMIN_FORCE_ALLAUTH: bool = env.bool("DJANGO_ADMIN_FORCE_ALLAUTH", default=False)

# LOGGING
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#logging
# See https://docs.djangoproject.com/en/dev/topics/logging for
# https://docs.djangoproject.com/en/4.2/ref/settings/#logging
# See https://docs.djangoproject.com/en/4.2/topics/logging for
# more details on how to customize your logging configuration.
LOGGING: dict[str, Any] = {
"version": 1,
Expand Down
8 changes: 4 additions & 4 deletions gateway/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
# https://docs.djangoproject.com/en/4.2/ref/settings/#debug
DEBUG: bool = True
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# https://docs.djangoproject.com/en/4.2/ref/settings/#secret-key
SECRET_KEY: str = env(
"DJANGO_SECRET_KEY",
default="7SGPiDXuHen3CinEGQ4GjOnzHVgcS28Mpbf6zTuHWJtELgpo1FyWs25IeaCR5Sfn",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
# https://docs.djangoproject.com/en/4.2/ref/settings/#allowed-hosts
ALLOWED_HOSTS: list[str] = env.list(
"DJANGO_ALLOWED_HOSTS",
default=[
Expand All @@ -36,7 +36,7 @@

# CACHES
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#caches
# https://docs.djangoproject.com/en/4.2/ref/settings/#caches
CACHES: dict[str, Any] = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
Expand Down
Loading