def get(self): if is_morning(): day = datetime.now() - timedelta(1) day_title = "yesterday" else: day = datetime.now() day_title = "today" suggestions = Suggestion.get_for_day(day, self.currentgroup) restaurants = [ s.restaurant for s in suggestions ] res_keys = [ r.key() for r in restaurants ] other_restaurants = [] all_restaurants = Restaurant.gql("WHERE group=:1 ORDER BY name", self.currentgroup) for res in all_restaurants: if res.key() not in res_keys: other_restaurants.append(res) context = { 'day': day.toordinal(), 'day_title': day_title, 'restaurants': restaurants, 'other_restaurants': other_restaurants } self.render('rate', context)
def can_vote_for_day(day): return (not userinfo.voted_for_day(day) and Suggestion.get_for_day(day, group).count() > 0)