Exemple #1
0
def index():
    """
    Example view demonstrating rendering a simple HTML page.
    """
    from models import Race

    context = make_context()

    with open('data/featured.json') as f:
        context['featured'] = json.load(f)

    context['races'] = Race.select()

    """
    Balance of Power data
    """
    races = Race.select().where(Race.office_name == 'U.S. Senate').order_by(Race.state_postal)

    context['not_called'] = app_utils.calculate_seats_left(races)

    if app_config.DEPLOY_PROMO:
        template_file = 'promo.html'
    else:
        template_file = 'index.html'

    return render_template(template_file, **context), 200,
Exemple #2
0
def index():
    """
    Example view demonstrating rendering a simple HTML page.
    """
    from models import Race

    context = make_context()

    with open('data/featured.json') as f:
        context['featured'] = json.load(f)

    context['races'] = Race.select()
    """
    Balance of Power data
    """
    races = Race.select().where(Race.office_name == 'U.S. Senate').order_by(
        Race.state_postal)

    context['not_called'] = app_utils.calculate_seats_left(races)

    if app_config.DEPLOY_PROMO:
        template_file = 'promo.html'
    else:
        template_file = 'index.html'

    return render_template(template_file, **context), 200,
Exemple #3
0
def _bop():
    """
    Serve the most recent bop data
    """
    from models import Race

    context = make_context()

    races = Race.select().where(Race.office_name == 'U.S. Senate').order_by(Race.state_postal)

    context['bop'] = app_utils.calculate_bop(races, app_utils.SENATE_INITIAL_BOP)
    context['not_called'] = app_utils.calculate_seats_left(races)

    return render_template('bop.html', **context)
Exemple #4
0
def _bop():
    """
    Serve the most recent bop data
    """
    from models import Race

    context = make_context()

    races = Race.select().where(Race.office_name == 'U.S. Senate').order_by(
        Race.state_postal)

    context['bop'] = app_utils.calculate_bop(races,
                                             app_utils.SENATE_INITIAL_BOP)
    context['not_called'] = app_utils.calculate_seats_left(races)

    return render_template('bop.html', **context)