diff --git a/api/admin.py b/api/admin.py index a4621d853c..24c58ee03a 100644 --- a/api/admin.py +++ b/api/admin.py @@ -56,17 +56,6 @@ def deduplicate_faces_function(queryset): for similar_face in faces_without_person_label[1:]: similar_face.delete() - -class FaceDeduplication(admin.ModelAdmin): - actions = ["deduplicate_faces"] - - def deduplicate_faces(self, request, queryset): - AsyncTask( - deduplicate_faces_function, - queryset=queryset, - ).run() - - @admin.register(Face) class FaceAdmin(admin.ModelAdmin): list_display = ( @@ -79,9 +68,28 @@ class FaceAdmin(admin.ModelAdmin): ) list_filter = ("person", "cluster") +@admin.register(Photo) +class PhotoAdmin(admin.ModelAdmin): + actions = ["deduplicate_faces"] + list_display = [ + "image_hash", + "owner", + "main_file", + "aspect_ratio", + "last_modified", + "added_on", + "width", + "height", + ] + list_filter = ["owner"] + + def deduplicate_faces(self, request, queryset): + AsyncTask( + deduplicate_faces_function, + queryset=queryset, + ).run() + -# Register your models here. -admin.site.register(Photo, FaceDeduplication) admin.site.register(Person) admin.site.register(AlbumAuto) admin.site.register(AlbumUser) diff --git a/api/directory_watcher.py b/api/directory_watcher.py index a86a09b360..2123355307 100644 --- a/api/directory_watcher.py +++ b/api/directory_watcher.py @@ -132,7 +132,7 @@ def create_new_image(user, path) -> Optional[Photo]: photo.save() photo._check_files() util.logger.warning("photo {} exists already".format(path)) - return None + return photo def handle_new_image(user, path, job_id, photo=None): diff --git a/api/models/photo.py b/api/models/photo.py index 0ea28fa27a..bad3146977 100644 --- a/api/models/photo.py +++ b/api/models/photo.py @@ -873,10 +873,7 @@ def _set_embedded_media(self, obj): return obj.main_file.embedded_media def __str__(self): + main_file_path = self.main_file.path if self.main_file is not None else "No main file" return ( - "{}".format(self.image_hash) - + " - " - + "{}".format(self.owner) - + " - " - + "{}".format(self.main_file.path) + "{} - {} - {}".format(self.image_hash, self.owner, main_file_path) )