示例#1
0
def send_stall_approved_email(stall):
    if stall.election.polling_places_loaded is False:
        location_info = stall.location_info
        stall_name = location_info["name"]
    else:
        location_info = model_to_dict(stall.polling_place)
        stall_name = location_info["premises"]

    token = str(getrandbits(128))
    signature = make_confirmation_hash(stall.id, token)

    html = get_mail_template(
        "stall_approved_with_mail_optout", {
            "POLLING_PLACE_NAME":
            location_info["name"],
            "POLLING_PLACE_ADDRESS":
            location_info["address"],
            "STALL_NAME":
            stall.name,
            "STALL_DESCRIPTION":
            stall.description,
            "STALL_OPENING_HOURS":
            stall.opening_hours,
            "STALL_WEBSITE":
            stall.website,
            "DELICIOUSNESS":
            getFoodDescription(stall),
            "STALL_PERMALINK":
            "{site_url}/{election_name}/stalls/{stall_id}".format(
                site_url=get_env("PUBLIC_SITE_URL"),
                stall_id=stall.id,
                election_name=get_url_safe_election_name(stall.election)),
            "STALL_EDIT_URL":
            "{site_url}/edit-stall?stall_id={stall_id}&token={token}&signature={signature}"
            .format(site_url=get_env("PUBLIC_SITE_URL"),
                    stall_id=stall.id,
                    token=token,
                    signature=signature),
            "CONFIRM_OPTOUT_URL":
            "{api_url}/0.1/mail/opt_out/?format=json&stall_id={stall_id}&token={token}&signature={signature}"
            .format(api_url=get_env("PUBLIC_API_BASE_URL"),
                    stall_id=stall.id,
                    token=token,
                    signature=signature),
        })

    return send({
        "to":
        stall.email,
        "subject":
        "Your Democracy Sausage stall for {} has been approved!".format(
            stall_name),
        "html":
        html,
    })
示例#2
0
def send_stall_submitted_email(stall):
    if stall.election.polling_places_loaded is False:
        location_info = stall.location_info
        stall_name = location_info["name"]
    else:
        location_info = model_to_dict(stall.polling_place)
        stall_name = location_info["premises"]

    token = str(getrandbits(128))
    signature = make_confirmation_hash(stall.id, token)

    html = get_mail_template(
        "stall_submitted", {
            "POLLING_PLACE_NAME":
            location_info["name"],
            "POLLING_PLACE_ADDRESS":
            location_info["address"],
            "STALL_NAME":
            stall.name,
            "STALL_DESCRIPTION":
            stall.description,
            "STALL_OPENING_HOURS":
            stall.opening_hours,
            "STALL_WEBSITE":
            stall.website,
            "DELICIOUSNESS":
            getFoodDescription(stall),
            "STALL_EDIT_URL":
            "{site_url}/edit-stall?stall_id={stall_id}&token={token}&signature={signature}"
            .format(site_url=get_env("PUBLIC_SITE_URL"),
                    stall_id=stall.id,
                    token=token,
                    signature=signature),
        })

    return send({
        "to":
        stall.email,
        "subject":
        "Your Democracy Sausage stall for {} has been received!".format(
            stall_name),
        "html":
        html,
    })