Photo.add_tag returns the added tag; site displays the normalized name instead of user input
This commit is contained in:
		
							parent
							
								
									70f284d413
								
							
						
					
					
						commit
						3be8813a0a
					
				
					 2 changed files with 6 additions and 4 deletions
				
			
		|  | @ -422,8 +422,9 @@ class Photo(ObjectBase): | |||
|     def add_tag(self, tag, *, commit=True): | ||||
|         tag = self.photodb.get_tag(tag) | ||||
| 
 | ||||
|         if self.has_tag(tag, check_children=False): | ||||
|             return | ||||
|         existing = self.has_tag(tag, check_children=False) | ||||
|         if existing: | ||||
|             return existing | ||||
| 
 | ||||
|         # If the new tag is less specific than one we already have, | ||||
|         # keep our current one. | ||||
|  | @ -431,7 +432,7 @@ class Photo(ObjectBase): | |||
|         if existing: | ||||
|             message = 'Preferring existing {exi:s} over {tag:s}'.format(exi=existing, tag=tag) | ||||
|             self.photodb.log.debug(message) | ||||
|             return | ||||
|             return existing | ||||
| 
 | ||||
|         # If the new tag is more specific, remove our current one for it. | ||||
|         for parent in tag.walk_parents(): | ||||
|  | @ -447,6 +448,7 @@ class Photo(ObjectBase): | |||
|         if commit: | ||||
|             self.photodb.log.debug('Committing - add photo tag') | ||||
|             self.photodb.commit() | ||||
|         return tag | ||||
| 
 | ||||
|     def albums(self): | ||||
|         ''' | ||||
|  |  | |||
|  | @ -673,7 +673,7 @@ def post_photo_add_remove_tag_core(photoid, tagname, add_or_remove): | |||
|     elif add_or_remove == 'remove': | ||||
|         photo.remove_tag(tag) | ||||
| 
 | ||||
|     response = {'tagname': tagname} | ||||
|     response = {'tagname': tag.name} | ||||
|     return jsonify.make_json_response(response)     | ||||
| 
 | ||||
| @site.route('/photo/<photoid>/add_tag', methods=['POST']) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue