When checking whether a template exists, check the right table

pull/449/head
ElementalAlchemist 4 weeks ago committed by Christopher Usher
parent 5bd8fbd65f
commit 8ac23f2927

@ -687,7 +687,7 @@ def add_template(artist=None):
with app.db_manager.get_conn() as conn: with app.db_manager.get_conn() as conn:
#check if name is already in the database #check if name is already in the database
query = sql.SQL(""" query = sql.SQL("""
SELECT name FROM events WHERE name = %s SELECT name FROM templates WHERE name = %s
""") """)
results = database.query(conn, query, new_template['name']) results = database.query(conn, query, new_template['name'])
if results.fetchone() is not None: if results.fetchone() is not None:
@ -718,14 +718,14 @@ def update_template(name, artist=None):
with app.db_manage.get_conn() as conn: with app.db_manage.get_conn() as conn:
#check if template is in database #check if template is in database
query = sql.SQL(""" query = sql.SQL("""
SELECT name FROM events WHERE name = %s SELECT name FROM templates WHERE name = %s
""") """)
results = database.query(conn, query, name) results = database.query(conn, query, name)
if results.fetchone() is None: if results.fetchone() is None:
return 'Template with name {} does not exist'.format(name), 400 return 'Template with name {} does not exist'.format(name), 400
# check if new name is in database # check if new name is in database
query = sql.SQL(""" query = sql.SQL("""
SELECT name FROM events WHERE name = %s SELECT name FROM templates WHERE name = %s
""") """)
results = database.query(conn, query, new_template['name']) results = database.query(conn, query, new_template['name'])
if results.fetchone() is not None: if results.fetchone() is not None:

Loading…
Cancel
Save