예제 #1
0
파일: views.py 프로젝트: gluwer/przepisymm
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,
  })
예제 #2
0
파일: utils.py 프로젝트: gluwer/przepisymm
  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
예제 #3
0
 def items(self):
   return Recipe.all().filter('rec_vis =', VISIBILITY[2]).filter('disabled =', False).order('-created').fetch(200)