No description
Find a file
2025-05-20 14:16:28 +02:00
config use timezone option 2024-05-30 16:21:51 +02:00
libs update model 2024-07-02 15:33:33 +02:00
logs # Conflicts: 2024-05-29 09:43:05 +02:00
raspberry_config_examples remove unused files 2024-05-29 09:47:29 +02:00
src/saunatable update all packages 2025-05-20 14:16:28 +02:00
.gitignore # Conflicts: 2024-05-29 09:43:05 +02:00
.gitmodules # Conflicts: 2024-05-29 09:43:05 +02:00
.pre-commit-config.yaml update to py 3.12, use linting 2024-07-02 15:27:40 +02:00
docker-compose.yml # Conflicts: 2024-05-29 09:43:05 +02:00
Dockerfile # Conflicts: 2024-05-29 09:43:05 +02:00
pdm.lock update all packages 2025-05-20 14:16:28 +02:00
pyproject.toml update all packages 2025-05-20 14:16:28 +02:00
README.md update to py 3.12, use linting 2024-07-02 15:27:40 +02:00

HaDiKo Saunatable

A small tool to scrape a pretix installation for upcoming events.

IMPORTANT NOTE: This repo uses submodules, so make sure to keep them to the current master branch

Link to a brief submodule tutorial here.

Local (Virtual Environment) Installation

If necessary get python:

# install python3 and python3-pip
apt install python3 python3-pip virtualenv

Get script running:

# copy this repo
## use --recursive to get the submodules
git clone --recursive https://git.univ-exp.com/HDK/Saunatable.git
cd Saunatable

# install pdm
pip3 install -U pdm

# copy sample config
cp ./config/config.toml.example ./config/config.toml

# edit config
nano ./config/config.cfg

# run program
pdm run SaunaTable

Setup

Change the default values in the file ./config/config.toml, all values in the sections

  • [AppSettings]
    • api_key → change your pretix API key
    • pretix_server → your pretix server URL
    • preview_days → the upcoming days for which the table should be generated
    • organizers → the pretix organizer names to search for events
    • show_orders(optional, defaults to true) → add a link to the orders in the table
    • privacymode(optional, defaults to false) → use of privacy mode. Also triggerable by argument.
    • diplaytime_pre_timeslot(optional, defaults to 15) → show attendee names this # minutes in advance from now
    • diplaytime_post_timeslot(optional, defaults to 15) → show attendee names this # minutes longer from now
    • log_level(optional, default is INFO) → log level for the logger
    • log_file(optional, defaults to none) → the log file to write to
    • locale (optional) → the locale in country code (e.g. de) to use, defaults to your system locale
    • timezone (optional) → the timezone to use, defaults to your system timezone
  • [WebInterface]
    • enabled → enable the web interface
    • port → the port to listen on
    • host → the host to listen on
    • location(optional, defaults to /) → the location to listen on, ( e.g. your-server.com:port/SaunaTable/),

URL Parameters

The following URL query-parameters are available:

  • days (int) → the number of days to show in the future, overrides the config value preview_days, the command line argument --preview-days and the web-interface input
  • privacy (true | false) → set privacy mode, overrides the config value privacymode and the command line argument --privacy
  • show_orders (true | false) → show the orders in the table, overrides the config value show_orders
  • no_menu (true | false) → hide the menu, useful for embedding the table
  • auto_update (true) → auto update the table every auto_update_interval seconds.
  • auto_update_interval (int >= 5) → the interval in seconds to auto update the table. Defaults to 60 seconds.

Example:

http://your-server.com:8080/?days=3&privacy=true&show_orders=false&no_menu=true&auto_update=true&auto_update_interval=10

Systemd Unit

Use the following example to run the script as a systemd service.

[Unit]
Description=SaunaTable
After=network.target

[Service]
# set your username here
User=username
# set your group here
Group=groupname
# set your working directory to your installation
WorkingDirectory=/opt/SaunaTable
# set your virtual environment (PDM creates .venv)
ExecStart=/opt/SaunaCancelWatchdog/.venv/bin/SaunaTable
Restart=always

[Install]
WantedBy=multi-user.target

Docker Installation

Make sure to have completed the setup before running the docker container. The folders ./config and ./logs are mounted to the container.

# builds the docker image and starts the container
docker compose up -d

Optional parameters

Use pdm run SaunaTable --help to get the following help:

Usage: SaunaTable [OPTIONS]                                                       
                                                                                   
╭─ Options ───────────────────────────────────────────────────────────────────────╮
│ --config           PATH     path to the config.toml file                        │
│ --since            TEXT     Create the tables since a given DATE in any format  │
│                             recognized by pendulum                              │
│ --preview-days     INTEGER  Create the tables for the next N days               │
│ --web-interface             Enable web interface and start a web server to show │
│                             the tables                                          │
│ --privacy                   Enable privacy and only show current window from    │
│                             config.toml                                         │
│ --highscore                 Print highscore instead of shifts table             │
│ --help                      Show this message and exit.                         │
╰─────────────────────────────────────────────────────────────────────────────────╯

Apache2 Redirect

To generate the AuthUserFile just use the htpasswd command.

The following example uses the location /SaunaTable. Make sure to set the same location in your config file as in the apache config file.


```# /etc/apache2/sites-available/saunatable.conf
    # [...] virtual host configuration
    # Reverse proxy configuration for Plotly Dash app
    ProxyPreserveHost On
    ProxyPass /SaunaTable http://localhost:8088/SaunaTable
    ProxyPassReverse /SaunaTable http://localhost:8088/SaunaTable

    # Optional: Add these lines if you want to handle WebSocket connections
    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule /SaunaTable/(.*) ws://localhost:8088/SaunaTable/$1 [P,L]

    # Basic Authentication configuration for /SaunaTable
    <Location /SaunaTable>
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /etc/apache2/htpasswd-files/saunatable.htpasswd
        Require valid-user
    </Location>
    # [...] virtual host configuration

Then just visit https://your-example-server.com:port and login with the user and password.

Update Submodules

# from inside repo run the following to pull submodules
git submodule update --init --recursive

# to pull submodules to the latest commit
git submodule update --remote --merge
# after submodule update you might want to commit the change
git commit -am "updated submodules"
git push

Linting

Use ruff and pre-commit to lint the code.

# install pre-commit, and ruff
pip3 install -U pre-commit ruff

# install pre-commit hooks
pre-commit install

License

Author Stefan Maier Licence GNU GPLv3

Contributing

Bug reports and pull requests are welcome on my website or mail to git@univ-exp.com