Beispiel #1
0
def make_photo_dict(photo, email):
    photo_dict = {}
    owner = User.get_by_key_name(photo.owner_email)
    photo_dict['image'] = photo.image_url
    photo_dict['owner_email'] = photo.owner_email
    photo_dict['owner_first_name'] = owner.first_name
    photo_dict['owner_last_name'] = owner.last_name
    photo_dict['num_votes'] = Vote.count(photo)
    photo_dict['num_comments'] = len(Comment.for_(photo))
    photo_dict['is_voted'] = Vote.is_voted(email, photo)
    photo_dict['profile_picture'] = owner.profile_picture
    return photo_dict