File tree Expand file tree Collapse file tree 2 files changed +60
-4
lines changed
Expand file tree Collapse file tree 2 files changed +60
-4
lines changed Original file line number Diff line number Diff line change 594594 "profile_picture" : " http://distillery.s3.amazonaws.com/profiles/profile_113603_75sq_1287035206.jpg" ,
595595 "id" : " 113603"
596596 }
597+ },
598+ {
599+ "type" : " image" ,
600+ "tags" : [],
601+ "location" : {
602+ "latitude" : 37.775180799999987 ,
603+ "id" : " 68841" ,
604+ "longitude" : -122.2270716 ,
605+ "name" : " El Novillo Taco Truck"
606+ },
607+ "comments" : {
608+ "count" : 1
609+ },
610+ "caption" : {
611+ "created_time" : " 1287585453" ,
612+ "text" : " Image with broken comment data " ,
613+ "from" : {
614+ "username" : " darodriguez" ,
615+ "first_name" : " David" ,
616+ "last_name" : " Rodriguez" ,
617+ "type" : " user" ,
618+ "id" : " 113603"
619+ },
620+ "id" : " 495311"
621+ },
622+ "link" : " http://localhost:8000/p/C5Wr/" ,
623+ "likes" : {
624+ "count" : 0
625+ },
626+ "created_time" : " 1287585407" ,
627+ "images" : {
628+ "low_resolution" : {
629+ "url" : " http://distillery-dev.s3.amazonaws.com/media/2010/10/20/1fde15405b6349ef949c9a8f5498868e_6.jpg" ,
630+ "width" : 480 ,
631+ "height" : 480
632+ },
633+ "thumbnail" : {
634+ "url" : " http://distillery-dev.s3.amazonaws.com/media/2010/10/20/1fde15405b6349ef949c9a8f5498868e_5.jpg" ,
635+ "width" : 150 ,
636+ "height" : 150
637+ },
638+ "standard_resolution" : {
639+ "url" : " http://distillery-dev.s3.amazonaws.com/media/2010/10/20/1fde15405b6349ef949c9a8f5498868e_7.jpg" ,
640+ "width" : 612 ,
641+ "height" : 612
642+ }
643+ },
644+ "user_has_liked" : false ,
645+ "id" : " 759211" ,
646+ "user" : {
647+ "username" : " darodriguez" ,
648+ "profile_picture" : " http://distillery.s3.amazonaws.com/profiles/profile_113603_75sq_1287035206.jpg" ,
649+ "id" : " 113603"
650+ }
597651 }
598652 ]
599653}
Original file line number Diff line number Diff line change @@ -94,10 +94,12 @@ def object_from_dictionary(cls, entry):
9494 for like in entry ['likes' ]['data' ]:
9595 new_media .likes .append (User .object_from_dictionary (like ))
9696
97- new_media .comment_count = entry ['comments' ]['count' ]
98- new_media .comments = []
99- for comment in entry ['comments' ]['data' ]:
100- new_media .comments .append (Comment .object_from_dictionary (comment ))
97+ new_media .comment_count = entry .get ('comments' , {}).get ('count' , 0 )
98+ if new_media .comment_count :
99+ new_media .comments = []
100+ if entry .get ('comments' , {}).get ('data' ):
101+ for comment in entry ['comments' ]['data' ]:
102+ new_media .comments .append (Comment .object_from_dictionary (comment ))
101103
102104 new_media .users_in_photo = []
103105 if entry .get ('users_in_photo' ):
You can’t perform that action at this time.
0 commit comments