Kód pro inventář spolku Herní historie.
Dependencies:
- PostgreSQL database
- Copy
.env_exampleto.envand fill in variables - Copy
alembic.ini_exampletoalembic.iniand fill in PostgreSQL database URL - Run:
uv sync
uv run playwright install --only-shell chromium # for rendering labels
uv run python dbseed.py
uv run alembic heads
uv run alembic stamp <revision>Where <revision> is the latest Alembic revision shown from alembic heads.
Chromium also needs some system libraries. On Debian or Ubuntu, install them with sudo .venv/bin/playwright install-deps chromium.
The first registered user should be given admin permissions.
Run with uv run flask run.
uv run flask run --debuguv run fastapi dev rhinventory/api/app.py poetry shell
# Jako git status
alembic current
# Udělal jsem novou tabulku, chci aby jí alembic přemigroval
alembic revision --autogenerate -m "Add File table"
# omrknu alembic/versions/[nová revize].py, jestli tam je to co chci...
# Spustím migraci
alembic upgrade headHave you updated events in hhfloppy? Run this to update the dependency:
uv lock --upgrade-package hhfloppy && uv syncIf there are no database migrations: run the script ./ops/deploy.sh
If there are database migrations: run the script ./ops/deploy_with_migration.sh
herniarchiv.cz (haweb) shows public rhinventory pages under /inventory/, by loading them in an iframe through its own proxy. The proxy sends these request headers:
X-Forwarded-Prefix: /inventory/_frame– path the proxy serves rhinventory at. All URLs must therefore be built withurl_for(or thesite_urlfilter for root-relative URLs from elsewhere, such as the database).X-Haweb-Embed: 1– embed mode: no header or menu (haweb shows its own), staff-only tools hidden,noindex, indexifembedded, andstatic/embed.cssandstatic/embed.jsare loaded (seeadmin/master.html).X-Haweb-Theme: light|dark– the visitor's theme on. Without it, the system preference applies.
To try it locally:
curl -H 'X-Forwarded-Prefix: /inventory/_frame' -H 'X-Haweb-Embed: 1' http://127.0.0.1:5000/asset/When HAWEB_INVENTORY_URL is set (https://herniarchiv.cz/inventory in production), visitors who aren't logged in are redirected from rhinventory's pages to the same page on herniarchiv.cz. Its "Log in" link leads to /login/github?next=<path>, which returns them to the page in rhinventory. Files, JSON and other responses that aren't pages are not redirected.
The proxy doesn't serve files. It redirects /inventory/_frame/files/... to rhinventory, so that large downloads don't pass through it.
/files/<id>/... checks that the visitor may see the file, and then sends it. Sending a large file from Flask ties up a gunicorn thread for the whole download, so in production nginx sends it instead: rhinventory returns an empty response with an X-Accel-Redirect: /_files/<store>/<path> header, and nginx serves that from an internal location for the store (files/rhbox/sites-hh/rhinventory.retroherna.org.nginx.conf in the infra repo).
X_ACCEL_REDIRECT_LOCATIONS lists which stores nginx serves, e.g. local=/_files/local/,coruscant=/_files/coruscant/. Only list a store once nginx (user www-data) can read its files, or downloads from it will fail with 404 or 403. Files in stores that aren't listed are sent by Flask, as is everything when the setting is empty (the default, and the way to run without nginx).
PYTHONPATH=. python scripts/script.py
Try to check logs with sudo journalctl -u www_rhinventory -e. If that's not enough, run manually with:
sudo systemctl stop rhinventory
cd /var/www/rhinventory
sudo -u flask ./deploy.shOnce solved:
sudo systemctl start rhinventoryuv lock --upgrade-package hhfloppy && uv syncThen update the SUPPORTED_EVENT_VERSION in event_store.py.