From 974af80a9b5fb325a8a0f4a17ecdc816b1dade35 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 12 Nov 2021 11:34:42 +0100 Subject: [PATCH 1/2] [db] Fix warnings and fix readme --- flaschengeist/models/__init__.py | 1 + readme.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/flaschengeist/models/__init__.py b/flaschengeist/models/__init__.py index 1b503dd..4eca8e3 100644 --- a/flaschengeist/models/__init__.py +++ b/flaschengeist/models/__init__.py @@ -44,6 +44,7 @@ class ModelSerializeMixin: class Serial(TypeDecorator): """Same as MariaDB Serial used for IDs""" + cache_ok=True impl = BigInteger().with_variant(mysql.BIGINT(unsigned=True), "mysql").with_variant(sqlite.INTEGER, "sqlite") diff --git a/readme.md b/readme.md index 133a570..7b64951 100644 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ If not you need to create user and database manually do (or similar on Windows): ( echo "CREATE DATABASE flaschengeist;" echo "CREATE USER 'flaschengeist'@'localhost' IDENTIFIED BY 'flaschengeist';" - echo "GRANT ALL PRIVILEGES ON 'flaschengeist'.* TO 'flaschengeist'@'localhost';" + echo "GRANT ALL PRIVILEGES ON flaschengeist.* TO 'flaschengeist'@'localhost';" echo "FLUSH PRIVILEGES;" ) | sudo mysql From 1b371763eee5cb1490a647574cdcd818c8b6d95f Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 13 Nov 2021 14:49:28 +0100 Subject: [PATCH 2/2] [events] Fix conflic return code --- flaschengeist/plugins/events/event_controller.py | 6 +++--- flaschengeist/plugins/users/__init__.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/flaschengeist/plugins/events/event_controller.py b/flaschengeist/plugins/events/event_controller.py index 1bc8b43..fb50655 100644 --- a/flaschengeist/plugins/events/event_controller.py +++ b/flaschengeist/plugins/events/event_controller.py @@ -1,7 +1,7 @@ from datetime import datetime, timedelta, timezone from typing import Optional -from werkzeug.exceptions import BadRequest, NotFound +from werkzeug.exceptions import BadRequest, Conflict, NotFound from sqlalchemy.exc import IntegrityError from flaschengeist import logger @@ -41,7 +41,7 @@ def create_event_type(name): db.session.commit() return event except IntegrityError: - raise BadRequest("Name already exists") + raise Conflict("Name already exists") def rename_event_type(identifier, new_name): @@ -50,7 +50,7 @@ def rename_event_type(identifier, new_name): try: db.session.commit() except IntegrityError: - raise BadRequest("Name already exists") + raise Conflict("Name already exists") def delete_event_type(name): diff --git a/flaschengeist/plugins/users/__init__.py b/flaschengeist/plugins/users/__init__.py index 8a0db58..9b41070 100644 --- a/flaschengeist/plugins/users/__init__.py +++ b/flaschengeist/plugins/users/__init__.py @@ -75,7 +75,7 @@ def list_users(current_session): @UsersPlugin.blueprint.route("/users/", methods=["GET"]) @login_required() -@headers({"Cache-Control": "private, must-revalidate, max-age=3600"}) +@headers({"Cache-Control": "private, must-revalidate, max-age=300"}) def get_user(userid, current_session): """Retrieve user by userid