Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def delete_bill(bill_id):
# fixme: everyone is able to delete a bill
bill = Bill.query.get(g.project, bill_id)
if not bill:
return redirect(url_for(".list_bills"))
db.session.delete(bill)
db.session.commit()
flash(_("The bill has been deleted"))
return redirect(url_for(".list_bills"))
def put(self, project, bill_id):
form = get_billform_for(project, True, meta={"csrf": False})
if form.validate():
bill = Bill.query.get(project, bill_id)
form.save(bill, project)
db.session.commit()
return bill.id, 200
return form.errors, 400
def edit_bill(bill_id):
# FIXME: Test this bill belongs to this project !
bill = Bill.query.get(g.project, bill_id)
if not bill:
raise NotFound()
form = get_billform_for(g.project, set_default=False)
if request.method == "POST" and form.validate():
form.save(bill, g.project)
db.session.commit()
flash(_("The bill has been modified"))
return redirect(url_for(".list_bills"))
if not form.errors:
form.fill(bill)
return render_template("add_bill.html", form=form, edit=True)
def get(self, project, bill_id):
bill = Bill.query.get(project, bill_id)
if not bill:
return "Not Found", 404
return bill, 200