Exemplo n.º 1
0
def detail(cid):
    def validate_cost(form):
        form.params.campaign = campaign.id
        if form.params.amount > (campaign.pledged() - campaign.spended()):
            form.errors.amount = \
                "The amount inserted is bigger than the amount pledged."

    campaign = Campaign.get(cid)
    cost_form = Cost.form(onvalidation=validate_cost)
    if cost_form.accepted:
        redirect(url('campaigns.detail', cid))
    return dict(campaign=campaign, cost_form=cost_form, graph=graph_data)
Exemplo n.º 2
0
def add(campaign):
    def set_form(form):
        form.params.user = auth.user.id
        form.params.campaign = record.id

    message = None
    record = Campaign.get(campaign)
    if not record:
        message = "Bad campaign id"
    form = Donation.form(onvalidation=set_form)
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form, campaign=record)
Exemplo n.º 3
0
def add(campaign):
    def validate(form):
        if form.params.amount > record.pledged():
            form.errors.amount = ""

    message = None
    record = Campaign.get(id=campaign, user=auth.user.id)
    if not record:
        message = "Bad campaign id"
    form = Cost.form(onvalidation=validate)
    form.params.campaign = record.id
    if form.accepted:
        redirect(url('campaigns.detail', record.id))
    return dict(msg=message, form=form)