Example #1
0
def add_pledge():
    pledge_details = dict()

    if 'value' in request.vars:
        # Convert input pounds to pence for db entry
        request.vars['value'] = custom_functions.calculate_pence(request.vars.value.replace(',', ''))

    for value in request.vars:
        pledge_details[value] = request.vars[value]

    inserted = db.pledges.insert(**pledge_details)

    return inserted
Example #2
0
def update_pledge():
    pledge_id      = request.vars.pledge_id
    pledge_details = dict()
    del request.vars.pledge_id

    if 'value' in request.vars:
        # Needs input as integer pence
        request.vars['value'] = custom_functions.calculate_pence(request.vars.value)

    for value in request.vars:
        pledge_details[value] = request.vars[value]

    updated = db(db.pledges.id == pledge_id).update(**pledge_details)

    return updated
Example #3
0
def update_project():
    if not is_project_owner(auth.user.id, request.vars.project_id):
        # Don't allow update if user isn't the Bootable Manager
        redirect(URL('errors', 'generic.html', vars=dict(error_details = 'no_permission')))

    project_id    = request.vars.project_id
    update_values = dict()
    del request.vars.project_id

    if 'funding_goal' in request.vars:
        # Needs to be input as integer, in pence to db
        # Replace commas if they've been input
        request.vars.funding_goal    = request.vars.funding_goal.replace(',', '')
        request.vars['funding_goal'] = custom_functions.calculate_pence(request.vars.funding_goal)

    for value in request.vars:
        update_values[value] = request.vars[value]

    updated = db(db.projects.id == project_id).update(**update_values)

    return updated