Ejemplo n.º 1
0
def email_picks_link(user, entries, week, reminder):

    subject = '2012 NFL Suicide Pool: Your Picks for Week %d' % week
    if reminder:
        subject = 'REMINDER: ' + subject
        
    token = users.make_login_token(user)
    args = {
        'name': user.name,
        'entries': '\n'.join(e for e in entries),
        'link': 'http://www.jgsuicidepool.com/login/%s' % token,
        'week': week,
        'deadline': weeks.deadline(week).strftime('%A, %B %d at %I:%M%p'),
    }
    plain_template = picks_template
    html_template = html_picks_template
    if reminder:
        plain_template = reminder_picks_template 
        html_template = reminder_html_picks_template
    plain = picks_template % args
    args['deadline'] = '<b>%s</b>' % args['deadline']
    args['entries'] = args['entries'].replace('\n', '<br/>')
    args['link'] = '<a href="%(link)s">%(link)s</a>' % args
    html = html_template % args
    _send_mail([user.email], subject, plain, html)
Ejemplo n.º 2
0
def email_new_user(email, token, num_entries):
    logging.info('Emailing new user %s', email)
    args = {
        'num_entries': num_entries,
        'link': 'http://www.jgsuicidepool.com/login/' + token,
        'deadline': weeks.deadline(1).strftime('%A, %B %d at %I:%M%p'),
    }
    plain = new_user_template % args
    args['deadline'] = '<strong>%s</strong>' % args['deadline']
    args['link'] = '<a href="%(link)s">Activate Your Account</a>' % args
    html = html_new_user_template % args
    _send_mail([email], '2012 NFL Suicide Pool: Activate Your Account', plain, html)
Ejemplo n.º 3
0
def email_new_entries(email, token, num_entries):
    logging.info('Emailing new user %s', email)
    week = weeks.current()
    args = {
        'num_entries': num_entries,
        'link': 'http://www.jgsuicidepool.com/login/' + token,
        'week': week,
        'deadline': weeks.deadline(week).strftime('%A, %B %d at %I:%M%p'),
    }
    plain = new_entries_template % args
    args['deadline'] = '<strong>%s</strong>' % args['deadline']
    args['link'] = '<a href="%(link)s">Name Your Entries</a>' % args
    html = html_new_entries_template % args
    _send_mail([email], '2012 NFL Suicide Pool: Name New Entries', plain, html)
Ejemplo n.º 4
0
 def post(self, entry_id):
     entry_id = int(entry_id)
     team = int(self.request.POST.get('team'))
     week = weeks.current()
     game = games.game_for_team(week, team)
     current_pick = entries.pick_for_entry(entry_id, week)
     current_game = games.game_for_team(week, current_pick.team)
     current_time = weeks.current_time()
     if current_time < weeks.deadline(week) and \
        current_time < game.tz_deadline() and \
        (current_game is None or current_time < current_game.tz_deadline()):
         entries.select_team(entry_id, weeks.current(), team)
     else:
         logging.warning('Attempt to set pick after deadline, user %s, team %s',
                         self.user.name, teams.shortname(team))
         self.abort(403)
Ejemplo n.º 5
0
 def get(self):
     week = weeks.current()
     user_entries = entries.entries_for_user(self.user)
     user_picks = entries.picks_for_user(self.user, week)
     picks = []
     for pick in user_picks.itervalues():
         entry = user_entries[pick.entry_id]
         if entry.activated:
             picks.append((entry.name, entry.key().id(), pick))
          
     args = {
         'week': week,
         'picks': sorted(picks),
         'current_time': time.mktime(weeks.current_time().timetuple()),
         'deadline': weeks.deadline(week),
         'deadline_passed': not weeks.check_deadline(week),
     }
     logging.debug(args)
     
     view.render(self, 'picks', args, css=True, js=True)
Ejemplo n.º 6
0
    def get(self):
        week = weeks.current()
        current_time = weeks.current_time()
        if current_time > weeks.deadline(week):
            closed = entries.close_picks(week)
            if closed > 0:
                view.clear_cache('/results/data')
            counts = entries.get_team_counts(week)
            logging.info('Saving counts: %s', counts)
            breakdown.save_team_counts(week, counts)
            breakdown.save_status_counts(week, 0, 0, entries.num_violations(week))
            self.redirect('/admin')
            return

        past_deadline = []
        for g in games.open_past_deadline(week, current_time):
            past_deadline.append(g.home)
            past_deadline.append(g.visiting)

        closed = entries.close_picks(week, past_deadline)
        if closed > 0:
            view.clear_cache('/results/data')
        self.redirect('/admin')