[chore] cleanup

This commit is contained in:
Ferdinand Thiessen 2021-03-24 18:37:53 +01:00
parent 1550be5da6
commit 7d692c5f68
3 changed files with 7 additions and 14 deletions

View File

@ -16,19 +16,17 @@ from flaschengeist.controller import roleController
class CustomJSONEncoder(JSONEncoder): class CustomJSONEncoder(JSONEncoder):
def default(self, o): def default(self, o):
# Check if custom model
try: try:
# Check if custom model
return o.serialize() return o.serialize()
except AttributeError: except AttributeError:
pass pass
if isinstance(o, datetime) or isinstance(o, date): if isinstance(o, datetime) or isinstance(o, date):
return o.isoformat() return o.isoformat()
if isinstance(o, enum.Enum): if isinstance(o, enum.Enum):
return o.value return o.value
# Check if iterable
try: try:
# Check if iterable
iterable = iter(o) iterable = iter(o)
except TypeError: except TypeError:
pass pass
@ -56,7 +54,7 @@ def __load_plugins(app):
f"Plugin {entry_point.name} was enabled, but could not be loaded due to an error.", exc_info=True f"Plugin {entry_point.name} was enabled, but could not be loaded due to an error.", exc_info=True
) )
if isinstance(plugin, AuthPlugin): if isinstance(plugin, AuthPlugin):
logger.debug("Found authentication plugin: %s", entry_point.name) logger.debug(f"Found authentication plugin: {entry_point.name}")
if entry_point.name == config["FLASCHENGEIST"]["auth"]: if entry_point.name == config["FLASCHENGEIST"]["auth"]:
app.config["FG_AUTH_BACKEND"] = plugin app.config["FG_AUTH_BACKEND"] = plugin
else: else:
@ -76,9 +74,9 @@ def install_all():
installed = [] installed = []
for name, plugin in current_app.config["FG_PLUGINS"].items(): for name, plugin in current_app.config["FG_PLUGINS"].items():
if not plugin: if not plugin:
logger.debug("Skip disabled plugin {}".format(name)) logger.debug(f"Skip disabled plugin: {name}")
continue continue
logger.info("Install plugin {}".format(name)) logger.info(f"Install plugin {name}")
plugin.install() plugin.install()
installed.append(plugin) installed.append(plugin)
if plugin.permissions: if plugin.permissions:

View File

@ -193,10 +193,10 @@ def get_event(event_id, current_session):
@schedule_bp.route("/events", methods=["GET"]) @schedule_bp.route("/events", methods=["GET"])
@login_required() @login_required()
def get_filtered_events(current_session): def get_filtered_events(current_session):
begin = request.args.get('from') begin = request.args.get("from")
if begin is not None: if begin is not None:
begin = from_iso_format(begin) begin = from_iso_format(begin)
end = request.args.get('to') end = request.args.get("to")
if end is not None: if end is not None:
end = from_iso_format(end) end = from_iso_format(end)
if begin is None and end is None: if begin is None and end is None:

View File

@ -24,11 +24,6 @@ class PriceListPlugin(Plugin):
config = {"discount": 0} config = {"discount": 0}
config.update(cfg) config.update(cfg)
def install(self):
from flaschengeist.database import db
db.create_all()
@pricelist_bp.route("/drink-types", methods=["GET"]) @pricelist_bp.route("/drink-types", methods=["GET"])
@pricelist_bp.route("/drink-types/<int:identifier>", methods=["GET"]) @pricelist_bp.route("/drink-types/<int:identifier>", methods=["GET"])