diff --git a/doc/development.md b/doc/development.md index a991d585..5b719fba 100644 --- a/doc/development.md +++ b/doc/development.md @@ -1,27 +1,28 @@ Development =========== -*this doc is based on new data models work which is a work in progress* - -First, a working version of local NeoDB instance has to be established, see [install guide](install.md). - -Since new data model is still under development, most pieces are off by default, add `new_data_model=1` to your shell env and run migrations before start working on these new models +Obviously a working version of local NeoDB instance has to be established first, see [install guide](install.md). +Install development related packages ``` -export new_data_model=1 -python3 manage.py makemigrations -python3 manage.py migrate +python3 -m pip install -r requirements-dev.txt ``` -It's recommended to create the test database from freshly created database: +Install pre-commit hooks ``` -CREATE DATABASE test_neodb WITH TEMPLATE neodb; +$ pre-commit install +pre-commit installed at .git/hooks/pre-commit ``` -Alternatively `python3 manage.py test` can create test databases every time test runs, but it's slow and buggy bc test run initial migration scripts slightly differently. Run Test -------- -Now to verify everything works, run tests with `python3 manage.py test --keepdb` +`python3 manage.py test` will run the tests + +Alternative you may create the test database from freshly created database: +``` +CREATE DATABASE test_neodb WITH TEMPLATE neodb; +``` +and run the test without re-create it every time ``` $ python3 manage.py test --keepdb @@ -44,5 +45,4 @@ Main django apps for NeoDB: - `catalog` manages different types of items user may review, and scrapers to fetch from external resources, see [catalog.md](catalog.md) for more details - `journal` manages user created content(review/ratings) and lists(collection/shelf/tag), see [journal.md](journal.md) for more details - `social` manages timeline for local users and ActivityStreams for remote servers, see [social.md](social.md) for more details - -These apps are legacy: books, music, movies, games, collections, they will be removed soon. + - `legacy` this is only used by instances upgraded from 0.4.x and earlier, to provide a link mapping from old urls to new ones. If your journey starts with 0.5 and later, feel free to ignore it. diff --git a/doc/install.md b/doc/install.md index dd849481..362d2bd8 100644 --- a/doc/install.md +++ b/doc/install.md @@ -19,11 +19,18 @@ Create and edit your own configuration file (optional but very much recommended) mkdir mysite && cp boofilsic/settings.py mysite/ export DJANGO_SETTINGS_MODULE=mysite.settings ``` +Alternatively you can have a configuration file import `boofilsic/settings.py` then override it: +``` +from boofilsic.settings import * + +SECRET_KEY = "my_key" +``` More details on `settings.py` in [configuration.md](configuration.md) -Create and use `venv` as you normally would, then install packages +Create and use `venv` as you normally would, then install packages ``` python3 -m pip install -r requirements.txt + ``` Quick check @@ -33,13 +40,13 @@ python3 manage.py check Initialize database ``` -python3 manage.py makemigrations users books movies games music sync mastodon management collection timeline -python3 manage.py migrate users python3 manage.py migrate ``` Build static assets ``` +python3 manage.py sass common/static/sass/boofilsic.sass common/static/css/boofilsic.min.css -t compressed +python3 manage.py sass common/static/sass/boofilsic.sass common/static/css/boofilsic.css python3 manage.py collectstatic ``` @@ -51,12 +58,12 @@ Make sure PostgreSQL and Redis are running Start job queue server ``` export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES # required and only for macOS, otherwise it may crash -python3 manage.py rqworker --with-scheduler doufen export mastodon +python3 manage.py rqworker --with-scheduler import export mastodon fetch crawl ``` Run web server in dev mode ``` -python3 manage.py runserver 0.0.0.0:80 +python3 manage.py runserver ``` It should be ready to serve from here, to run web server for production, consider `gunicorn -w 8 boofilsic.wsgi` in systemd or sth similar @@ -66,7 +73,6 @@ Migrate from an earlier version ------------------------------- Update database ``` -python3 manage.py makemigrations python3 manage.py migrate ``` @@ -87,15 +93,15 @@ Install TypeSense or Meilisearch, change `SEARCH_BACKEND` and coniguration for s Build initial index, it may take a few minutes or hours ``` -python3 manage.py init_index -python3 manage.py reindex +python3 manage.py index --init +python3 manage.py index --reindex ``` Other maintenance tasks ----------------------- -Requeue failed jobs +Requeue failed import jobs ``` -rq requeue --all --queue doufen +rq requeue --all --queue import ``` Run in Docker @@ -109,4 +115,3 @@ Run Tests coverage run --source='.' manage.py test coverage report ``` - diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..79682cc2 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +pre-commit +black +django-debug-toolbar +coverage diff --git a/requirements.txt b/requirements.txt index 24a47c78..5ca95615 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -coverage dateparser django~=3.2.16 django-markdownx @ git+https://github.com/alphatownsman/django-markdownx.git@e69480c64ad9c5d0499f4a8625da78cf2bb7691b @@ -11,7 +10,7 @@ django-user-messages django-slack django-ninja django-polymorphic -django-debug-toolbar +django-maintenance-mode meilisearch easy-thumbnails lxml @@ -26,4 +25,3 @@ dnspython typesense markdownify igdb-api-v4 -django-maintenance-mode