def clerk_details(county): g.locale = guess_locale() clerk = Clerk.find_by_county(county) if clerk: return render_template('county.html', clerk=clerk) else: return abort(404)
def clerk_details(county): g.locale = guess_locale() clerk = Clerk.find_by_county(county) if clerk: evl = EarlyVotingLocations(county) d = Dropboxes(county) return render_template('county.html', clerk=clerk, early_voting_locations=evl.locations, dropboxes=d.dropboxes) else: return abort(404)
def stats(): g.locale = guess_locale() ninety_days = datetime.timedelta(days=90) today = datetime.date.today() s = RegistrantStats() vr_stats = s.vr_through_today(today - ninety_days) ab_stats = s.ab_through_today(today - ninety_days) stats = {'vr': [], 'ab': []} for r in vr_stats: stats['vr'].append(r.values()) for r in ab_stats: stats['ab'].append(r.values()) return render_template('stats.html', stats=stats)
def decorated(*args, **kwargs): def request_is_root(): if request.path == '/' or request.url_rule.rule == '/<lang_code>/': return True return False http_session.permanent = True # enforce expiration TTL session_id = http_session.get('session_id') g.registrant = None g.locale = guess_locale( ) # so we have it available for all template rendering # if we don't yet have a session_id, assign one. if not session_id: current_app.logger.debug("No session_id found") uuid_str = str(uuid4()) http_session['session_id'] = uuid_str current_app.logger.debug("created session uuid %s" % (uuid_str)) # edge case: a request "in the middle" of the flow. if not request_is_root(): current_app.logger.error("redirect to flow start") if request.method == 'POST': flash(lazy_gettext('session_interrupted_error'), 'warning') return redirect(url_for('main.index')) else: current_app.logger.debug("found session uuid %s" % (session_id)) g.registrant = Registrant.find_by_session(session_id) # Security belt-and-suspenders. Disallow session continuation if the Registrant # has not been updated within the SESSION_TTL window. r = g.registrant if r and not r.updated_since( current_app.config['SESSION_TTL']) and not r.is_demo(): current_app.logger.error( "Discontinuing old session for existing Registrant.") http_session['session_id'] = None if request.method == 'POST': flash(lazy_gettext('session_interrupted_error'), 'warning') return redirect(url_for('main.index')) # edge case: clear stale cookie and start over. # adding in fix for index if session_id and not g.registrant and not request_is_root(): current_app.logger.debug('reset session') http_session.pop('session_id') return redirect(url_for('main.index')) return f(*args, **kwargs)
def page_not_found(_e): g.locale = guess_locale() return render_template('404.html'), 404
def page_exception(_e): g.locale = guess_locale() return render_template('500.html'), 500
def get_locale(): from app.main.helpers import guess_locale if g.locale: return g.locale return guess_locale()
def about_us(): g.locale = guess_locale() return render_template('about.html')
def privacy(): g.locale = guess_locale() return render_template('privacy-policy.html')
def forget_session(): g.locale = guess_locale() http_session['session_id'] = None # flash(lazy_gettext('session_forgotten'), 'info') # TODO wordsmith this return redirect(url_for('main.index'))
def terms(): g.locale = guess_locale() return render_template('terms.html')