Beispiel #1
0
def homepage(request):
    return piglet.render(
        "default/index.html",
        {
            "days_left":
            (options.CONVENTION_DATE - request.now.date()).days - 1
        },
    ).add_headers(cache_control="must-revalidate, max-age=3", vary="cookie")
Beispiel #2
0
def confirm_email(request, token):
    conn = request.getconn()
    with queries.transaction(conn):
        supporter_id = supporters.confirm_email(conn, token)
        if supporter_id is None:
            return piglet.render("default/invalid-confirmation-token.html", {})
    request.remember_user_id(supporter_id)
    return Response.redirect(support_step, _query={"step": 2})
Beispiel #3
0
def supporter_list(request):
    limit = request.getint("limit", 500)
    offset = request.getint("offset", 0)
    ss, has_more_results = supporters.get_supporter_list(
        request.getconn(), limit, offset)
    return piglet.render(
        "admin/supporters-list.html",
        {
            "count": supporters.supporter_count(request.getconn()),
            "supporters": ss,
            "limit": limit,
            "offset": offset,
            "has_more_results": has_more_results,
        },
    )
Beispiel #4
0
def support_step(request):
    step = request.getint("step", None)
    if step is None or not request.is_authenticated():
        return Response.redirect(support_us)

    conn = request.getconn()
    supporter = supporters.get_supporter_by_id(conn, request.get_user_id())
    if supporter is None:
        return Response.redirect(support_us)

    occupation_options = supporters.occupation_options(conn)
    year_of_birth_range_options = supporters.year_of_birth_range_options(
        supporter)
    template = f"default/support-us-step-{step}.html"
    return piglet.render(
        template,
        {
            "step": step,
            "is_new": request.get("is_new"),
            "supporter": supporter,
            "occupation_options": occupation_options,
            "year_of_birth_range_options": year_of_birth_range_options,
        },
    )
Beispiel #5
0
def existing_support(request):
    return piglet.render("default/existing-support.html", {})
Beispiel #6
0
def email_needs_confirmation(request, email):
    return piglet.render("default/email-needs-confirmation.html",
                         {"email": email})
Beispiel #7
0
def support_us(request):
    return piglet.render("default/support-us.html", {})
Beispiel #8
0
def soutiens(request):
    return piglet.render("default/soutiens.html", {}).add_headers(
        cache_control="must-revalidate, max-age=3", vary="cookie")
Beispiel #9
0
def templated_page(request, template):
    return piglet.render(template, {})