Example #1
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,
          'teams' : reg.teams(),
          'institutions' : reg.institutions()
        }
        template = JINJA_ENVIRONMENT.get_template('view/tabexport/tournaman.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))
Example #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()

        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))
Example #3
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))