def get(self, cook): user = User.is_logged(self) author = User.all().filter('nickname =', cook.lower()).fetch(1) if not len( author ): self.error(404) return author = author[0] if user: alreadyfollow = Friendship.alreadyfollow( user, author ) title = "%s's CookBook" %(author.nickname) subhead = "Discover what %s has shared" % (author.nickname) author_recipes_count = Koch.all().filter('author =', author).count(); 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 ) page = self.request.get_range('page', min_value=0, max_value=1000, default=0) tmp_kochs, next_page, prev_page = helpers.paginate( Koch.all().filter('author =', author).order('-created'), page ) kochs = helpers.get_kochs_data(tmp_kochs) last_kochs = Koch.all().filter('author =', author).order('-created').fetch(5); last_from_all = Koch.get_random() current = "explore" self.response.out.write(template.render('templates/list_kochs.html', locals()))
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_following_data(entities): friends = [] user = User.is_logged() for friend in entities: if not friend.star.usegravatar and friend.star.avatar: avatar = "/avatar/?user_id=%s" %(friend.star.key()) else: avatar = get_gravatar( friend.star.email ) friendship = False if user: friendship = Friendship.alreadyfollow( user, friend.star ) friends.append({ 'fan': friend.star, 'avatar' : avatar, 'friend' : friendship }) return friends