diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 06b0a13..86dab81 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,22 +5,22 @@ on: [push] jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.10", "3.11"] steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - pip install --user pdm - pdm sync -G dev - - name: Format - run: | - pdm run ruff format --check . - - name: Lint - run: | - pdm run ruff check . + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install dependencies + run: | + pip install --user pdm + pdm sync -G dev + - name: Format + run: | + pdm run ruff format --check . + - name: Lint + run: | + pdm run ruff check . + - name: Djlint + run: | + pdm run djlint coffeebuddy diff --git a/.github/workflows/test_backends.yml b/.github/workflows/test_backends.yml index b25c797..988a894 100644 --- a/.github/workflows/test_backends.yml +++ b/.github/workflows/test_backends.yml @@ -7,51 +7,51 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - sudo apt-get install libpcsclite-dev - pip install --user pdm - pdm sync --prod - - name: Test backend sqlite - run: | - sed -i 's/^CARD.*/CARD = ""/' config.py - sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py - sed -i 's/^PIR.*/PIR = False/' config.py - sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py - sed -i 's/^DB_BACKEND.*/DB_BACKEND = "sqlite"/' config.py - pdm run ./bin/run.py & - pid=$! - sleep 1 - ps | grep -c $pid || wait $pid - kill -SIGTERM $pid - - name: Test backend postgresql - run: | - sed -i 's/^CARD.*/CARD = ""/' config.py - sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py - sed -i 's/^PIR.*/PIR = False/' config.py - sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py - sed -i 's/^DB_BACKEND.*/DB_BACKEND = "postgres"/' config.py - pdm run ./bin/run.py & - pid=$! - sleep 1 - ps | grep -c $pid || wait $pid - kill -SIGTERM $pid - - name: Test backend testing - run: | - sed -i 's/^CARD.*/CARD = ""/' config.py - sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py - sed -i 's/^PIR.*/PIR = False/' config.py - sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py - sed -i 's/^DB_BACKEND.*/DB_BACKEND = "sqlite"/' config.py - export FLASK_ENV=prefilled - export FLASK_DEBUG=true - pdm run ./bin/run.py & - pid=$! - sleep 1 - ps | grep -c $pid || wait $pid - kill -SIGTERM $pid + - uses: actions/checkout@v2 + - name: Set up Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: 3.13 + - name: Install dependencies + run: | + sudo apt-get install libpcsclite-dev + pip install --user pdm + pdm sync --prod + - name: Test backend sqlite + run: | + sed -i 's/^CARD.*/CARD = ""/' config.py + sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py + sed -i 's/^PIR.*/PIR = False/' config.py + sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py + sed -i 's/^DB_BACKEND.*/DB_BACKEND = "sqlite"/' config.py + pdm run ./bin/run.py & + pid=$! + sleep 1 + ps | grep -c $pid || wait $pid + kill -SIGTERM $pid + - name: Test backend postgresql + run: | + sed -i 's/^CARD.*/CARD = ""/' config.py + sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py + sed -i 's/^PIR.*/PIR = False/' config.py + sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py + sed -i 's/^DB_BACKEND.*/DB_BACKEND = "postgres"/' config.py + pdm run ./bin/run.py & + pid=$! + sleep 1 + ps | grep -c $pid || wait $pid + kill -SIGTERM $pid + - name: Test backend testing + run: | + sed -i 's/^CARD.*/CARD = ""/' config.py + sed -i 's/^FACERECOGNITION.*/FACERECOGNITION = False/' config.py + sed -i 's/^PIR.*/PIR = False/' config.py + sed -i 's/^ILLUMINATION.*/ILLUMINATION = False/' config.py + sed -i 's/^DB_BACKEND.*/DB_BACKEND = "sqlite"/' config.py + export FLASK_ENV=prefilled + export FLASK_DEBUG=true + pdm run ./bin/run.py & + pid=$! + sleep 1 + ps | grep -c $pid || wait $pid + kill -SIGTERM $pid diff --git a/.github/workflows/test_dockerdb.yml b/.github/workflows/test_dockerdb.yml index 3e99e0b..f5ca3fc 100644 --- a/.github/workflows/test_dockerdb.yml +++ b/.github/workflows/test_dockerdb.yml @@ -7,31 +7,31 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Patch docker-compose.yml - run: sed -i 's,.*/mnt/ssd/postgresql.*,#\\0,' database/docker-compose.yml - - name: Setup certificates - run: | - cd database - echo -e "1\nn" | ./gen_certs.sh - echo -e "2\ncoffeebuddydb" | ./gen_certs.sh - echo -e "3\ncoffeebuddy01\nn" | ./gen_certs.sh - - name: Create container - run: | - cd database - docker compose up - - name: Start container again - run: | - cd database - docker compose up -d - sleep 5 - PGSSLMODE=require \ - PGSSLROOTCERT=certs/ca/root.crt \ - PGSSLCERT=certs/client_coffeebuddy01/postgresql.crt \ - PGSSLKEY=certs/client_coffeebuddy01/postgresql.key \ - psql -U coffeebuddy01 -h localhost -d coffeebuddy -lqt - - name: Stop containers - if: always() - run: | - cd database - docker compose down + - uses: actions/checkout@v2 + - name: Patch docker-compose.yml + run: sed -i 's,.*/mnt/ssd/postgresql.*,#\\0,' database/docker-compose.yml + - name: Setup certificates + run: | + cd database + echo -e "1\nn" | ./gen_certs.sh + echo -e "2\ncoffeebuddydb" | ./gen_certs.sh + echo -e "3\ncoffeebuddy01\nn" | ./gen_certs.sh + - name: Create container + run: | + cd database + docker compose up + - name: Start container again + run: | + cd database + docker compose up -d + sleep 5 + PGSSLMODE=require \ + PGSSLROOTCERT=certs/ca/root.crt \ + PGSSLCERT=certs/client_coffeebuddy01/postgresql.crt \ + PGSSLKEY=certs/client_coffeebuddy01/postgresql.key \ + psql -U coffeebuddy01 -h localhost -d coffeebuddy -lqt + - name: Stop containers + if: always() + run: | + cd database + docker compose down diff --git a/coffeebuddy/extensions/coffeemaker.py b/coffeebuddy/extensions/coffeemaker.py index e95f74e..ebcd6fe 100644 --- a/coffeebuddy/extensions/coffeemaker.py +++ b/coffeebuddy/extensions/coffeemaker.py @@ -40,6 +40,7 @@ def brew(self, data): def init(): logging.getLogger(__name__).info("Init") app = flask.current_app + config = app.config.get("COFFEEMAKER", None) or {} - if (brew_time := app.config.get("COFFEEMAKER_MOCK_BREW_TIME", False)) is not False: - CoffeeMakerMock(brew_time=brew_time) + if "mock" in config: + CoffeeMakerMock(brew_time=config["mock"]) diff --git a/coffeebuddy/model.py b/coffeebuddy/model.py index a47cddb..fa5cfdb 100644 --- a/coffeebuddy/model.py +++ b/coffeebuddy/model.py @@ -8,7 +8,7 @@ import flask import sqlalchemy from sqlalchemy import Column, ForeignKey, Integer, Table, select, text -from sqlalchemy.orm import Mapped, backref, mapped_column, relationship +from sqlalchemy.orm import Mapped, mapped_column, relationship from . import Base diff --git a/coffeebuddy/ui/__init__.py b/coffeebuddy/ui/__init__.py index cef229a..1055aab 100644 --- a/coffeebuddy/ui/__init__.py +++ b/coffeebuddy/ui/__init__.py @@ -40,7 +40,11 @@ def url(site: str, **kwargs): for key, value in kwargs.items(): if isinstance(value, bytes): kwargs[key] = value.hex() - return site + "?" + "&".join(f"{key}={value}" for key, value in kwargs.items()) + return ( + site + + "?" + + "&".join(f"{key}={value}" if value else key for key, value in kwargs.items()) + ) @flask.current_app.context_processor diff --git a/coffeebuddy/ui/base/templates/selectuser.html b/coffeebuddy/ui/base/templates/selectuser.html index ffff30d..5bf95b5 100644 --- a/coffeebuddy/ui/base/templates/selectuser.html +++ b/coffeebuddy/ui/base/templates/selectuser.html @@ -43,7 +43,7 @@
{{ hexstr(user.tag) }}
- 01020304
or
- 01 02 03 04
-
-
- 01020304
or
+ 01 02 03 04
+
+