hotfix: use dashboard/local_settings.py instead of env vars
ci/woodpecker/pr/woodpecker Pipeline failed Details
ci/woodpecker/push/woodpecker Pipeline failed Details

My env var loading technique is not allowing local_settings.py to
override settings.py. This hotfix disables env vars in favor of
local_settings.py.

fixes https://gitea.hostea.org/Hostea/dashboard/issues/3
pull/4/head
Aravinth Manivannan 2022-06-26 01:49:32 +05:30
parent e7446dea2b
commit 3378e61606
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
2 changed files with 38 additions and 28 deletions

View File

@ -9,11 +9,6 @@ https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
import environ
import os
env = environ.Env()
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
@ -31,12 +26,16 @@ ALLOWED_HOSTS = []
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = { DATABASES = {
"default": env.db_url( "default": {
"DATABSE_URL", default="postgres://postgres:password@localhost:5432/postgres" "ENGINE": "django.db.backends.postgresql",
) "NAME": "postgres",
"USER": "postgres",
"PASSWORD": "password",
"HOST": "localhost",
"PORT": "5432",
}
} }
## django-payments configuration ## django-payments configuration
PAYMENT_HOST = "http://localhost:8000" PAYMENT_HOST = "http://localhost:8000"
@ -44,8 +43,8 @@ PAYMENT_VARIANTS = {
"stripe": ( "stripe": (
"payments.stripe.StripeProvider", # please don't change this "payments.stripe.StripeProvider", # please don't change this
{ {
"secret_key": env.get_value("STRIPE_SECRET_KEY"), "secret_key": "",
"public_key": env.get_value("STRIPE_PUBLIC_KEY"), "public_key": "",
}, },
) )
} }
@ -78,6 +77,11 @@ HOSTEA = {
}, },
} }
EMAIL_CONFIG = env.email("EMAIL_URL", default="smtp://admin:password@localhost:10025") # Please see EMAIL_* configuration options:
# https://docs.djangoproject.com/en/4.1/ref/settings/#email-host
vars().update(EMAIL_CONFIG) EMAIL_HOST = "localhost"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
EMAIL_PORT = 10025
EMAIL_HOST_USER = "admin"
EMAIL_HOST_PASSWORD = "password"

View File

@ -9,13 +9,8 @@ https://docs.djangoproject.com/en/4.0/topics/settings/
For the full list of settings and their values, see For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/ https://docs.djangoproject.com/en/4.0/ref/settings/
""" """
import environ
import os
from pathlib import Path from pathlib import Path
env = environ.Env()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -86,9 +81,14 @@ WSGI_APPLICATION = "dashboard.wsgi.application"
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases # https://docs.djangoproject.com/en/4.0/ref/settings/#databases
DATABASES = { DATABASES = {
"default": env.db_url( "default": {
"DATABSE_URL", default="postgres://postgres:password@localhost:5432/postgres" "ENGINE": "django.db.backends.postgresql",
) "NAME": "postgres",
"USER": "postgres",
"PASSWORD": "password",
"HOST": "localhost",
"PORT": "5432",
}
} }
@ -157,8 +157,8 @@ PAYMENT_VARIANTS = {
"stripe": ( "stripe": (
"payments.stripe.StripeProvider", "payments.stripe.StripeProvider",
{ {
"secret_key": env.get_value("STRIPE_SECRET_KEY", default=""), "secret_key": "",
"public_key": env.get_value("STRIPE_PUBLIC_KEY", default=""), "public_key": "",
}, },
) )
} }
@ -192,9 +192,15 @@ HOSTEA = {
}, },
} }
EMAIL_CONFIG = env.email("EMAIL_URL", default="smtp://admin:password@localhost:10025") # Please see EMAIL_* configuration options:
# https://docs.djangoproject.com/en/4.1/ref/settings/#email-host
EMAIL_HOST = "localhost"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = False
EMAIL_PORT = 10025
EMAIL_HOST_USER = "admin"
EMAIL_HOST_PASSWORD = "password"
vars().update(EMAIL_CONFIG)
try: try:
import dashboard.local_settings import dashboard.local_settings