コード例 #1
0
ファイル: views.py プロジェクト: paulsc/lunchdiscussion
	def get(self):
		context = { 
			'karma_ranking': Restaurant.gql('WHERE group=:1 ORDER BY karma DESC LIMIT 10', self.currentgroup),
			'lunchcount_ranking': Restaurant.gql('WHERE group=:1 ORDER BY lunchcount DESC LIMIT 10', self.currentgroup),
			'best_user': self.currentgroup.get_best_users(),
			'biggest_eater': self.currentgroup.get_biggest_users()			
			}
							
		self.render('stats', context)
コード例 #2
0
ファイル: views.py プロジェクト: paulsc/lunchdiscussion
	def post(self):
		name = cgi.escape(self.request.get('name'))
		name = name.capitalize()
		if name == '':
			self.error(400)
			return
			
		restaurant = Restaurant.gql("WHERE name = :1 AND group = :2", name, self.currentgroup).get()
		if restaurant == None:
			restaurant = Restaurant(name=name, group=self.currentgroup)
			restaurant.put()
		else:
			logging.info("restaurant '%s' already exists, skipping" % name)

		self.get()
コード例 #3
0
ファイル: views.py プロジェクト: paulsc/lunchdiscussion
	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)