def edit_record(id): e_form = EditForm(request.form) add_form = AddRecordForm(request.form) database = methods.get_db() if request.form['btn'] == 'edit': id = id name = e_form.name.data price = e_form.price.data dimension = e_form.dimension.data methods.edit(id, name, price, dimension) return redirect(url_for('show_database')) return redirect(url_for('show_database'))
def edit_name(url): prev_name = url e_form = EditForm(request.form) lib = methods.get_all_authors_and_books() sorted_lib = sorted(lib) new_lib = [] for key in sorted_lib: new_lib.append([key, lib[key]]) if request.method == 'POST' and e_form.validate(): new_name = (e_form.new_name.data).strip() flag = methods.edit(prev_name, new_name) if flag == False: edit = True flash('Such name already exist') return render_template('library.html', e_form=e_form, new_lib=new_lib, edit=edit) return redirect(url_for('show_library')) else: flash('Insert name') edit = True return render_template('library.html', e_form=e_form, new_lib=new_lib, edit=edit)
def edit_name(url): prev_name = url e_form = EditForm(request.form) lib = methods.get_all_authors_and_books() sorted_lib = sorted(lib) new_lib = [] for key in sorted_lib: new_lib.append([key, lib[key]]) if request.method == "POST" and e_form.validate(): new_name = (e_form.new_name.data).strip() flag = methods.edit(prev_name, new_name) if flag == False: edit = True flash("Such name already exist") return render_template("library.html", e_form=e_form, new_lib=new_lib, edit=edit) return redirect(url_for("show_library")) else: flash("Insert name") edit = True return render_template("library.html", e_form=e_form, new_lib=new_lib, edit=edit)