Exemplo n.º 1
0
  def get(self):
    user = tusers.get_current_user()

    if user:

      name = user.full_name
      current_institution = user.current_institution
      public = user.public_profile
      phone = user.phone

      form = ProfileForm()
      form.name.data = name
      form.institution.data = current_institution
      form.public.data = public
      form.phone.data = phone

      template_values = {
        'user' : user,
        'logout' : tusers.create_logout_url('/'),
        'form' : form
      }
      template = JINJA_ENVIRONMENT.get_template('view/update_profile.html')
      self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 2
0
  def get(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):
        reg = t.preRegRecord().get()
        if (reg == None):
          reg = PreRegRecord(parent=key)
          reg.open = False
          reg.put()


        template_values = {
          'user' : user,
          't' : t,
          'logout' : tusers.create_logout_url('/'),
          'r' : reg,
          'i_judges' : reg.indyJudges(),
          'institutions' : reg.institutions()
        }
        template = JINJA_ENVIRONMENT.get_template('view/tabexport/tournaman_j.csv')
        self.response.headers['Content-Type'] = 'text/csv'
        self.response.write(template.render(template_values))

      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 3
0
  def post(self):
    user = tusers.get_current_user()

    if user:

      form = ProfileForm(self.request.POST)
      if (form.validate()):
        user.full_name = form.name.data
        user.current_institution = form.institution.data
        user.public_profile = form.public.data
        user.phone = form.phone.data
        user.put()

        if form.email.data:
          user.change_email(form.email.data)

        if form.email_code.data:
          user.verify_email(form.email_code.data)

        self.redirect('/update_profile')

      else:

        template_values = {
          'user' : user,
          'logout' : tusers.create_logout_url('/'),
          'form' : form
        }
        template = JINJA_ENVIRONMENT.get_template('view/update_profile.html')
        self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 4
0
    def get(self):
        user = tusers.get_current_user()
        tid = self.request.get('t')

        if not user:
            self.redirect('/reg?t=' + tid)

        #Get the requested tournament
        key = ndb.Key('Tournament', int(tid))
        t = key.get()

        reg = t.preRegRecord().get()

        isi = reg.isInstitution(user)

        if isi:

            template_values = {
            'user' : user,
            't' : t,
            'logout' : tusers.create_logout_url('/'),
            'login' : tusers.create_login_url('/reg?t=' + tid),
            'r' : reg,
            'isi' : isi,
            'teams' : isi.teams(),
            'reg_key' : isi.key.urlsafe()
            }
            template = JINJA_ENVIRONMENT.get_template('view/update_inst_teams.html')
            self.response.write(template.render(template_values))

        else:
            self.redirect('/reg?t=' + tid)
Exemplo n.º 5
0
  def get(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):
        reg = t.preRegRecord().get()
        if (reg == None):
          reg = PreRegRecord(parent=key)
          reg.open = False
          reg.put()

        template_values = {
          'user' : user,
          't' : t,
          'logout' : tusers.create_logout_url('/'),
          'r' : reg
        }
        template = JINJA_ENVIRONMENT.get_template('view/tournaman.html')
        self.response.write(template.render(template_values))

      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 6
