Add more feature_required decorators and config.
This commit is contained in:
		
							parent
							
								
									1b9f7608b1
								
							
						
					
					
						commit
						6bed300496
					
				
					 2 changed files with 42 additions and 0 deletions
				
			
		|  | @ -161,7 +161,9 @@ DEFAULT_CONFIGURATION = { | ||||||
|     'enable_new_photo': True, |     'enable_new_photo': True, | ||||||
|     'enable_new_tag': True, |     'enable_new_tag': True, | ||||||
|     'enable_new_user': True, |     'enable_new_user': True, | ||||||
|  |     'enable_bookmark_edit': True, | ||||||
|     'enable_photo_add_remove_tag': True, |     'enable_photo_add_remove_tag': True, | ||||||
|  |     'enable_photo_edit': True, | ||||||
|     'enable_photo_generate_thumbnail': True, |     'enable_photo_generate_thumbnail': True, | ||||||
|     'enable_photo_reload_metadata': True, |     'enable_photo_reload_metadata': True, | ||||||
|     'enable_tag_edit': True, |     'enable_tag_edit': True, | ||||||
|  |  | ||||||
|  | @ -241,6 +241,11 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         self._sum_bytes_photos = None |         self._sum_bytes_photos = None | ||||||
|         self._sum_bytes_albums = None |         self._sum_bytes_albums = None | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|  |     def add(self, *args, **kwargs): | ||||||
|  |         return super().add(*args, **kwargs) | ||||||
|  | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def add_associated_directory(self, filepath, *, commit=True): |     def add_associated_directory(self, filepath, *, commit=True): | ||||||
|         filepath = pathclass.Path(filepath) |         filepath = pathclass.Path(filepath) | ||||||
|  | @ -272,6 +277,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - add associated directory') |             self.photodb.log.debug('Committing - add associated directory') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def add_photo(self, photo, *, commit=True): |     def add_photo(self, photo, *, commit=True): | ||||||
|         if self.photodb != photo.photodb: |         if self.photodb != photo.photodb: | ||||||
|  | @ -286,6 +292,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - add photo to album') |             self.photodb.log.debug('Committing - add photo to album') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     # No required_feature, let the photo.add_tag take care of that. | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def add_tag_to_all(self, tag, *, nested_children=True, commit=True): |     def add_tag_to_all(self, tag, *, nested_children=True, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -318,6 +325,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         directories = [pathclass.Path(x) for x in directories] |         directories = [pathclass.Path(x) for x in directories] | ||||||
|         return directories |         return directories | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def delete(self, *, delete_children=False, commit=True): |     def delete(self, *, delete_children=False, commit=True): | ||||||
|         self.photodb.log.debug('Deleting album {album:r}'.format(album=self)) |         self.photodb.log.debug('Deleting album {album:r}'.format(album=self)) | ||||||
|  | @ -370,6 +378,14 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         ) |         ) | ||||||
|         return cur.fetchone() is not None |         return cur.fetchone() is not None | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|  |     def join_group(self, *args, **kwargs): | ||||||
|  |         return super().join_group(*args, **kwargs) | ||||||
|  | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|  |     def leave_group(self, *args, **kwargs): | ||||||
|  |         return super().leave_group(*args, **kwargs) | ||||||
|  | 
 | ||||||
|     def photos(self): |     def photos(self): | ||||||
|         photos = [] |         photos = [] | ||||||
|         generator = helpers.select_generator( |         generator = helpers.select_generator( | ||||||
|  | @ -384,6 +400,7 @@ class Album(ObjectBase, GroupableMixin): | ||||||
|         photos.sort(key=lambda x: x.basename.lower()) |         photos.sort(key=lambda x: x.basename.lower()) | ||||||
|         return photos |         return photos | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_album_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def remove_photo(self, photo, *, commit=True): |     def remove_photo(self, photo, *, commit=True): | ||||||
|         if not self.has_photo(photo): |         if not self.has_photo(photo): | ||||||
|  | @ -436,6 +453,7 @@ class Bookmark(ObjectBase): | ||||||
|     def __repr__(self): |     def __repr__(self): | ||||||
|         return 'Bookmark:{id}'.format(id=self.id) |         return 'Bookmark:{id}'.format(id=self.id) | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_bookmark_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def delete(self, *, commit=True): |     def delete(self, *, commit=True): | ||||||
|         cur = self.photodb.sql.cursor() |         cur = self.photodb.sql.cursor() | ||||||
|  | @ -443,6 +461,7 @@ class Bookmark(ObjectBase): | ||||||
|         if commit: |         if commit: | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_bookmark_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def edit(self, title=None, url=None, *, commit=True): |     def edit(self, title=None, url=None, *, commit=True): | ||||||
|         if title is None and url is None: |         if title is None and url is None: | ||||||
|  | @ -575,6 +594,7 @@ class Photo(ObjectBase): | ||||||
|     def bytestring(self): |     def bytestring(self): | ||||||
|         return bytestring.bytestring(self.bytes) |         return bytestring.bytestring(self.bytes) | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_photo_add_remove_tag') | ||||||
|     def copy_tags(self, other_photo): |     def copy_tags(self, other_photo): | ||||||
|         ''' |         ''' | ||||||
|         Take all of the tags owned by other_photo and apply them to this photo. |         Take all of the tags owned by other_photo and apply them to this photo. | ||||||
|  | @ -582,6 +602,7 @@ class Photo(ObjectBase): | ||||||
|         for tag in other_photo.tags(): |         for tag in other_photo.tags(): | ||||||
|             self.add_tag(tag) |             self.add_tag(tag) | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_photo_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def delete(self, *, delete_file=False, commit=True): |     def delete(self, *, delete_file=False, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -804,6 +825,7 @@ class Photo(ObjectBase): | ||||||
|             self.photodb.log.debug('Committing - reload metadata') |             self.photodb.log.debug('Committing - reload metadata') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_photo_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def relocate(self, new_filepath, *, allow_duplicates=False, commit=True): |     def relocate(self, new_filepath, *, allow_duplicates=False, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -857,6 +879,7 @@ class Photo(ObjectBase): | ||||||
|             self.photodb.log.debug('Committing - remove photo tag') |             self.photodb.log.debug('Committing - remove photo tag') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_photo_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def rename_file(self, new_filename, *, move=False, commit=True): |     def rename_file(self, new_filename, *, move=False, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -979,6 +1002,11 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
|         self.photodb.caches['tag'].remove(self.id) |         self.photodb.caches['tag'].remove(self.id) | ||||||
|         self._cached_qualified_name = None |         self._cached_qualified_name = None | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|  |     def add(self, *args, **kwargs): | ||||||
|  |         return super().add(*args, **kwargs) | ||||||
|  | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def add_synonym(self, synname, *, commit=True): |     def add_synonym(self, synname, *, commit=True): | ||||||
|         synname = self.photodb.normalize_tagname(synname) |         synname = self.photodb.normalize_tagname(synname) | ||||||
|  | @ -1004,6 +1032,7 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
| 
 | 
 | ||||||
|         return synname |         return synname | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def convert_to_synonym(self, mastertag, *, commit=True): |     def convert_to_synonym(self, mastertag, *, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -1053,6 +1082,7 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - convert to synonym') |             self.photodb.log.debug('Committing - convert to synonym') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def delete(self, *, delete_children=False, commit=True): |     def delete(self, *, delete_children=False, commit=True): | ||||||
|         self.photodb.log.debug('Deleting tag {tag:r}'.format(tag=self)) |         self.photodb.log.debug('Deleting tag {tag:r}'.format(tag=self)) | ||||||
|  | @ -1086,6 +1116,14 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - edit tag') |             self.photodb.log.debug('Committing - edit tag') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|  |     def join_group(self, *args, **kwargs): | ||||||
|  |         return super().join_group(*args, **kwargs) | ||||||
|  | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|  |     def leave_group(self, *args, **kwargs): | ||||||
|  |         return super().leave_group(*args, **kwargs) | ||||||
|  | 
 | ||||||
|     def qualified_name(self, *, max_len=None): |     def qualified_name(self, *, max_len=None): | ||||||
|         ''' |         ''' | ||||||
|         Return the 'group1.group2.tag' string for this tag. |         Return the 'group1.group2.tag' string for this tag. | ||||||
|  | @ -1121,6 +1159,7 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
| 
 | 
 | ||||||
|         return qualname |         return qualname | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def remove_synonym(self, synname, *, commit=True): |     def remove_synonym(self, synname, *, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  | @ -1147,6 +1186,7 @@ class Tag(ObjectBase, GroupableMixin): | ||||||
|             self.photodb.log.debug('Committing - remove synonym') |             self.photodb.log.debug('Committing - remove synonym') | ||||||
|             self.photodb.commit() |             self.photodb.commit() | ||||||
| 
 | 
 | ||||||
|  |     @decorators.required_feature('enable_tag_edit') | ||||||
|     @decorators.transaction |     @decorators.transaction | ||||||
|     def rename(self, new_name, *, apply_to_synonyms=True, commit=True): |     def rename(self, new_name, *, apply_to_synonyms=True, commit=True): | ||||||
|         ''' |         ''' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue