Cleanup: Rename GroupableMixin.add to add_child for clarity.
Especially since for albums it might sound like you're adding a photo.
This commit is contained in:
		
							parent
							
								
									3f69a2c240
								
							
						
					
					
						commit
						bb5fa816d8
					
				
					 3 changed files with 10 additions and 9 deletions
				
			
		|  | @ -48,7 +48,7 @@ class GroupableMixin: | ||||||
|     group_table = None |     group_table = None | ||||||
| 
 | 
 | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def add(self, member, *, commit=True): |     def add_child(self, member, *, commit=True): | ||||||
|         ''' |         ''' | ||||||
|         Add a child object to this group. |         Add a child object to this group. | ||||||
|         Child must be of the same type as the calling object. |         Child must be of the same type as the calling object. | ||||||
|  | @ -175,7 +175,7 @@ class GroupableMixin: | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def join_group(self, group, *, commit=True): |     def join_group(self, group, *, commit=True): | ||||||
|         ''' |         ''' | ||||||
|         Leave the current group, then call `group.add(self)`. |         Leave the current group, then call `group.add_child(self)`. | ||||||
|         ''' |         ''' | ||||||
|         if not isinstance(group, type(self)): |         if not isinstance(group, type(self)): | ||||||
|             raise TypeError('Group must also be %s' % type(self)) |             raise TypeError('Group must also be %s' % type(self)) | ||||||
|  | @ -184,7 +184,7 @@ class GroupableMixin: | ||||||
|             raise ValueError('Cant join self') |             raise ValueError('Cant join self') | ||||||
| 
 | 
 | ||||||
|         self.leave_group(commit=commit) |         self.leave_group(commit=commit) | ||||||
|         group.add(self, commit=commit) |         group.add_child(self, commit=commit) | ||||||
| 
 | 
 | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def leave_group(self, *, commit=True): |     def leave_group(self, *, commit=True): | ||||||
|  | @ -222,6 +222,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         super().__init__(photodb) |         super().__init__(photodb) | ||||||
|         if isinstance(db_row, (list, tuple)): |         if isinstance(db_row, (list, tuple)): | ||||||
|             db_row = dict(zip(constants.SQL_ALBUM_COLUMNS, db_row)) |             db_row = dict(zip(constants.SQL_ALBUM_COLUMNS, db_row)) | ||||||
|  | 
 | ||||||
|         self.id = db_row['id'] |         self.id = db_row['id'] | ||||||
|         self.title = db_row['title'] or '' |         self.title = db_row['title'] or '' | ||||||
|         self.description = db_row['description'] or '' |         self.description = db_row['description'] or '' | ||||||
|  | @ -242,8 +243,8 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         self._sum_bytes_albums = None |         self._sum_bytes_albums = None | ||||||
| 
 | 
 | ||||||
|     @decorators.required_feature('album.edit') |     @decorators.required_feature('album.edit') | ||||||
|     def add(self, *args, **kwargs): |     def add_child(self, *args, **kwargs): | ||||||
|         return super().add(*args, **kwargs) |         return super().add_child(*args, **kwargs) | ||||||
| 
 | 
 | ||||||
|     @decorators.required_feature('album.edit') |     @decorators.required_feature('album.edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|  | @ -1014,8 +1015,8 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
|         self._cached_qualified_name = None |         self._cached_qualified_name = None | ||||||
| 
 | 
 | ||||||
|     @decorators.required_feature('tag.edit') |     @decorators.required_feature('tag.edit') | ||||||
|     def add(self, *args, **kwargs): |     def add_child(self, *args, **kwargs): | ||||||
|         return super().add(*args, **kwargs) |         return super().add_child(*args, **kwargs) | ||||||
| 
 | 
 | ||||||
|     @decorators.required_feature('tag.edit') |     @decorators.required_feature('tag.edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|  |  | ||||||
|  | @ -1258,7 +1258,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs | ||||||
|             parent = albums.get(current_location.parent.absolute_path, None) |             parent = albums.get(current_location.parent.absolute_path, None) | ||||||
|             if parent is not None: |             if parent is not None: | ||||||
|                 try: |                 try: | ||||||
|                     parent.add(current_album, commit=False) |                     parent.add_child(current_album, commit=False) | ||||||
|                 except exceptions.GroupExists: |                 except exceptions.GroupExists: | ||||||
|                     pass |                     pass | ||||||
|             for photo in new_photos: |             for photo in new_photos: | ||||||
|  |  | ||||||
|  | @ -534,7 +534,7 @@ def post_albums_create(): | ||||||
|         response = jsonify.make_json_response(response, status=400) |         response = jsonify.make_json_response(response, status=400) | ||||||
|         flask.abort(response) |         flask.abort(response) | ||||||
|     if parent is not None: |     if parent is not None: | ||||||
|         parent.add(album) |         parent.add_child(album) | ||||||
|     response = etiquette.jsonify.album(album, minimal=False) |     response = etiquette.jsonify.album(album, minimal=False) | ||||||
|     return jsonify.make_json_response(response) |     return jsonify.make_json_response(response) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue