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))
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))
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() #Create a registration record reg = new_tournament.preRegRecord().get() if (reg == None): reg = PreRegRecord(parent=new_tournament.key) reg.open = False reg.put() #Send the user back to the tournaments page self.redirect('/tournaments') 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 = 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))
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))
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))