Photo.add_tag returns the added tag; site displays the normalized name instead of user input

master
voussoir 2017-03-10 14:04:50 -08:00
parent 70f284d413
commit 3be8813a0a
2 changed files with 6 additions and 4 deletions

View File

@ -422,8 +422,9 @@ class Photo(ObjectBase):
def add_tag(self, tag, *, commit=True): def add_tag(self, tag, *, commit=True):
tag = self.photodb.get_tag(tag) tag = self.photodb.get_tag(tag)
if self.has_tag(tag, check_children=False): existing = self.has_tag(tag, check_children=False)
return if existing:
return existing
# If the new tag is less specific than one we already have, # If the new tag is less specific than one we already have,
# keep our current one. # keep our current one.
@ -431,7 +432,7 @@ class Photo(ObjectBase):
if existing: if existing:
message = 'Preferring existing {exi:s} over {tag:s}'.format(exi=existing, tag=tag) message = 'Preferring existing {exi:s} over {tag:s}'.format(exi=existing, tag=tag)
self.photodb.log.debug(message) self.photodb.log.debug(message)
return return existing
# If the new tag is more specific, remove our current one for it. # If the new tag is more specific, remove our current one for it.
for parent in tag.walk_parents(): for parent in tag.walk_parents():
@ -447,6 +448,7 @@ class Photo(ObjectBase):
if commit: if commit:
self.photodb.log.debug('Committing - add photo tag') self.photodb.log.debug('Committing - add photo tag')
self.photodb.commit() self.photodb.commit()
return tag
def albums(self): def albums(self):
''' '''

View File

@ -673,7 +673,7 @@ def post_photo_add_remove_tag_core(photoid, tagname, add_or_remove):
elif add_or_remove == 'remove': elif add_or_remove == 'remove':
photo.remove_tag(tag) photo.remove_tag(tag)
response = {'tagname': tagname} response = {'tagname': tag.name}
return jsonify.make_json_response(response) return jsonify.make_json_response(response)
@site.route('/photo/<photoid>/add_tag', methods=['POST']) @site.route('/photo/<photoid>/add_tag', methods=['POST'])