def get(self, slug): user = User.is_logged(self) query = Koch.all().filter( 'slug =', slug).fetch(1) if len( query ): koch = query[0]; alreadylike = False alreadyfollow = False likesusers = [] koch.views += 1 koch.put() author = koch.author avatar = helpers.get_gravatar( author.email, 90 ) author_recipes_count = Koch.all().filter('author =', author).count(); for like in Like.all().filter( 'koch =', koch ): if like.user.fb_profile_url: lavatar = "https://graph.facebook.com/%s/picture" % (like.user.nickname) elif not like.user.usegravatar and like.user.avatar: lavatar = "/avatar/?user_id=%s" %(like.user.key()) else: lavatar = helpers.get_gravatar( like.user.email, 90 ) likesusers.append({ 'nickname' : like.user.nickname, 'avatar' : lavatar }) if user: alreadylike = Like.alreadylike( koch, user ) alreadyfollow = Friendship.alreadyfollow( user, author ) is_owner = True if user.key() == author.key() else False if author.fb_profile_url: avatar = "https://graph.facebook.com/%s/picture" % (author.nickname) elif not author.usegravatar and author.avatar: avatar = "/avatar/?user_id=%s" %(author.key()) else: avatar = helpers.get_gravatar( author.email, 90 ) last_kochs = Koch.all().filter('author =', author).order('-created').fetch(5); last_from_all = Koch.get_random() current = "explore" humanlikes = intcomma( int( koch.likes) ) self.response.out.write(template.render('templates/details_koch.html', locals())) else: self.error(404)
def get_kochs_data(entities, author=None): kochs = [] user = User.is_logged() for koch in entities: if user: alreadylike = Like.alreadylike( koch, user ) else: alreadylike = False kochs.append({ 'koch' : koch, 'humanlikes' : intcomma( int( koch.likes) ), 'alreadylike' : alreadylike, }) return kochs