Fix checking if app exists before inserting into DB

This commit is contained in:
Davor 2022-06-21 17:33:04 +02:00
parent 4c6a9bc8c9
commit 812fc41c6e

View file

@ -57,13 +57,15 @@ def create_app(slug, name):
obj.name = name
obj.slug = slug
app = db.session.query(App).filter_by(slug=slug).first()
app_obj = App.query.filter_by(slug=slug).first()
if app_obj:
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
return
if app is not None:
db.session.add(obj)
db.session.commit()
else:
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
current_app.logger.info(f"App definition: {name} ({slug}) created")