From b2d843169797fb1359aba5d86f787cb94d108bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Mon, 29 Mar 2021 20:26:15 +0200 Subject: [PATCH] [pricelist][fix] add permission to plugin --- flaschengeist/plugins/pricelist/__init__.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/flaschengeist/plugins/pricelist/__init__.py b/flaschengeist/plugins/pricelist/__init__.py index 35c3ce1..9d5151a 100644 --- a/flaschengeist/plugins/pricelist/__init__.py +++ b/flaschengeist/plugins/pricelist/__init__.py @@ -16,6 +16,7 @@ from . import pricelist_controller, permissions class PriceListPlugin(Plugin): name = "pricelist" + permissions = permissions.permissions blueprint = Blueprint(name, __name__, url_prefix="/pricelist") plugin = LocalProxy(lambda: current_app.config["FG_PLUGINS"][PriceListPlugin.name]) models = models @@ -186,7 +187,11 @@ def delete_extra_ingredient(identifier): def pricelist_settings_min_prices(): if request.method == "GET": # TODO: Handle if no prices are set! - return jsonify(PriceListPlugin.plugin.get_setting("min_prices")) + try: + min_prices = PriceListPlugin.plugin.get_setting("min_prices") + except KeyError: + min_prices = [] + return jsonify(min_prices) else: data = request.get_json() if not isinstance(data, list) or not all(isinstance(n, int) for n in data): @@ -227,7 +232,7 @@ def get_columns(userid, current_session: Session): userController.persist() return no_content() -@PriceListPlugin.route("/drinks//picture", methods=["POST", "GET", "DELETE"]) +@PriceListPlugin.blueprint.route("/drinks//picture", methods=["POST", "GET", "DELETE"]) def set_picture(identifier): if request.method == "DELETE": @@ -243,7 +248,7 @@ def set_picture(identifier): else: raise BadRequest -@PriceListPlugin.route("/picture/", methods=["GET"]) +@PriceListPlugin.blueprint.route("/picture/", methods=["GET"]) def _get_picture(identifier): if request.method == "GET": size = request.args.get("size")