Skip to content
Snippets Groups Projects
Commit 812fc41c authored by Davor's avatar Davor
Browse files

Fix checking if app exists before inserting into DB

parent 4c6a9bc8
No related branches found
No related tags found
No related merge requests found
......@@ -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 is not None:
db.session.add(obj)
db.session.commit()
else:
if app_obj:
current_app.logger.info(f"App definition: {name} ({slug}) already exists in database")
return
db.session.add(obj)
db.session.commit()
current_app.logger.info(f"App definition: {name} ({slug}) created")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment