def put(self, project): form = EditProjectForm(meta={'csrf': False}) if form.validate(): form.update(project) db.session.commit() return "UPDATED" return form.errors, 400
def put(self, project): form = EditProjectForm(meta={"csrf": False}) if form.validate() and current_app.config.get("ALLOW_PUBLIC_PROJECT_CREATION"): form.update(project) db.session.commit() return "UPDATED" return form.errors, 400
def edit_project(): edit_form = EditProjectForm() if request.method == "POST": if edit_form.validate(): project = edit_form.update(g.project) db.session.add(project) db.session.commit() return redirect(url_for(".list_bills")) else: edit_form.name.data = g.project.name edit_form.contact_email.data = g.project.contact_email return render_template("edit_project.html", edit_form=edit_form, current_view="edit_project")
def edit_project(): edit_form = EditProjectForm() export_form = ExportForm() if request.method == "POST": if edit_form.validate(): project = edit_form.update(g.project) db.session.commit() session[project.id] = project.password return redirect(url_for(".list_bills")) if export_form.validate(): export_format = export_form.export_format.data export_type = export_form.export_type.data if export_type == 'transactions': export = g.project.get_transactions_to_settle_bill( pretty_output=True) if export_type == "bills": export = g.project.get_pretty_bills( export_format=export_format) if export_format == "json": file2export = list_of_dicts2json(export) if export_format == "csv": file2export = list_of_dicts2csv(export) return send_file(file2export, attachment_filename="%s-%s.%s" % (g.project.id, export_type, export_format), as_attachment=True ) else: edit_form.name.data = g.project.name edit_form.password.data = g.project.password edit_form.contact_email.data = g.project.contact_email return render_template("edit_project.html", edit_form=edit_form, export_form=export_form)
def edit_project(): edit_form = EditProjectForm() export_form = ExportForm() if request.method == "POST": if edit_form.validate(): project = edit_form.update(g.project) db.session.add(project) db.session.commit() return redirect(url_for(".list_bills")) if export_form.validate(): export_format = export_form.export_format.data export_type = export_form.export_type.data if export_type == 'transactions': export = g.project.get_transactions_to_settle_bill( pretty_output=True) if export_type == "bills": export = g.project.get_pretty_bills( export_format=export_format) if export_format == "json": file2export = list_of_dicts2json(export) if export_format == "csv": file2export = list_of_dicts2csv(export) return send_file(file2export, attachment_filename="%s-%s.%s" % (g.project.id, export_type, export_format), as_attachment=True ) else: edit_form.name.data = g.project.name edit_form.password.data = g.project.password edit_form.contact_email.data = g.project.contact_email return render_template("edit_project.html", edit_form=edit_form, export_form=export_form)