|
|
@ -606,6 +606,7 @@ def list_templates():
|
|
|
|
SELECT name, description, attribution, crop, location FROM templates ORDER BY name
|
|
|
|
SELECT name, description, attribution, crop, location FROM templates ORDER BY name
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
results = database.query(conn, query)
|
|
|
|
results = database.query(conn, query)
|
|
|
|
|
|
|
|
logging.info('List of thumbnail templates fetched')
|
|
|
|
return json.dumps([row._asdict() for row in results.fetchall()])
|
|
|
|
return json.dumps([row._asdict() for row in results.fetchall()])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -623,6 +624,7 @@ def get_template(name):
|
|
|
|
return 'Template {} not found'.format(name), 404
|
|
|
|
return 'Template {} not found'.format(name), 404
|
|
|
|
|
|
|
|
|
|
|
|
image = row[0]
|
|
|
|
image = row[0]
|
|
|
|
|
|
|
|
logging.info('Thumbnail image of {} fetched'.format(name))
|
|
|
|
return flask.Response(image, mimetype='image/png')
|
|
|
|
return flask.Response(image, mimetype='image/png')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -638,6 +640,7 @@ def get_template_metadata(name):
|
|
|
|
row = results.fetchone()
|
|
|
|
row = results.fetchone()
|
|
|
|
if row is None:
|
|
|
|
if row is None:
|
|
|
|
return 'Template {} not found'.format(name), 404
|
|
|
|
return 'Template {} not found'.format(name), 404
|
|
|
|
|
|
|
|
logging.info('Thumbnail metadata of {} fetched'.format(name))
|
|
|
|
return json.dumps(row._asdict())
|
|
|
|
return json.dumps(row._asdict())
|
|
|
|
|
|
|
|
|
|
|
|
def validate_template(new_template):
|
|
|
|
def validate_template(new_template):
|
|
|
@ -691,6 +694,7 @@ def add_template(artist=None):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
database.query(conn, query, **new_template)
|
|
|
|
database.query(conn, query, **new_template)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logging.info('Thumbnail template {} added'.format(new_template['name']))
|
|
|
|
return '', 201
|
|
|
|
return '', 201
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/thrimshim/update-template/<name>', methods=['POST'])
|
|
|
|
@app.route('/thrimshim/update-template/<name>', methods=['POST'])
|
|
|
@ -728,6 +732,10 @@ def update_template(name, artist=None):
|
|
|
|
) for column in columns))
|
|
|
|
) for column in columns))
|
|
|
|
database.query(conn, query, old_name=name, **new_template)
|
|
|
|
database.query(conn, query, old_name=name, **new_template)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if name == new_template['name']:
|
|
|
|
|
|
|
|
logging.info('Thumbnail template {} updated'.format(name))
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
logging.info('Thumbnail template {} renamed to {} and updated'.format(name, new_template['name']))
|
|
|
|
return '', 200
|
|
|
|
return '', 200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -746,6 +754,7 @@ def get_thumbnail(ident):
|
|
|
|
event = row._asdict()
|
|
|
|
event = row._asdict()
|
|
|
|
|
|
|
|
|
|
|
|
if event['thumbnail_mode'] != 'NONE' and event['thumbnail_image']:
|
|
|
|
if event['thumbnail_mode'] != 'NONE' and event['thumbnail_image']:
|
|
|
|
|
|
|
|
logging.info('Thumbnail for event {} fetched'.format(ident))
|
|
|
|
return flask.Response(event['thumbnail_image'], mimetype='image/png')
|
|
|
|
return flask.Response(event['thumbnail_image'], mimetype='image/png')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return '', 404
|
|
|
|
return '', 404
|
|
|
|