예제 #1
0
def setup():
    interests = firebase.get_interests()
    causes = [{
        "name": x,
        "value": base64.b64encode(x.encode("utf8")).decode("utf8"),
        "active": (x in interests),
    } for x in charity_causes.CAUSES]
    return url_tools.render_template("setup.html", causes=causes)
예제 #2
0
def userCharities():

    charityChoice = flask.request.args.get("choose")
    if charityChoice != None:
        user.setCharity(str(charityChoice))
        return flask.redirect(flask.url_for("app.userCharities"))

    customers = accounts.get_customers()
    customers_id = accounts.get_customers_id(customers,
                                             app.config.get("CUSTOMER"))
    client = accounts.make_client(customers_id)

    charityMarkers = []
    charities = []

    if not TESTING:
        try:
            pool = Pool(processes=2)
            charitiesByLocation = find_charity.get_suggestions_by_city(
                client.city)
            charityMarkers = pool.map(charityMarker, charitiesByLocation[:5],
                                      2)
            charityMarkers = [x for x in charityMarkers if x != None]
            charities = recommend.write_final_rec('user1')
        except Exception as e:
            print("SKIPPED")
            import traceback
            traceback.print_exc()
            print(e)
            pass
    try:
        map = Map(
            identifier="view-side",
            lat=38.64181689999999,
            lng=-83.7657646,
            style="height:500px;width:100%;",
            zoom=12,
            # fit_markers_to_bounds=True,
            markers=charityMarkers,
        )
    except:
        map = None

    topCharity = topDB.getTopCharity()

    return url_tools.render_template(
        "usercharities.html",
        map=map,
        charities=charities,
        topCharity=topCharity,
    )
예제 #3
0
def accountoverview():
    BANK.refresh()
    accounts = BANK.ACCOUNTS
    hasCharity = False
    for account in accounts:
        if account.get("nickname") == "Charity Account":
            hasCharity = True
        if account.get("balance") == None:
            account["strBalance"] = "0.00"
            continue 
        account["strBalance"] = "{0:.2f}".format(account["balance"])
    return url_tools.render_template("accountoverview.html", map=map, accounts=accounts, hasCharity=hasCharity)

# for all of a user's charity interests, get a list of charities and display as a list
예제 #4
0
def vote():

    try:
        charities = voting_db.get_charities()
    except Exception as e:
        return "Error retrieving charities: " + str(e)

    for charity in charities:
        charity["description"] = redis.hget("charity:" + charity["name"],
                                            "mission")

    _charities = json.dumps(charities)
    return url_tools.render_template(
        "voting.html",
        charities=charities,
        _charities=_charities,
    )