示例#1
0
	def get(self):
		user = tusers.get_current_user()
		
		if user:
			
			#Get a list of tournaments that the user owns
			owner_q = Tournament.query(Tournament.owner == user.key)

			#Get a list of tournaments that the user is attending
			attend_q = Attending.query(ancestor=user.key)


			#Build a list of tournaments to pass to the view
			tournaments = []
			for a in attend_q:
				tournament = tournament_bean()
				tournament.tournament = a.tournament.get()
				tournament.role = a.role
				tournaments.append(tournament)


			template_values = {
				'user' : user,
				'tournaments' : owner_q,
				'attending' : tournaments,
				'logout' : tusers.create_logout_url('/'),
			}
			template = JINJA_ENVIRONMENT.get_template('view/tournaments.html')
			self.response.write(template.render(template_values))
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
示例#2
0
	def post(self):
		user = tusers.get_current_user()

		#Get the requested tournament
		key = ndb.Key(urlsafe=self.request.get('institution'))
		institution = key.get()

		if institution.authorised(user):
			#Remove the attendance record
			q = Attending.query(ancestor=user.key)
			q.filter(Attending.tournament == key.parent().parent())
			q.get(keys_only=True).delete()

			institution.destroy()

		self.redirect(self.request.referer)
示例#3
0
	def post(self):
		user = tusers.get_current_user()

		#Check if the t_key parameter is un use
		if self.request.get('t_key', default_value=False):
			key = ndb.Key(urlsafe=self.request.get('t_key'))
			t = key.get()

			if t.authorised(user):

				#Remove the attendance record
				q = Attending.query(ancestor=user.key)
				q.filter(Attending.tournament == key.parent().parent())
				q.get(keys_only=True).delete()

				key.delete()
		self.redirect(self.request.referer)
示例#4
0
	def post(self):
		user = tusers.get_current_user()

		#Check if the j_key parameter is in use.
		if self.request.get('j_key', default_value=False):
			key = ndb.Key(urlsafe=self.request.get('j_key'))
			j = key.get()

			#Delete from the database
			if j.authorised(user):
				if key.kind() == 'RegisteredIndependentJudge':
					#Remove the attendance record
					q = Attending.query(ancestor=user.key)
					q.filter(Attending.tournament == key.parent().parent())
					q.get(keys_only=True).delete()

				key.delete()

		self.redirect(self.request.referer)