Fix name duplicate check to only run when the template name is changed

Without checking first, a rename is required for all thumbnail template modifications.
pull/460/head
ElementalAlchemist 3 weeks ago committed by Christopher Usher
parent f4d303147d
commit 501549350b

@ -724,12 +724,13 @@ def update_template(name, artist=None):
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(""" if name != new_template["name"]:
SELECT name FROM templates WHERE name = %s query = sql.SQL("""
""") SELECT name FROM templates WHERE name = %s
results = database.query(conn, query, new_template['name']) """)
if results.fetchone() is not None: results = database.query(conn, query, new_template['name'])
return 'Template with name {} already exists'.format(new_template['name']), 400 if results.fetchone() is not None:
return 'Template with name {} already exists'.format(new_template['name']), 400
query = sql.SQL(""" query = sql.SQL("""
UPDATE templates UPDATE templates

Loading…
Cancel
Save