0
	def get(self):
		user = tusers.get_current_user()

		#Get the requested tournament
		tid = self.request.get('t')
		key = ndb.Key('Tournament', int(tid))
		t = key.get()

		reg = t.preRegRecord().get()

		isj = reg.isJudge(user)
		ist = reg.isOpenTeam(user)
		isi = reg.isInstitution(user)

		# Initialise variables so that they can be passed to the view
		iJudges = None
		iTeams = None
		iJudgeCount = 0
		iTeamCount = 0

		# If they are already registered as a team, pre-populate the
		# modify teams form
		if (ist):
			form = TeamForm()
			form.teamName.data = ist.teamName
			form.sp1Name.data = ist.sp1Name
			form.sp2Name.data = ist.sp2Name
			form.sp1Novice.data = ist.sp1Novice
			form.sp2Novice.data = ist.sp2Novice
			form.sp1ESL.data = ist.sp1ESL
			form.sp2ESL.data = ist.sp2ESL

		elif (isi):
			form = InstRegForm()
			iJudges = isi.judges()
			iJudgeCount = iJudges.count(limit=500)
			iTeams = isi.teams()
			iTeamCount = iTeams.count(limit=500)

		else:
			form = None

		template_values = {
			'user' : user,
			't' : t,
			'logout' : tusers.create_logout_url('/'),
			'login' : tusers.create_login_url('/reg?t=' + tid),
			'r' : reg,
			'isj' : isj,
			'ist' : ist,
			'isi' : isi,
			'form' : form,
			'regd' : (isj!=None) or (ist!=None) or (isi!=None),
			'iTeams' : iTeams,
			'iJudges' : iJudges,
			'iJudgeCount' : iJudgeCount,
			'iTeamCount' : iTeamCount
		}
		template = JINJA_ENVIRONMENT.get_template('view/reg.html')
		self.response.write(template.render(template_values))
