Update docs and scripts

This commit is contained in:
Daniel Egger 2022-05-27 11:01:08 +02:00
parent 5081ddf107
commit a431f35743
8 changed files with 38 additions and 67 deletions

View File

@ -31,7 +31,13 @@ Especially set correct values for `POSTGRES_*` and `DATABASE_URL`
### Server part ### Server part
The "prepare_server.sh" script will create the database according to `POSTGRE_*` environment variables. Install python dependencies:
```bash
pip install -r server/requirements/requirements-dev.txt
```
The "prepare_server.sh" script will create the database according to `POSTGRES_*` environment variables.
It will also setup the tables for django and run the django development server. It will also setup the tables for django and run the django development server.
```bash ```bash
@ -45,6 +51,8 @@ It will also setup the tables for django and run the django development server.
### Client part ### Client part
```bash ```bash
cd client
npm install npm install
# run dev server # run dev server
@ -56,6 +64,7 @@ npm run dev
Cypress and TailwindCSS ist installed for client and server, so there is this package.json on the project root directory Cypress and TailwindCSS ist installed for client and server, so there is this package.json on the project root directory
```bash ```bash
# in project root directory
npm install npm install
``` ```
@ -82,8 +91,6 @@ npm install
#### Install the tailwind css Plugin from Jetbrains #### Install the tailwind css Plugin from Jetbrains
## Wagtail API intro ## Wagtail API intro
get all pages: get all pages:

View File

@ -2,7 +2,7 @@
if [ -z "$CI" ]; if [ -z "$CI" ];
then then
# kill all subprocess on exit # kill all subprocess on exit so that Bitbucket Pipelines process will not hang
trap "exit" INT TERM ERR trap "exit" INT TERM ERR
trap "kill 0" EXIT trap "kill 0" EXIT
else echo "CI is set to $CI"; else echo "CI is set to $CI";
@ -35,13 +35,17 @@ done
echo "SKIP_SETUP = ${SKIP_SETUP}" echo "SKIP_SETUP = ${SKIP_SETUP}"
POSTGRES_DB=${POSTGRES_DB:-vbv_lernwelt} POSTGRES_DB=${POSTGRES_DB:-vbv_lernwelt}
POSTGRES_HOST=${POSTGRES_HOST:-localhost}
POSTGRES_PORT=${POSTGRES_PORT:-5432}
POSTGRES_USER=${POSTGRES_USER:-postgres}
DJANGO_PORT=${DJANGO_PORT:-8000} DJANGO_PORT=${DJANGO_PORT:-8000}
mypsql() { mypsql() {
psql -h "${POSTGRES_HOST:-localhost}" -p "${POSTGRES_PORT:-5432}" -U "${POSTGRES_USER:-postgres}" "$@" psql -h "${POSTGRES_HOST}" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" "$@"
} }
if [ "$SKIP_SETUP" = false ]; then if [ "$SKIP_SETUP" = false ]; then
# TODO: in heroku we must do a `pg:resets` to reset the db
echo "Drop all connections to $POSTGRES_DB" 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 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" echo "Drop database: $POSTGRES_DB"
@ -58,8 +62,9 @@ if [ "$SKIP_SETUP" = false ]; then
# make django translations # make django translations
(cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE") (cd server && python3 manage.py compilemessages --settings="$DJANGO_SETTINGS_MODULE")
else else
echo "else" # TODO: can we reset important data without resetting the database?
# python3 src/manage.py recreate_customer_data_for_integration_tests --settings="$DJANGO_SETTINGS_MODULE" echo "Skip database setup"
# python3 src/manage.py cypress_reset --settings="$DJANGO_SETTINGS_MODULE"
fi fi
if [ "$START_BACKGROUND" = true ]; then if [ "$START_BACKGROUND" = true ]; then

View File

@ -1,6 +1,6 @@
export POSTGRES_DB=vbv_lernwelt_cypress
export DJANGO_PORT=8001
export DJANGO_SETTINGS_MODULE=config.settings.test_cypress
export IT_APP_ENVIRONMENT=development export IT_APP_ENVIRONMENT=development
export DJANGO_SETTINGS_MODULE=config.settings.test_cypress
export DJANGO_PORT=8001
export POSTGRES_DB=vbv_lernwelt_cypress
./prepare_server.sh "$@" ./prepare_server.sh "$@"

View File

@ -473,11 +473,14 @@ SPECTACULAR_SETTINGS = {
# Your stuff... # Your stuff...
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
if DEBUG:
SECRET_KEY = env(
"IT_DJANGO_SECRET_KEY",
default="J9FiYN31FuY7lHrmx9Mpai3GGpTVCxakEclOfCLretDe7bTf2DtTsgazJ0aIMtbq",
)
else:
SECRET_KEY = env("IT_DJANGO_SECRET_KEY")
SECRET_KEY = env(
"IT_DJANGO_SECRET_KEY",
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(
"IT_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"]

View File

@ -1,27 +1,17 @@
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
import getpass
import os import os
os.environ['IT_APP_ENVIRONMENT'] = 'development'
from .base import * # noqa from .base import * # noqa
from .base import env from .base import env
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env(
"IT_DJANGO_SECRET_KEY",
default="1NpUCSvAKLpDZL9e3tqDaUe8Kk2xAuF1tXosFjBanc4lFCgNcfBp02MD3UjB72ZS",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#test-runner # https://docs.djangoproject.com/en/dev/ref/settings/#test-runner
TEST_RUNNER = "django.test.runner.DiscoverRunner" TEST_RUNNER = "django.test.runner.DiscoverRunner"
# PASSWORDS
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers # https://docs.djangoproject.com/en/dev/ref/settings/#password-hashers
PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"] PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]
# EMAIL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend # https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
@ -35,18 +25,3 @@ class DisableMigrations(dict):
MIGRATION_MODULES = DisableMigrations() MIGRATION_MODULES = DisableMigrations()
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "vbv_lernwelt_test",
"USER": os.environ.get("PG_USER", getpass.getuser()),
"PASSWORD": os.environ.get("PG_PASSWORD"),
"HOST": "localhost",
"PORT": os.environ.get("PG_PORT", ""),
}
}
# Your stuff...
# ------------------------------------------------------------------------------

View File

@ -1,17 +1,11 @@
# pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position
import getpass
import os
from .base import * # noqa from .base import * # noqa
from .base import env
# GENERAL # GENERAL
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
SECRET_KEY = env( DATABASES['default']['NAME'] = 'vbv_lernwelt_cypress'
"IT_DJANGO_SECRET_KEY",
default="1LhwZ0DvP4cGBgbBdCfaBQV7eiaOc4jWKdzO9WEXLFT7AaqBN6jqd0uyaZeAZ19K",
)
# EMAIL # EMAIL
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -19,19 +13,6 @@ SECRET_KEY = env(
EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend"
CYPRESS_TEST = True CYPRESS_TEST = True
DEBUG = True
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "vbv_lernwelt_cypress",
"USER": os.environ.get("PG_USER", getpass.getuser()),
"PASSWORD": os.environ.get("PG_PASSWORD"),
"HOST": "localhost",
"PORT": os.environ.get("PG_PORT", ""),
}
}
# Your stuff... # Your stuff...
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View File

@ -1,7 +1,6 @@
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
import djclick as click import djclick as click
from django.contrib.auth import get_user_model
from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path from vbv_lernwelt.learnpath.tests.create_default_learning_path import create_default_learning_path

View File

@ -2,9 +2,9 @@ import wagtail_factories
from wagtail.core.models import Site from wagtail.core.models import Site
from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningUnit from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningUnit
from vbv_lernwelt.learnpath.tests.create_default_competences import create_default_competences
from vbv_lernwelt.learnpath.tests.learningpath_factories import LearningPathFactory, TopicFactory, CircleFactory, \ from vbv_lernwelt.learnpath.tests.learningpath_factories import LearningPathFactory, TopicFactory, CircleFactory, \
LearningSequenceFactory, LearningUnitFactory, VideoBlockFactory, WebBasedTrainingBlockFactory, LearningPackageFactory LearningSequenceFactory, LearningUnitFactory, VideoBlockFactory, WebBasedTrainingBlockFactory, \
LearningPackageFactory
def create_default_learning_path(): def create_default_learning_path():
@ -22,9 +22,10 @@ def create_default_learning_path():
tp = TopicFactory(title="Basis", is_visible=False, learning_path=lp) tp = TopicFactory(title="Basis", is_visible=False, learning_path=lp)
circle_1 = CircleFactory(title="Basis", parent=lp, topic=tp, description="""In diesem Circle erklären wir dir, wie der Lehrgang circle_1 = CircleFactory(title="Basis", parent=lp, topic=tp, description="""
Versicherungsvermittler / in " aufgebaut ist. Zudem vermitteln wir dir die wichtigsten Grundlagen, In diesem Circle erklären wir dir, wie der Lehrgang
damit erfolgreich mit deinem Lernpfad starten kannst.""") Versicherungsvermittler / in " aufgebaut ist. Zudem vermitteln wir dir die wichtigsten Grundlagen,
damit erfolgreich mit deinem Lernpfad starten kannst.""")
ls_1 = LearningSequenceFactory(title='Einleitung', circle=circle_1) ls_1 = LearningSequenceFactory(title='Einleitung', circle=circle_1)