def index(request): if request.user.is_authenticated(): favs = Favs.get_list(request.user.key()) else: favs = None return render_to_response('index/index.html',{ 'categories': Category.get_for_lists(), 'hpinfo': SPage.get_by_key_name('hpinfo'), 'new_recipes': Recipe.all().filter('rec_vis =', VISIBILITY[2]).filter('disabled =', False).order('-created').fetch(10), 'pop_recipes': Recipe.all().filter('rec_vis =', VISIBILITY[2]).filter('disabled =', False).order('-views').fetch(10), 'fav_recipes': favs, })
def tx(key, incr): recipe = Recipe.get(db.Key(key)) if recipe: recipe.views += incr to_db = [recipe] idx = RecipeIdx.get(db.Key.from_path('RecipeIdx', 'idx', parent=recipe.key())) if idx: idx.views = recipe.views to_db.append(idx) fri = RecipeFriends.get(db.Key.from_path('RecipeFriends', 'fri', parent=recipe.key())) if fri: fri.views = recipe.views to_db.append(fri) db.put(to_db) return True
def items(self): return Recipe.all().filter('rec_vis =', VISIBILITY[2]).filter('disabled =', False).order('-created').fetch(200)