Rename env variable stuff

This commit is contained in:
Daniel Egger 2022-05-25 17:44:07 +02:00
parent 7d233f21ea
commit 5081ddf107
21 changed files with 137 additions and 221 deletions

View File

@ -8,7 +8,7 @@ end_of_line = lf
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{py,rst,ini}] [*.{py,rst,ini,sh}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4

View File

@ -11,38 +11,32 @@ npm run tailwind
# run vue vite dev server # run vue vite dev server
cd client && npm run dev cd client && npm run dev
# run django dev server # reset db and run django dev server
cd server && python manage.py runserver ./prepare_server.sh
``` ```
## Installation ## Installation
See `.tool-versions` file for used django and node version See `.tool-versions` file for used django and node version
You have to set up at least the following environment variables:
```bash
export IT_APP_ENVIRONMENT=development
```
See `.env_secrets/local_daniel.env` for more possible environment variables.
Especially set correct values for `POSTGRES_*` and `DATABASE_URL`
### Server part ### Server part
Run every sub command in the `server` directory The "prepare_server.sh" script will create the database according to `POSTGRE_*` environment variables.
It will also setup the tables for django and run the django development server.
Create a new PostgreSQL database and role
```bash ```bash
createdb vbv_lernwelt # will initial`migrate` and `runserver` etc...
createuser vbv_lernwelt ./prepare_server.sh
```
Set the environment variable accordingly
```bash
export VBV_DATABASE_URL='postgres://vbv_lernwelt@localhost:5432/vbv_lernwelt'
```
Set `VBV_DJANGO_READ_DOT_ENV_FILE=True` to make the config read the `example.env` file (with direnv!?).
```bash
python manage.py migrate
# sync server
python manage.py runserver
# or async server # or async server
# uvicorn config.asgi:application --host 0.0.0.0 --reload # uvicorn config.asgi:application --host 0.0.0.0 --reload
@ -50,8 +44,6 @@ python manage.py runserver
### Client part ### Client part
Run every command in the `client` directory
```bash ```bash
npm install npm install

View File

@ -44,11 +44,11 @@ cap.create_and_update_app(
image_name='docker.io/iterativ/vbv-lernwelt-django', image_name='docker.io/iterativ/vbv-lernwelt-django',
environment_variables={ environment_variables={
# 'DJANGO_SETTINGS_MODULE': 'config.settings.base', # 'DJANGO_SETTINGS_MODULE': 'config.settings.base',
'VBV_DJANGO_SECRET_KEY': env.str('VBV_DJANGO_SECRET_KEY'), 'IT_DJANGO_SECRET_KEY': env.str('IT_DJANGO_SECRET_KEY'),
'VBV_DJANGO_ADMIN_URL': env.str('VBV_DJANGO_ADMIN_URL'), 'IT_DJANGO_ADMIN_URL': env.str('IT_DJANGO_ADMIN_URL'),
'VBV_DJANGO_ALLOWED_HOSTS': env.str('VBV_DJANGO_ALLOWED_HOSTS'), 'IT_DJANGO_ALLOWED_HOSTS': env.str('IT_DJANGO_ALLOWED_HOSTS'),
'VBV_SENTRY_DSN': env.str('VBV_SENTRY_DSN'), 'IT_SENTRY_DSN': env.str('IT_SENTRY_DSN'),
'VBV_DJANGO_DEV_MODE': 'caprover', 'IT_APP_ENVIRONMENT': 'caprover',
'POSTGRES_HOST': 'srv-captain--vbv-lernwelt-postgres-db', 'POSTGRES_HOST': 'srv-captain--vbv-lernwelt-postgres-db',
'POSTGRES_PORT': 5432, 'POSTGRES_PORT': 5432,
'POSTGRES_DB': db_name, 'POSTGRES_DB': db_name,

View File

@ -13,9 +13,9 @@ if [ -z "${POSTGRES_USER}" ]; then
base_postgres_image_default_user='postgres' base_postgres_image_default_user='postgres'
export POSTGRES_USER="${base_postgres_image_default_user}" export POSTGRES_USER="${base_postgres_image_default_user}"
fi fi
export VBV_DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" export DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}"
echo $VBV_DATABASE_URL echo $DATABASE_URL
postgres_ready() { postgres_ready() {
python << END python << END

View File

@ -8,5 +8,5 @@ POSTGRES_PASSWORD=hNqfCdG6bwCLcnfboDtNM1L2Hiwp8GuKp1DJ6t2rcKl15Vls2QbByoIZ6IQlci
# General # General
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
VBV_DJANGO_LOCAL_DOCKER=True IT_DJANGO_LOCAL_DOCKER=True
IPYTHONDIR=/app/.ipython IPYTHONDIR=/app/.ipython

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
example.env Normal file
View File

@ -0,0 +1 @@
export IT_APP_ENVIRONMENT='development'

View File

@ -1,45 +0,0 @@
#!/bin/bash
#export DATABASE_HOST=postgres
#export DATABASE_PORT=5432
#export DATABASE_URL=postgres://$DATABASE_USER:$PG_PASSWORD@$DATABASE_HOST:$DATABASE_PORT/$DATABASE_NAME
#
#echo $DATABASE_URL
#DJANGO_SETTINGS_MODULE=config.settings.base
#DATABASE_NAME=vbv_lernwelt
SKIP_SETUP=false
##
echo "Setting up VBV Project for Local usage"
if [ "$SKIP_SETUP" = false ]; then
if [ -z "$PG_PORT" ]; then # if the port is set in the env, use iterg
DB_PORT="";
else
DB_PORT="-p $PG_PORT";
fi
if [ -z "$PG_USER" ]; then # if the user is set in the env, use it
DB_USER="";
else
DB_USER="-U $PG_USER";
fi
echo "psql -h localhost --port=$DB_PORT --username=$DB_USER -c 'drop database if exists' $DATABASE_NAME;"
echo "Drop all connections to the database"
psql -h localhost --port=$DB_PORT --username=$DB_USER -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DATABASE_NAME' AND pid <> pg_backend_pid();"
echo "Drop database: $DATABASE_NAME"
psql -h localhost --port=$DB_PORT --username=$DB_USER -c "drop database if exists $DATABASE_NAME;"
echo "Create database: $DATABASE_NAME"
psql -h localhost --port=$DB_PORT --username=$DB_USER -c "create database $DATABASE_NAME;"
# reset data
python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py create_default_users --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py create_default_learningpath --settings="$DJANGO_SETTINGS_MODULE"
#
# # make django translations
(cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE")
fi

69
prepare_server.sh Executable file
View File

@ -0,0 +1,69 @@
#!/bin/bash
if [ -z "$CI" ];
then
# kill all subprocess on exit
trap "exit" INT TERM ERR
trap "kill 0" EXIT
else echo "CI is set to $CI";
fi
# script should fail when any process returns non zero code
set -ev
# handle arguments
SKIP_SETUP=false
START_BACKGROUND=false
for i in "$@"
do
case $i in
--start-background)
START_BACKGROUND=true
shift # past argument
;;
--skip-setup)
SKIP_SETUP=true
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
echo "SKIP_SETUP = ${SKIP_SETUP}"
POSTGRES_DB=${POSTGRES_DB:-vbv_lernwelt}
DJANGO_PORT=${DJANGO_PORT:-8000}
mypsql() {
psql -h "${POSTGRES_HOST:-localhost}" -p "${POSTGRES_PORT:-5432}" -U "${POSTGRES_USER:-postgres}" "$@"
}
if [ "$SKIP_SETUP" = false ]; then
echo "Drop all connections to $POSTGRES_DB"
mypsql -c "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$POSTGRES_DB' AND pid <> pg_backend_pid();" > /dev/null 2>&1
echo "Drop database: $POSTGRES_DB"
mypsql -c "drop database if exists $POSTGRES_DB;"
echo "Create database: $POSTGRES_DB"
mypsql -c "create database $POSTGRES_DB;"
echo "initialize database for django"
python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py create_default_users --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py create_default_learningpath --settings="$DJANGO_SETTINGS_MODULE"
# make django translations
(cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE")
else
echo "else"
# python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE"
fi
if [ "$START_BACKGROUND" = true ]; then
python3 server/manage.py runserver "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE" > /dev/null &
else
python3 server/manage.py runserver "${DJANGO_PORT}" --settings="$DJANGO_SETTINGS_MODULE"
fi

View File

@ -1,91 +1,6 @@
#!/bin/bash export POSTGRES_DB=vbv_lernwelt_cypress
export DJANGO_PORT=8001
export DJANGO_SETTINGS_MODULE=config.settings.test_cypress
export IT_APP_ENVIRONMENT=development
if [ -z "$CI" ]; ./prepare_server.sh "$@"
then
# kill all subprocess on exit
trap "exit" INT TERM ERR
trap "kill 0" EXIT
else echo "CI is set to $CI";
fi
# script should fail when any process returns non zero code
set -ev
# handle arguments
SKIP_SETUP=false
START_BACKGROUND=false
PROXY_VUE=false
for i in "$@"
do
case $i in
--start-background)
START_BACKGROUND=true
shift # past argument
;;
--skip-setup)
SKIP_SETUP=true
shift # past argument with no value
;;
--proxy-vue)
PROXY_VUE=true
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
echo "SKIP_SETUP = ${SKIP_SETUP}"
DJANGO_SETTINGS_MODULE=config.settings.test_cypress
CYPRESS_DB=vbv_lernwelt_cypress
if [ "$SKIP_SETUP" = false ]; then
if [ -z "$PG_PORT" ]; then # if the port is set in the env, use iterg
DB_PORT="";
else
DB_PORT="-p $PG_PORT";
fi
if [ -z "$PG_USER" ]; then # if the user is set in the env, use it
DB_USER="";
else
DB_USER="-U $PG_USER";
fi
echo "psql -h localhost $DB_PORT $DB_USER -c 'drop database if exists $CYPRESS_DB;'"
# create database
psql -h localhost $DB_PORT $DB_USER -c "drop database if exists $CYPRESS_DB;"
psql -h localhost $DB_PORT $DB_USER -c "create database $CYPRESS_DB;"
# reset data
# python3 src/manage.py randomdata --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py createcachetable --settings="$DJANGO_SETTINGS_MODULE"
python3 server/manage.py migrate --settings="$DJANGO_SETTINGS_MODULE"
# make django translations
(cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE")
else
echo "else"
# python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE"
fi
if [ "$PROXY_VUE" = true ]; then
export DJANGO_VUE_LANDINGPAGE_PROXY=http://localhost:8080/
fi
# install cypress here to avoid problems with `npm install` on the iesc servers
#CYPRESS_INSTALLED=0
##npx --no-install cypress --version || CYPRESS_INSTALLED=$?
#if [ $CYPRESS_INSTALLED -ne 0 ]; then
# echo "install cypress"
## npm install cypress@5.6.0 @testing-library/cypress@7.0.2 --no-save
#fi
if [ "$START_BACKGROUND" = true ]; then
python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE" > /dev/null &
else
python3 server/manage.py runserver 8001 --settings="$DJANGO_SETTINGS_MODULE"
fi

View File

@ -10,21 +10,17 @@ from environs import Env
from vbv_lernwelt.core.utils import structlog_add_app_info from vbv_lernwelt.core.utils import structlog_add_app_info
SERVER_ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent SERVER_ROOT_DIR = Path(__file__).resolve(strict=True).parent.parent.parent
# vbv_lernwelt/
APPS_DIR = SERVER_ROOT_DIR / "vbv_lernwelt" APPS_DIR = SERVER_ROOT_DIR / "vbv_lernwelt"
env = Env() env = Env()
READ_DOT_ENV_FILE = env.bool("VBV_DJANGO_READ_DOT_ENV_FILE", default=False) # set to "development" for local development
if READ_DOT_ENV_FILE: APP_ENVIRONMENT = env("IT_APP_ENVIRONMENT")
# OS environment variables take precedence over variables from .env
env.read_env(str(SERVER_ROOT_DIR / "example.env"))
DJANGO_DEV_MODE = env("VBV_DJANGO_DEV_MODE", default="development")
# GENERAL # GENERAL
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#debug # https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool("VBV_DJANGO_DEBUG", False) DEBUG = env.bool("IT_DJANGO_DEBUG", True if APP_ENVIRONMENT == "development" else False)
# Local time zone. Choices are # Local time zone. Choices are
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# though not all of them may be available with every OS. # though not all of them may be available with every OS.
@ -48,8 +44,8 @@ LOCALE_PATHS = [str(SERVER_ROOT_DIR / "locale")]
# https://docs.djangoproject.com/en/dev/ref/settings/#databases # https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = { DATABASES = {
"default": env.dj_db_url( "default": env.dj_db_url(
"VBV_DATABASE_URL", "DATABASE_URL",
default="postgres://vbv_lernwelt@localhost:5432/vbv_lernwelt", default="postgres://postgres@localhost:5432/vbv_lernwelt",
) )
} }
DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405 DATABASES["default"]["ATOMIC_REQUESTS"] = True # noqa F405
@ -308,11 +304,14 @@ MANAGERS = ADMINS
# https://docs.djangoproject.com/en/dev/ref/settings/#logging # https://docs.djangoproject.com/en/dev/ref/settings/#logging
# See https://docs.djangoproject.com/en/dev/topics/logging for # See https://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration. # more details on how to customize your logging configuration.
VBV_DJANGO_LOGGING_CONF = env(
"VBV_DJANGO_LOGGING_CONF", default="VBV_DJANGO_LOGGING_CONF_JSON_FILE"
)
if VBV_DJANGO_LOGGING_CONF == "VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR": logging_conf_default = "IT_DJANGO_LOGGING_CONF_JSON_FILE"
if DEBUG:
logging_conf_default = "IT_DJANGO_LOGGING_CONF_CONSOLE_COLOR"
IT_DJANGO_LOGGING_CONF = env("IT_DJANGO_LOGGING_CONF", default=logging_conf_default)
if IT_DJANGO_LOGGING_CONF == "IT_DJANGO_LOGGING_CONF_CONSOLE_COLOR":
timestamper = structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S") timestamper = structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S")
LOGGING = { LOGGING = {
"version": 1, "version": 1,
@ -476,12 +475,12 @@ SPECTACULAR_SETTINGS = {
SECRET_KEY = env( SECRET_KEY = env(
"VBV_DJANGO_SECRET_KEY", "IT_DJANGO_SECRET_KEY",
default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq", default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq",
) )
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts # https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = env.list( ALLOWED_HOSTS = env.list(
"VBV_DJANGO_ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1"] "IT_DJANGO_ALLOWED_HOSTS", default=["localhost", "0.0.0.0", "127.0.0.1"]
) )
@ -489,21 +488,21 @@ ALLOWED_HOSTS = env.list(
CACHES = { CACHES = {
"default": { "default": {
"BACKEND": env( "BACKEND": env(
"VBV_DJANGO_CACHE_BACKEND", "IT_DJANGO_CACHE_BACKEND",
default="django.core.cache.backends.db.DatabaseCache", default="django.core.cache.backends.db.DatabaseCache",
), ),
"LOCATION": env("VBV_DJANGO_CACHE_LOCATION", default="django_cache_table"), "LOCATION": env("IT_DJANGO_CACHE_LOCATION", default="django_cache_table"),
} }
} }
if "django_redis.cache.RedisCache" in env("VBV_DJANGO_CACHE_BACKEND", default=""): if "django_redis.cache.RedisCache" in env("IT_DJANGO_CACHE_BACKEND", default=""):
CACHES = { CACHES = {
"default": { "default": {
"BACKEND": env( "BACKEND": env(
"VBV_DJANGO_CACHE_BACKEND", "IT_DJANGO_CACHE_BACKEND",
default="django.core.cache.backends.db.DatabaseCache", default="django.core.cache.backends.db.DatabaseCache",
), ),
"LOCATION": env("VBV_DJANGO_CACHE_LOCATION", default="django_cache_table"), "LOCATION": env("IT_DJANGO_CACHE_LOCATION", default="django_cache_table"),
"OPTIONS": { "OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient", "CLIENT_CLASS": "django_redis.client.DefaultClient",
# Mimicing memcache behavior. # Mimicing memcache behavior.
@ -530,7 +529,7 @@ OAUTH = {
} }
} }
if DJANGO_DEV_MODE == "development": if APP_ENVIRONMENT == "development":
# http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development # http://whitenoise.evans.io/en/latest/django.html#using-whitenoise-in-development
INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405 INSTALLED_APPS = ["whitenoise.runserver_nostatic"] + INSTALLED_APPS # noqa F405
@ -547,7 +546,7 @@ if DJANGO_DEV_MODE == "development":
# } # }
# https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#internal-ips
INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"] INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]
if env.bool("VBV_DJANGO_LOCAL_DOCKER", False): if env.bool("IT_DJANGO_LOCAL_DOCKER", False):
import socket import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
@ -564,13 +563,13 @@ if DJANGO_DEV_MODE == "development":
# https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration # https://django-extensions.readthedocs.io/en/latest/installation_instructions.html#configuration
INSTALLED_APPS += ["django_extensions"] # noqa F405 INSTALLED_APPS += ["django_extensions"] # noqa F405
if DJANGO_DEV_MODE in ["production", "caprover"]: if APP_ENVIRONMENT in ["production", "caprover"]:
# SECURITY # SECURITY
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header # https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect # https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
SECURE_SSL_REDIRECT = env.bool("VBV_DJANGO_SECURE_SSL_REDIRECT", default=True) SECURE_SSL_REDIRECT = env.bool("IT_DJANGO_SECURE_SSL_REDIRECT", default=True)
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure # https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
SESSION_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure # https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
@ -604,7 +603,7 @@ if DJANGO_DEV_MODE in ["production", "caprover"]:
default="VBV Lernwelt <info@iterativ.ch>", default="VBV Lernwelt <info@iterativ.ch>",
) )
# https://docs.djangoproject.com/en/dev/ref/settings/#server-email # https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = env("VBV_DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL) SERVER_EMAIL = env("IT_DJANGO_SERVER_EMAIL", default=DEFAULT_FROM_EMAIL)
# https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix # https://docs.djangoproject.com/en/dev/ref/settings/#email-subject-prefix
EMAIL_SUBJECT_PREFIX = env( EMAIL_SUBJECT_PREFIX = env(
"DJANGO_EMAIL_SUBJECT_PREFIX", "DJANGO_EMAIL_SUBJECT_PREFIX",
@ -614,7 +613,7 @@ if DJANGO_DEV_MODE in ["production", "caprover"]:
# ADMIN # ADMIN
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Django Admin URL regex. # Django Admin URL regex.
ADMIN_URL = env("VBV_DJANGO_ADMIN_URL") ADMIN_URL = env("IT_DJANGO_ADMIN_URL", 'admin/')
# Anymail # Anymail
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -633,7 +632,7 @@ if DJANGO_DEV_MODE in ["production", "caprover"]:
from sentry_sdk.integrations.logging import LoggingIntegration from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.redis import RedisIntegration from sentry_sdk.integrations.redis import RedisIntegration
SENTRY_DSN = env("VBV_SENTRY_DSN") SENTRY_DSN = env("IT_SENTRY_DSN")
SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO) SENTRY_LOG_LEVEL = env.int("DJANGO_SENTRY_LOG_LEVEL", logging.INFO)
sentry_logging = LoggingIntegration( sentry_logging = LoggingIntegration(

View File

@ -9,7 +9,7 @@ from .base import env
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env( SECRET_KEY = env(
"VBV_DJANGO_SECRET_KEY", "IT_DJANGO_SECRET_KEY",
default="1NpUCSvAKLpDZL9e3tqDaUe8Kk2xAuF1tXosFjBanc4lFCgNcfBp02MD3UjB72ZS", default="1NpUCSvAKLpDZL9e3tqDaUe8Kk2xAuF1tXosFjBanc4lFCgNcfBp02MD3UjB72ZS",
) )
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner # https://docs.djangoproject.com/en/dev/ref/settings/#test-runner

View File

@ -9,7 +9,7 @@ from .base import env
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env( SECRET_KEY = env(
"VBV_DJANGO_SECRET_KEY", "IT_DJANGO_SECRET_KEY",
default="1LhwZ0DvP4cGBgbBdCfaBQV7eiaOc4jWKdzO9WEXLFT7AaqBN6jqd0uyaZeAZ19K", default="1LhwZ0DvP4cGBgbBdCfaBQV7eiaOc4jWKdzO9WEXLFT7AaqBN6jqd0uyaZeAZ19K",
) )

View File

@ -1,11 +0,0 @@
export VBV_DATABASE_URL='postgres://vbv_lernwelt@localhost:5432/vbv_lernwelt'
#export VBV_DJANGO_LOGGING_CONF=VBV_DJANGO_LOGGING_CONF_CONSOLE_COLOR
export VBV_DJANGO_DEBUG=True
# oauth is for the moment not used
export OAUTH_CLIENT_ID=iterativ
export OAUTH_CLIENT_SECRET=abced-1234
export OAUTH_ACCESS_TOKEN_URL=https://sso.test.b.lernetz.host/auth/realms/vbv/protocol/openid-connect/token
export OAUTH_AUTHORIZE_URL=https://sso.test.b.lernetz.host/auth/realms/vbv/protocol/openid-connect/auth
export OAUTH_API_BASE_URL=https://sso.test.b.lernetz.host/auth/realms/vbv/protocol/openid-connect/
export OAUTH_LOCAL_REDIRECT_URI=http://localhost:8000/api/oauth/callback/

View File

@ -9,13 +9,11 @@ def create_default_users(user_model=User, group_model=Group):
content_creator_grop, created = group_model.objects.get_or_create(name='content_creator_grop') content_creator_grop, created = group_model.objects.get_or_create(name='content_creator_grop')
student_group, created = group_model.objects.get_or_create(name='student_group') student_group, created = group_model.objects.get_or_create(name='student_group')
admin_user, created = _get_or_create_user(user_model=user_model, admin_user, created = _get_or_create_user(user_model=user_model, username='admin', password='admin')
username='admin',
password='admin')
admin_user.is_superuser = True admin_user.is_superuser = True
admin_user.groups.add(admin_group) admin_user.groups.add(admin_group)
admin_user.save() admin_user.save()
student_user, created = _get_or_create_user(user_model=user_model, username='student', password='student') student_user, created = _get_or_create_user(user_model=user_model, username='student', password='student')
student_user.groups.add(student_group) student_user.groups.add(student_group)
student_user.save() student_user.save()

View File

@ -10,8 +10,8 @@ def structlog_add_app_info(
logger: logging.Logger, method_name: str, event_dict: EventDict logger: logging.Logger, method_name: str, event_dict: EventDict
) -> EventDict: ) -> EventDict:
event_dict["django_app"] = "vbv_lernwelt" event_dict["django_app"] = "vbv_lernwelt"
event_dict["django_dev_mode"] = settings.DJANGO_DEV_MODE event_dict["APP_ENVIRONMENT"] = settings.APP_ENVIRONMENT
event_dict["django_app_dev_mode"] = f"vbv_lernwelt_{settings.DJANGO_DEV_MODE}" event_dict["django_app_dev_mode"] = f"vbv_lernwelt_{settings.APP_ENVIRONMENT}"
return event_dict return event_dict

View File

@ -19,8 +19,9 @@ def vue_home(request):
content_type = headers.get('content-type', 'text/html') content_type = headers.get('content-type', 'text/html')
return HttpResponse(res.text, content_type=content_type) return HttpResponse(res.text, content_type=content_type)
except Exception as e: except Exception as e:
print(f'Can not connect to vue dev server at {settings.IT_SERVE_VUE_URL}:', e) return HttpResponse(
return f'Can not connect to vue dev server at {settings.IT_SERVE_VUE_URL}: {e}'
)
# render index.html from `npm run build` # render index.html from `npm run build`
return render(request, 'index.html', {}) return render(request, 'index.html', {})

View File

@ -159,9 +159,6 @@ von Neukunden zu benützen
circle_7 = CircleFactory.create(title="Prüfungsvorbereitung", parent=lp, topic=tp) circle_7 = CircleFactory.create(title="Prüfungsvorbereitung", parent=lp, topic=tp)
def delete_default_learning_path(): def delete_default_learning_path():
LearningUnit.objects.all().delete() LearningUnit.objects.all().delete()
LearningSequence.objects.all().delete() LearningSequence.objects.all().delete()