Exemplo n.º 7
0
	def post(self):
		user = tusers.get_current_user()
		#Get the requested tournament
		tid = self.request.get('t')
		t_key = ndb.Key('Tournament', int(tid))
		t = t_key.get()
				
		if (user and user.key in t.owner):

			form = CustomStatusForm(self.request.POST)
			if form.validate():
				if not t.customRoomStatus:
					t.customRoomStatus = [form.name.data]
				else:
					t.customRoomStatus.append(form.name.data)
				t.put()
				self.redirect('/custom_room_status?t=' + tid)

			else:

				template_values = {
				'user' : user,
				't' : t,
				'logout' : tusers.create_logout_url('/'),
				'form' : form,
				}
				template = JINJA_ENVIRONMENT.get_template('view/custom_room_status.html')
				self.response.write(template.render(template_values))


		else:
			self.redirect(tusers.create_login_url(self.request.uri))
  def post(self):
    user = tusers.get_current_user()

    if user:

      form = SpeakerRecordForm(self.request.POST)
      if (form.validate()):
        #Populate a new speaker record with the form data
        record = PerfSpeakerRecord(parent=user.key)

        record.tournament = form.tournamentName.data
        record.startDate = form.startDate.data

        record.teamRank = form.teamRank.data
        record.averageSpeaks = float(form.averageSpeaks.data)
        record.speakerRank = form.speakerRank.data

        record.champion = form.champion.data
        record.finalist = form.finalist.data
        record.semifinalist = form.semifinalist.data
        record.quarterfinalist = form.quarterfinalist.data
        record.octofinalist = form.octofinalist.data
        record.doubleoctofinalist = form.doubleoctofinalist.data

        record.ESLBreak = form.eslBreak.data
        record.ESLChampion = form.eslChampion.data
        record.EFLBreak = form.eflBreak.data
        record.EFLChampion = form.eflChampion.data

        record.NoviceBreak = form.noviceBreak.data
        record.NoviceChampion = form.noviceChampion.data

        #Check if this is a breaking record
        if record.finalist or record.semifinalist or record.quarterfinalist or record.octofinalist or record.doubleoctofinalist or record.NoviceBreak or record.ESLBreak or record.EFLBreak:
          record.isBreak = True
        else:
          record.isBreak = False

        #Check if this is a winning record
        if record.champion or record.NoviceChampion or record.ESLChampion or record.EFLChampion:
          record.isWin = True
        else:
          record.isWin = False

        record.put()

        self.redirect('/myProfile')

      else:

        template_values = {
          'user' : user,
          'logout' : tusers.create_logout_url('/'),
          'form' : form
        }
        template = JINJA_ENVIRONMENT.get_template('view/add_speaker_record.html')
        self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
  def get(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t_key')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):

        #Pre-Populate the Tournament Info Form
        form = TournamentInfoForm()
        form.blurb.data = t.blurb
        form.email.data = t.contact_email
        form.homepage.data = t.homepage
        form.facebook.data = t.facebook

        template_values = {
          'user' : user,
          'logout' : tusers.create_logout_url('/'),
          't' : t,
          'form' : form
        }
        template = JINJA_ENVIRONMENT.get_template('view/tournament.html')
        self.response.write(template.render(template_values))

      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 10
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))
Exemplo n.º 11
0
  def post(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t_key')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):
        form = TournamentInfoForm(self.request.POST)

        #Check that the fields are valid
        if form.validate():
          #If they are, update the tournament
          t.blurb = form.blurb.data
          t.contact_email = form.email.data
          t.homepage = form.homepage.data
          t.facebook = form.facebook.data
          t.put()
          self.redirect('/tournament_instance?t_key=' + str(t.key.id()))
        else:
          #Otherwise output the form again
          template_values = {
            'user' : user,
            'logout' : tusers.create_logout_url('/'),
            't' : t,
            'form' : form
          }
          template = JINJA_ENVIRONMENT.get_template('view/tournament.html')
          self.response.write(template.render(template_values))
      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 12
0
	def get(self):
		user = tusers.get_current_user()
		#Get the requested tournament
		tid = self.request.get('t')
		t_key = ndb.Key('Tournament', int(tid))
		t = t_key.get()
				
		if (user and user.key in t.owner):
			#Get all of the rooms whose parent is the current tournament
			q = t.rooms()
			
			template_values = {
				'user' : user,
				't' : t,
				'rooms' : q,
				'logout' : tusers.create_logout_url('/'),
			}
			#Check if this is an AJAX request for the raw table
			if (self.request.get('raw') == '1'):
				template = JINJA_ENVIRONMENT.get_template('view/rawgrid.html')
			else:
				template = JINJA_ENVIRONMENT.get_template('view/trackgrid.html')
			self.response.write(template.render(template_values))
						
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 13
0
	def post(self):
		user = tusers.get_current_user()
		form = TeamForm(self.request.POST)

		t_string = self.request.get('t')
		t_key = ndb.Key(urlsafe=t_string)
		team = t_key.get()

		institution = None
		t = None

		# If it is an institutional team, don't let them update the contact info
		# with this method, as that data belongs to the Institution
		if (isinstance(team, InstitutionTeam)):
			institution = team.key.parent().get()
			form.leadName.data = institution.leadName
			form.phone.data = institution.phone

			reg = institution.key.parent().get()

		elif (isinstance(team, RegisteredOpenTeam)):
			reg = t_key.parent().get()

		t = reg.key.parent().get()

		#Check if they are allowed to edit
		if team.authorised(user):

			#If valid, update the team object
			if (form.validate()):

				team.leadName = form.leadName.data
				team.phone = form.phone.data
				team.teamName = form.teamName.data
				team.sp1Name = form.sp1Name.data
				team.sp2Name = form.sp2Name.data
				team.sp1ESL = form.sp1ESL.data
				team.sp2ESL = form.sp2ESL.data
				team.sp1Novice = form.sp1Novice.data
				team.sp2Novice = form.sp2Novice.data

				team.put()

				self.redirect('/reg_control?t=' + str(t.key.id()))
			else:
				template_values = {
					'user' : user,
					't' : t,
					'logout' : tusers.create_logout_url('/'),
					'login' : tusers.create_login_url('/mod/team?j=' + t_key.urlsafe()),
					'r' : reg,
					'form' : form,
					'team' : t_key.urlsafe(),
					'institution' : institution
				}
				template = JINJA_ENVIRONMENT.get_template('view/modteam.html')
				self.response.write(template.render(template_values))
		else:
			self.redirect(self.request.referer)
Exemplo n.º 14
0
  def get(self):
    user = tusers.get_current_user()

    #Get the requested tournament
    t_key_string = self.request.get('t')

    key = ndb.Key(urlsafe=t_key_string)
    t = key.get()

    reg = t.preRegRecord().get()

    ist = None

    team_code = self.request.get('team')

    #If a manual team code has been provided, use it
    if (team_code):
      t_key = ndb.Key(urlsafe=team_code)
      ist = t_key.get()

    #Otherwise use the team that they are registered as
    else:
      ist = reg.isOpenTeam(user)

    # If they are already registered as a team, pre-populate the
    # modify teams form
    if (ist):
      form = TeamForm()
      form.teamName.data = ist.teamName
      form.sp1Name.data = ist.speaker1()
      form.sp2Name.data = ist.speaker2()
      form.sp1Novice.data = ist.sp1Novice
      form.sp2Novice.data = ist.sp2Novice
      form.sp1ESL.data = ist.sp1ESL
      form.sp2ESL.data = ist.sp2ESL

      if ist.sp1Key:
        form.sp1Key.data = ist.sp1Key.id()
      if ist.sp2Key:
        form.sp2Key.data = ist.sp2Key.id()

    else:
      self.redirect('/reg?t=' + tid)
      return

    template_values = {
      'user' : user,
      't' : t,
      'logout' : tusers.create_logout_url('/'),
      'login' : tusers.create_login_url('/reg?t=' + str(key.id())),
      'r' : reg,
      'ist' : ist,
      'form' : form,
    }
    template = JINJA_ENVIRONMENT.get_template('view/update_team_details.html')
    self.response.write(template.render(template_values))
Exemplo n.º 15
0
	def get(self):
		user = tusers.get_current_user()
		if user:
			template_values = {
				'user' : user,
				'logout' : tusers.create_logout_url('/')
			}
			template = JINJA_ENVIRONMENT.get_template('view/index.html')
			self.response.write(template.render(template_values))
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 16
0
	def get(self):
		user = tusers.get_current_user()
		form = TeamForm()

		t_string = self.request.get('t')
		t_key = ndb.Key(urlsafe=t_string)
		team = t_key.get()

		t = None
		reg = None

		if team.authorised(user):
			form.teamName.data = team.teamName
			form.sp1Name.data = team.sp1Name
			form.sp2Name.data = team.sp2Name
			form.sp1ESL.data = team.sp1ESL
			form.sp1Novice.data = team.sp1Novice
			form.sp2ESL.data = team.sp2ESL
			form.sp2Novice.data = team.sp2ESL

			institution = None

			if isinstance(team, RegisteredOpenTeam ):
				form.leadName.data = team.leadName
				form.email.data = team.email
				form.phone.data = team.phone
				reg = t_key.parent().get()

			elif isinstance(team, InstitutionTeam):
				institution = team.key.parent().get()
				form.leadName.data = institution.leadName
				form.phone.data = institution.phone
				form.email.data = institution.email
				reg = t_key.parent().parent().get()

			t = reg.key.parent().get()

			template_values = {
				'user' : user,
				'logout' : tusers.create_logout_url('/'),
				'login' : tusers.create_login_url('/mod/team?t=' + t_string),
				'r' : reg,
				't' : t,
				'form' : form,
				'institution' : institution,
				'team' : t_key.urlsafe()
			}
			template = JINJA_ENVIRONMENT.get_template('view/modteam.html')
			self.response.write(template.render(template_values))
			return
		else:
			self.redirect(self.request.referer)
Exemplo n.º 17
0
  def get(self):
    user = tusers.get_current_user()

    public_profiles = TUser.query(TUser.public_profile == True)


    template_values = {
      'user' : user,
      'logout' : tusers.create_logout_url('/'),
      'login' : tusers.create_login_url('/directory'),
      'public_profiles' : public_profiles
    }
    template = JINJA_ENVIRONMENT.get_template('view/directory.html')
    self.response.write(template.render(template_values))
Exemplo n.º 18
0
	def post(self):
		user = tusers.get_current_user()
		form = JudgeForm(self.request.POST)

		j = self.request.get('j')
		j_key = ndb.Key(urlsafe=j)
		judge = j_key.get()

		reg = None
		institution = None

		if judge.authorised(user):


			if isinstance(judge, InstitutionJudge):
				institution = j_key.parent().get()
				reg = institution.key.parent().get()

				form.email.data = institution.email
				form.phone.data = institution.phone

			elif isinstance(judge, RegisteredIndependentJudge):
				reg = j_key.parent().get()

			t = reg.key.parent().get()

			if (form.validate()):

				judge.name = form.name.data
				judge.phone = form.phone.data
				judge.email = form.email.data
				judge.cv = form.cv.data

				judge.put()

				self.redirect('/reg_control?t=' + str(t.key.id()))
			else:
				template_values = {
					'user' : user,
					't' : t,
					'logout' : tusers.create_logout_url('/'),
					'login' : tusers.create_login_url('/mod/judge?j=' + j),
					'r' : reg,
					'form' : form,
					'institution' : institution,
				}
				template = JINJA_ENVIRONMENT.get_template('view/modjudge.html')
				self.response.write(template.render(template_values))
		else:
			self.redirect(self.request.referer)
Exemplo n.º 19
0
	def get(self):
		user = tusers.get_current_user()
		form = JudgeForm()

		j = self.request.get('j')
		j_key = ndb.Key(urlsafe=j)
		judge = j_key.get()

		reg = None

		institution = None

		if judge.authorised(user):
			form.name.data = judge.name
			form.cv.data = judge.cv

			if isinstance(judge, InstitutionJudge):
				institution = j_key.parent().get()
				t = j_key.parent().parent().parent().get()
				form.email.data = institution.email
				form.phone.data = institution.phone

				reg = j_key.parent().parent().get()

			elif isinstance(judge, RegisteredIndependentJudge):
				reg = j_key.parent().get()
				form.email.data = judge.email
				form.phone.data = judge.phone

			t = reg.key.parent().get()

			template_values = {
				'user' : user,
				't' : t,
				'logout' : tusers.create_logout_url('/'),
				'login' : tusers.create_login_url('/mod/judge?j=' + j),
				'r' : reg,
				'form' : form,
				'j' : j_key.urlsafe(),
				'institution' : institution
			}
			template = JINJA_ENVIRONMENT.get_template('view/modjudge.html')
			self.response.write(template.render(template_values))
			return
		else:
			self.redirect(self.request.referer)
Exemplo n.º 20
0
  def get(self):
    user = tusers.get_current_user()

    if user:

      form = SpeakerRecordForm()

      template_values = {
        'user' : user,
        'logout' : tusers.create_logout_url('/'),
        'form' : form
      }
      template = JINJA_ENVIRONMENT.get_template('view/add_speaker_record.html')
      self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 21
0
  def post(self):
    user = tusers.get_current_user()

    if user:

      form = JudgeRecordForm(self.request.POST)
      if (form.validate()):
        #Populate a new speaker record with the form data
        record = PerfJudgeRecord(parent=user.key)

        record.tournament = form.tournamentName.data
        record.startDate = form.startDate.data

        record.CA = form.CA.data
        record.DCA = form.DCA.data
        record.equity = form.equity.data

        record.chair = form.chair.data
        record.broke = form.broke.data
        record.outroundChair = form.outroundChair.data

        #Store whether or not there is an achievement in this record.
        if record.CA or record.DCA or record.equity or record.chair or record.broke or record.outroundChair:
          record.isAchievement = True
        else:
          record.isAchievement = False

        record.put()

        self.redirect('/myProfile')

      else:

        template_values = {
          'user' : user,
          'logout' : tusers.create_logout_url('/'),
          'form' : form
        }
        template = JINJA_ENVIRONMENT.get_template('view/add_speaker_record.html')
        self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 22
0
  def get(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):
        reg = t.preRegRecord().get()
        if (reg == None):
          reg = PreRegRecord(parent=key)
          reg.open = False
          reg.put()

        iJudges = reg.indyJudges()
        teams = reg.teams()
        institutions = reg.institutions()


        template_values = {
          'user' : user,
          't' : t,
          'logout' : tusers.create_logout_url('/'),
          'r' : reg,
          'ijudges' : iJudges,
          'jcount' : reg.totalJudgeCount(),
          'teams' : teams,
          'institutions' : institutions,
          'tcount' : reg.totalTeamCount(),
          'icount' : institutions.count(limit=500),
        }
        template = JINJA_ENVIRONMENT.get_template('view/recipients.html')
        self.response.write(template.render(template_values))

      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 23
0
	def get(self):
		user = tusers.get_current_user()
		#Get the requested tournament
		tid = self.request.get('t')
		t_key = ndb.Key('Tournament', int(tid))
		t = t_key.get()

		form = CustomStatusForm()
				
		if (user and user.key in t.owner):

			template_values = {
				'user' : user,
				't' : t,
				'logout' : tusers.create_logout_url('/'),
				'form' : form,
			}
			template = JINJA_ENVIRONMENT.get_template('view/custom_room_status.html')
			self.response.write(template.render(template_values))
						
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 24
0
  def get(self):
    user = tusers.get_current_user()

    if user:

      name = user.full_name
      current_institution = user.current_institution

      if (not name):
        self.redirect('/update_profile')

      else:

        template_values = {
          'user' : user,
        ' logout' : tusers.create_logout_url('/'),
        }
        template = JINJA_ENVIRONMENT.get_template('view/profile.html')
        self.response.write(template.render(template_values))

    else:
      self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 25
0
	def get(self):
		user = tusers.get_current_user()
		
		if user:
			#Get the requested tournament
			tid = self.request.get('t')
			key = ndb.Key('Tournament', int(tid))
			t = key.get()
			
			if (t and user.key in t.owner):
				template_values = {
					'user' : user,
					't' : t,
					'logout' : tusers.create_logout_url('/'),
				}
				template = JINJA_ENVIRONMENT.get_template('view/trackpin.html')
				self.response.write(template.render(template_values))

			else:
				self.redirect('/tournaments')
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
Exemplo n.º 26
0
    def get(self):
        user = tusers.get_current_user()

        # Get the requested tournament
        tid = self.request.get("t")
        key = ndb.Key("Tournament", int(tid))
        t = key.get()

        reg = t.preRegRecord().get()

        form = JudgeForm()

        template_values = {
            "user": user,
            "t": t,
            "logout": tusers.create_logout_url("/"),
            "login": tusers.create_login_url("/reg/judge?t=" + tid),
            "r": reg,
            "form": form,
        }
        template = JINJA_ENVIRONMENT.get_template("view/regjudge.html")
        self.response.write(template.render(template_values))
Exemplo n.º 27
0
	def get(self):
		user = tusers.get_current_user()
		
		#Get the requested tournament
		tid = self.request.get('t')
		key = ndb.Key('Tournament', int(tid))
		t = key.get()
			
		reg = t.preRegRecord().get()

		form = JudgeForm()
					
		template_values = {
			'user' : user,
			't' : t,
			'logout' : tusers.create_logout_url('/'),
			'login' : tusers.create_login_url('/reg/judge?t=' + tid),
			'r' : reg,
			'form' : form,
		}
		template = JINJA_ENVIRONMENT.get_template('view/regjudge.html')
		self.response.write(template.render(template_values))
Exemplo n.º 28
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)

			#Tournaments that the user has registered for
			reg_q = RegisteredEntity.query(RegisteredEntity.user == user.key)
			attending = reg_q.map(tournament_for_registration)
			logging.info(attending)

			template_values = {
				'user' : user,
				'tournaments' : owner_q,
				'logout' : tusers.create_logout_url('/'),
				'attending' : attending
			}
			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))
