Skip to content

Commit

Permalink
Add type of face to photo endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Oct 12, 2024
1 parent bd8fe56 commit 2c708ab
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion api/serializers/photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,32 @@ def get_geolocation(self, obj) -> dict:

def get_people(self, obj) -> list:
return [
{"name": f.person.name, "face_url": f.image.url, "face_id": f.id}
{
"name": (
f.person.name
if f.person
else (
f.cluster_person.name
if f.cluster_person
else (
f.classification_person.name
if f.classification_person
else ""
)
)
),
"type": (
"user"
if f.person
else (
"cluster"
if f.cluster_person
else ("classification" if f.classification_person else "")
)
),
"face_url": f.image.url,
"face_id": f.id,
}
for f in obj.faces.all()
]

Expand Down

0 comments on commit 2c708ab

Please sign in to comment.