Fix checking if app exists before inserting into DB
This commit is contained in:
parent
4c6a9bc8c9
commit
812fc41c6e
1 changed files with 7 additions and 5 deletions
|
@ -57,13 +57,15 @@ def create_app(slug, name):
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.slug = slug
|
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:
|
if app_obj:
|
||||||
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}) already exists in database")
|
||||||
|
return
|
||||||
|
|
||||||
|
db.session.add(obj)
|
||||||
|
db.session.commit()
|
||||||
|
current_app.logger.info(f"App definition: {name} ({slug}) created")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue