Skip to content

Commit

Permalink
Fix multiple smaller bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Oct 31, 2024
1 parent f84ec42 commit 8149688
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
34 changes: 21 additions & 13 deletions api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/directory_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 2 additions & 5 deletions api/models/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

0 comments on commit 8149688

Please sign in to comment.