diff --git a/.editorconfig b/.editorconfig index 6a9a5c45..8ac421b7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,7 +12,7 @@ trim_trailing_whitespace = true indent_style = space indent_size = 4 -[*.{html,css,scss,json,yml,xml}] +[*.{html,css,scss,json,yml,js,vue,ts,md,xml}] indent_style = space indent_size = 2 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..2eb57b52 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +nodejs 16.10.0 +python 3.10.0 diff --git a/README.md b/README.md index ba101e7b..82a56260 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,50 @@ # VBV Lernwelt -Behold My Awesome Project! +Project setup is based on [cookiecutter-django](https://github.com/cookiecutter/cookiecutter-django) project template. -[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter)](https://github.com/cookiecutter/cookiecutter-django/) -[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) +## Installation -## Settings +See `.tool-versions` file for used django and node version -Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings.html). +Create a new PostgreSQL database and role -## Basic Commands +```bash +createdb vbv_lernwelt +createuser vbv_lernwelt +``` -### Setting Up Your Users +Set the environment variable accordingly -- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go. +```bash +export DATABASE_URL='postgres://vbv_lernwelt@localhost:5432/vbv_lernwelt' +``` -- To create an **superuser account**, use this command: +Set `DJANGO_READ_DOT_ENV_FILE=True` to make the config read the `example.env` file (with direnv!?). - $ python manage.py createsuperuser +Apply migrations and run async server -For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. +```bash +python manage.py migrate -### Type checks +# sync server +python manage.py runserver -Running type checks with mypy: +# or async server +uvicorn config.asgi:application --host 0.0.0.0 --reload +``` - $ mypy vbv_lernwelt +## SASS Live-Reloading -### Test coverage +```bash +# start django server... +# live reloading is hardcoded via proxy to port 8000 -> django server must get started manually +npm run dev -To run the tests, check your test coverage, and generate an HTML coverage report: +# open site with http://localhost:3000 +``` - $ coverage run -m pytest - $ coverage html - $ open htmlcov/index.html +## IntelliJ Configuration -#### Running tests with pytest - - $ pytest - -### Live reloading and Sass CSS compilation - -Moved to [Live reloading and SASS compilation](http://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html). - -### Sentry - -Sentry is an error logging aggregator service. You can sign up for a free account at or download and host it yourself. -The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application. - -You must set the DSN url in production. - -## Deployment - -The following details how to deploy this application. - -### Docker - -See detailed [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html). +* In the .idea/vbv_lernwelt.iml file change the module type to "PYTHON_MODULE". +* Add django facet in "Project Structure". +* Run configuration with "Python -> server.py" to have async debugging support. diff --git a/README_generated.md b/README_generated.md new file mode 100644 index 00000000..ba101e7b --- /dev/null +++ b/README_generated.md @@ -0,0 +1,59 @@ +# VBV Lernwelt + +Behold My Awesome Project! + +[![Built with Cookiecutter Django](https://img.shields.io/badge/built%20with-Cookiecutter%20Django-ff69b4.svg?logo=cookiecutter)](https://github.com/cookiecutter/cookiecutter-django/) +[![Black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) + +## Settings + +Moved to [settings](http://cookiecutter-django.readthedocs.io/en/latest/settings.html). + +## Basic Commands + +### Setting Up Your Users + +- To create a **normal user account**, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go. + +- To create an **superuser account**, use this command: + + $ python manage.py createsuperuser + +For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users. + +### Type checks + +Running type checks with mypy: + + $ mypy vbv_lernwelt + +### Test coverage + +To run the tests, check your test coverage, and generate an HTML coverage report: + + $ coverage run -m pytest + $ coverage html + $ open htmlcov/index.html + +#### Running tests with pytest + + $ pytest + +### Live reloading and Sass CSS compilation + +Moved to [Live reloading and SASS compilation](http://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html). + +### Sentry + +Sentry is an error logging aggregator service. You can sign up for a free account at or download and host it yourself. +The system is set up with reasonable defaults, including 404 logging and integration with the WSGI application. + +You must set the DSN url in production. + +## Deployment + +The following details how to deploy this application. + +### Docker + +See detailed [cookiecutter-django Docker documentation](http://cookiecutter-django.readthedocs.io/en/latest/deployment-with-docker.html). diff --git a/config/settings/base.py b/config/settings/base.py index 95f973c3..f7fec8fa 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -13,7 +13,7 @@ env = environ.Env() READ_DOT_ENV_FILE = env.bool("DJANGO_READ_DOT_ENV_FILE", default=False) if READ_DOT_ENV_FILE: # OS environment variables take precedence over variables from .env - env.read_env(str(ROOT_DIR / ".env")) + env.read_env(str(ROOT_DIR / "example.env")) # GENERAL # ------------------------------------------------------------------------------ diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index eaa1f77b..00000000 --- a/docs/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = ./_build -APP = /app - -.PHONY: help livehtml apidocs Makefile - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -c . - -# Build, watch and serve docs with live reload -livehtml: - sphinx-autobuild -b html --host 0.0.0.0 --port 7000 --watch $(APP) -c . $(SOURCEDIR) $(BUILDDIR)/html - -# Outputs rst files from django application code -apidocs: - sphinx-apidoc -o $(SOURCEDIR)/api $(APP) - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -c . diff --git a/docs/__init__.py b/docs/__init__.py deleted file mode 100644 index 8772c827..00000000 --- a/docs/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Included so that Django's startproject comment runs against the docs directory diff --git a/docs/conf.py b/docs/conf.py deleted file mode 100644 index 899845ef..00000000 --- a/docs/conf.py +++ /dev/null @@ -1,62 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. - -import os -import sys -import django - -if os.getenv("READTHEDOCS", default=False) == "True": - sys.path.insert(0, os.path.abspath("..")) - os.environ["DJANGO_READ_DOT_ENV_FILE"] = "True" - os.environ["USE_DOCKER"] = "no" -else: - sys.path.insert(0, os.path.abspath("/app")) -os.environ["DATABASE_URL"] = "sqlite:///readthedocs.db" -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local") -django.setup() - -# -- Project information ----------------------------------------------------- - -project = "VBV Lernwelt" -copyright = """2022, Daniel Egger""" -author = "Daniel Egger" - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.napoleon", -] - -# Add any paths that contain templates here, relative to this directory. -# templates_path = ["_templates"] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "alabaster" - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -# html_static_path = ["_static"] diff --git a/docs/howto.rst b/docs/howto.rst deleted file mode 100644 index 08b6d9bd..00000000 --- a/docs/howto.rst +++ /dev/null @@ -1,38 +0,0 @@ -How To - Project Documentation -====================================================================== - -Get Started ----------------------------------------------------------------------- - -Documentation can be written as rst files in `vbv_lernwelt/docs`. - - -To build and serve docs, use the commands:: - - docker-compose -f local.yml up docs - - - -Changes to files in `docs/_source` will be picked up and reloaded automatically. - -`Sphinx `_ is the tool used to build documentation. - -Docstrings to Documentation ----------------------------------------------------------------------- - -The sphinx extension `apidoc `_ is used to automatically document code using signatures and docstrings. - -Numpy or Google style docstrings will be picked up from project files and availble for documentation. See the `Napoleon `_ extension for details. - -For an in-use example, see the `page source <_sources/users.rst.txt>`_ for :ref:`users`. - -To compile all docstrings automatically into documentation source files, use the command: - :: - - make apidocs - - -This can be done in the docker container: - :: - - docker run --rm docs make apidocs diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index 14147719..00000000 --- a/docs/index.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. VBV Lernwelt documentation master file, created by - sphinx-quickstart. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to VBV Lernwelt's documentation! -====================================================================== - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - howto - users - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 445d8822..00000000 --- a/docs/make.bat +++ /dev/null @@ -1,46 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -c . -) -set SOURCEDIR=_source -set BUILDDIR=_build -set APP=..\vbv_lernwelt - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.Install sphinx-autobuild for live serving. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -b %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:livehtml -sphinx-autobuild -b html --open-browser -p 7000 --watch %APP% -c . %SOURCEDIR% %BUILDDIR%/html -GOTO :EOF - -:apidocs -sphinx-apidoc -o %SOURCEDIR%/api %APP% -GOTO :EOF - -:help -%SPHINXBUILD% -b help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/docs/users.rst b/docs/users.rst deleted file mode 100644 index 4cc398de..00000000 --- a/docs/users.rst +++ /dev/null @@ -1,15 +0,0 @@ - .. _users: - -Users -====================================================================== - -Starting a new project, it’s highly recommended to set up a custom user model, -even if the default User model is sufficient for you. - -This model behaves identically to the default user model, -but you’ll be able to customize it in the future if the need arises. - -.. automodule:: vbv_lernwelt.users.models - :members: - :noindex: - diff --git a/example.env b/example.env new file mode 100644 index 00000000..159363a6 --- /dev/null +++ b/example.env @@ -0,0 +1,3 @@ +export DATABASE_URL='postgres://vbv_lernwelt@localhost:5432/vbv_lernwelt' +export CELERY_BROKER_URL='redis://localhost:6379/0' +export USE_DOCKER=false diff --git a/gulpfile.js b/gulpfile.js index 7eb392c0..3059801d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -106,7 +106,7 @@ function initBrowserSync() { open: false, // https://www.browsersync.io/docs/options/#option-proxy proxy: { - target: 'django:8000', + target: 'localhost:8000', proxyReq: [ function(proxyReq, req) { // Assign proxy "host" header same as current request at Browsersync server