@@ -26,15 +26,30 @@ class Meta:
26
26
'image_hash' ,
27
27
'image_path' )
28
28
def get_thumbnail_url (self , obj ):
29
- return obj .thumbnail .url
29
+ try :
30
+ return obj .thumbnail .url
31
+ except :
32
+ return None
30
33
def get_thumbnail_height (self , obj ):
31
- return obj .thumbnail .height
34
+ try :
35
+ return obj .thumbnail .height
36
+ except :
37
+ return None
32
38
def get_thumbnail_width (self , obj ):
33
- return obj .thumbnail .width
39
+ try :
40
+ return obj .thumbnail .width
41
+ except :
42
+ return None
34
43
def get_square_thumbnail_url (self , obj ):
35
- return obj .square_thumbnail .url
44
+ try :
45
+ return obj .square_thumbnail .url
46
+ except :
47
+ return None
36
48
def get_image_url (self , obj ):
37
- return obj .image .url
49
+ try :
50
+ return obj .image .url
51
+ except :
52
+ return None
38
53
def get_geolocation (self , obj ):
39
54
if obj .geolocation_json :
40
55
return json .loads (obj .geolocation_json )
@@ -205,4 +220,37 @@ def get_people(self,obj):
205
220
serialized_person = PersonSerializer (face .person ).data
206
221
if serialized_person not in res :
207
222
res .append (serialized_person )
208
- return res
223
+ return res
224
+
225
+
226
+ class AlbumAutoListSerializer (serializers .ModelSerializer ):
227
+ # people = serializers.SerializerMethodField()
228
+ cover_photo_url = serializers .SerializerMethodField ()
229
+
230
+ class Meta :
231
+ model = AlbumAuto
232
+ fields = (
233
+ "id" ,
234
+ "title" ,
235
+ "timestamp" ,
236
+ "created_on" ,
237
+ "cover_photo_url" ,
238
+ "gps_lat" ,
239
+ # 'people',
240
+ "gps_lon" )
241
+
242
+ def get_cover_photo_url (self ,obj ):
243
+ first_photo = obj .photos .first ()
244
+ return first_photo .image .url
245
+
246
+ # def get_people(self,obj):
247
+ # # ipdb.set_trace()
248
+ # photos = obj.photos.all()
249
+ # res = []
250
+ # for photo in photos:
251
+ # faces = photo.faces.all()
252
+ # for face in faces:
253
+ # serialized_person = PersonSerializer(face.person).data
254
+ # if serialized_person not in res:
255
+ # res.append(serialized_person)
256
+ # return res
0 commit comments