Exemplo n.º 29
0
  def get(self):
    user = tusers.get_current_user()

    #Get the requested tournament
    tid = self.request.get('t')
    key = ndb.Key('Tournament', int(tid))
    t = key.get()

    reg = t.preRegRecord().get()

    #This page relies on the reg record, but it might not exist in some
    #older tournaments. Check it exists before proceding.
    if (reg == None):
      reg = PreRegRecord(parent=t.key)
      reg.open = False
      reg.put()


    isj = reg.isJudge(user)
    ist = reg.isOpenTeam(user)
    isi = reg.isInstitution(user)

    template_values = {
      'user' : user,
      't' : t,
      'logout' : tusers.create_logout_url('/'),
      'login' : tusers.create_login_url('/hub?t=' + tid),
      'r' : reg,
      'isj' : isj,
      'ist' : ist,
      'isi' : isi,
      'regd' : (isj!=None) or (ist!=None) or (isi!=None),
      'contact_available' : t.facebook or t.contact_email or t.homepage
    }
    template = JINJA_ENVIRONMENT.get_template('view/hub.html')
    self.response.write(template.render(template_values))
Exemplo n.º 30
0
  def post(self):
    user = tusers.get_current_user()

    if user:
      #Get the requested tournament
      tid = self.request.get('t')
      key = ndb.Key('Tournament', int(tid))
      t = key.get()

      if (t and user.key in t.owner):
        reg = t.preRegRecord().get()
        if (reg == None):
          reg = PreRegRecord(parent=key)
          reg.open = False
          reg.put()

        iJudges = reg.indyJudges()
        teams = reg.teams()
        institutions = reg.institutions()

        mail_from = "Tournatrack"
        subject = t.name
        body = self.request.get('mbody')
        body += "\n******\nYou are receiving this email because you registered for the %s at http://tournatrack.com"%t.name

        logging.info(body)

        #Get the username and password from the config file
        Config = ConfigParser.ConfigParser()
        Config.read('settings.ini')

        uname = Config.get('mail', 'uname')
        pw = Config.get('mail', 'password')

        #Open connection to SendGrid
        sendGrid = sendgrid.SendGridClient(uname, pw, secure=True)

        #Create the message
        comm = message.Mail(from_email=mail_from, from_name="Tournatrack", subject=subject, text=body)

        #Add teams if necessary
        if self.request.get('teams'):
          for t in teams:
            owner = t.user.get()
            comm.add_to(owner.preferredEmail())

            if owner.full_name:
              comm.add_to_name(owner.full_name)
            else:
              comm.add_to_name("Debater")

        #Add judges if necessary
        if self.request.get('judges'):
          for j in iJudges:
            owner = j.user.get()
            comm.add_to(owner.preferredEmail())

            if owner.full_name:
              comm.add_to_name(owner.full_name)
            else:
              comm.add_to_name("Debater")

        #Add institutions if necessary
          logging.info("Going to institutions")
          for i in institutions:
            owner = i.user.get()
            comm.add_to(owner.preferredEmail())

            if owner.full_name:
              comm.add_to_name(owner.full_name)
            else:
              comm.add_to_name("Debater")


        #Add the owner
        comm.add_to(user.preferredEmail())
        comm.add_to_name(user.full_name)

        logging.info(sendGrid.send(comm))


        template_values = {
          'user' : user,
          't' : t,
          'logout' : tusers.create_logout_url('/'),
        }
        template = JINJA_ENVIRONMENT.get_template('view/message_sent.html')
        self.response.write(template.render(template_values))

      else:
        self.redirect('/tournaments')
    else:
      self.redirect(tusers.create_login_url(self.request.uri))