当前位置: 首页>>代码示例>>Python>>正文


Python tusers.get_current_user函数代码示例

本文整理汇总了Python中tusers.get_current_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_current_user函数的具体用法?Python get_current_user怎么用?Python get_current_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_current_user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

  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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:60,代码来源:add_speaker_record.py

示例2: get

	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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:60,代码来源:reg.py

示例3: get

	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))
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:31,代码来源:tournaments.py

示例4: post

	def post(self):
		user = tusers.get_current_user()

		if user:
			#Check if we are modifying a tournament or making a new one
			if self.request.get('id'):
				new_tournament = ndb.Key('Tournament', int(self.request.get('id'))).get()
			else:
				new_tournament = Tournament()
			new_tournament.name = self.request.get('name')
			new_tournament.owner = [user.key]
			new_tournament.trackpin = pin_gen()
						
			dates_valid = True
			
			try:
				new_tournament.start = datetime.datetime.strptime(self.request.get('start'), '%Y-%m-%d').date()
				new_tournament.end = datetime.datetime.strptime(self.request.get('end'), '%Y-%m-%d').date()
			except ValueError:
				dates_valid = False
				
			if (dates_valid and len(new_tournament.name) > 0):
				new_tournament.put()
			#Send the user back to the tournaments page
			self.redirect('/tournaments')

		else:
			self.redirect(tusers.create_login_url(self.request.uri))
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:28,代码来源:tournaments.py

示例5: get

	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))
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:26,代码来源:trackgrid.py

示例6: post

  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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:33,代码来源:update_profile.py

示例7: get

  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))
开发者ID:nzervoudis,项目名称:tournatrack,代码行数:33,代码来源:tournaman.py

示例8: get

	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()

			#Get the judge object
			j = self.request.get('j')
			j_key = ndb.Key(urlsafe=j)
			judge = j_key.get()

			#If they are authorised, show the CV
			if user.key in t.owner:
				template_values = {
						'judge': judge
				}
				template = JINJA_ENVIRONMENT.get_template('view/judgecv.html')
				self.response.write(template.render(template_values))
				return

			else:
				self.redirect('/tournaments')
		else:
			self.redirect(tusers.create_login_url(self.request.uri))
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:27,代码来源:judgecv.py

示例9: get

    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)
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:32,代码来源:updatereg.py

示例10: post

	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))
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:32,代码来源:custom_room_status.py

示例11: post

  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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:35,代码来源:tournamentinstance.py

示例12: post

    def post(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:
            if self.request.get('updating') == 'j':
                #Get all of the judge objects
                judges = isi.judges()

                for j in judges:
                    name = self.request.get(str(j.key.id()) + '_n')
                    j.name = name

                    cv = self.request.get(str(j.key.id()) + '_c')
                    j.cv = cv

                    j.put()

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

        else:
            self.redirect('/reg?t=' + tid)
开发者ID:TomFarrow,项目名称:tournatrack,代码行数:33,代码来源:updatereg.py

示例13: get

  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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:31,代码来源:tournamentinstance.py

示例14: get

  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))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:26,代码来源:update_profile.py

示例15: get

  def get(self):

    user = tusers.get_current_user()

    #If they're not authenticated deny the request
    if not user:
      self.error(404)
      return

    debater = None
    problem = "DebaterID not valid"

    if self.request.get('id'):
      try:
        dID = self.request.get('id')
        key = ndb.Key('TUser', int(dID))
        debater = key.get()
        problem = None
        if not debater.basic_info:
          problem = "The owner of this ID needs to add their full name and phone number before they can be registered."

      except:
        problem = "DebaterID not valid"

    template_values = {
        'problem' : problem,
        'debater' : debater
        }
    template = JINJA_ENVIRONMENT.get_template('view/json/check_id.json')
    self.response.write(template.render(template_values))
开发者ID:sarrionandia,项目名称:tournatrack,代码行数:30,代码来源:check_id.py


注:本文中的tusers.get_current_user函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。