def services_commit_update(service_id): if current_user.employee is not True: return redirect(url_for("my_appointments")) form = ServiceForm(request.form) if not form.validate(): return render_template("services/updateform.html", service=Service.query.get(service_id), form=form) service_exists = Service.query.filter_by(service=form.service.data).first() update_service = Service.query.get(service_id) if service_exists and service_exists is not update_service: form.service.errors.append( "This service name is already in use. Please choose another service name." ) return render_template("services/updateform.html", service=Service.query.get(service_id), form=form) update_service = Service.query.get(service_id) update_service.service = form.service.data update_service.price = form.price.data db.session().commit() return redirect(url_for("services_update"))
def services_update(): form = ServiceForm(obj=Service.query.first()) if current_user.employee is not True: return redirect(url_for("my_appointments")) return render_template("services/update.html", services=Service.query.all(), form=form)
def services_update_by_id(service_id): if current_user.employee is not True: return redirect(url_for("my_appointments")) update_service = Service.query.get(service_id) form = ServiceForm(obj=update_service) if not form.validate(): return render_template("services/update.html", services=Service.query.all(), form=form) return render_template("services/updateform.html", service=Service.query.get(service_id), form=form)
def services_updates(service_id): form = ServiceForm(request.form) if not form.validate(): return render_template("services/update.html", services=Service.query.all(), form=form) t = Service.query.get(service_id) t.service = form.service.data t.price = form.price.data db.session().commit() return redirect(url_for("services_update"))
def services_create(): form = ServiceForm(request.form) if not form.validate(): return render_template("services/new.html", form=form) serviceExists = Service.query.filter_by(service=form.service.data).first() if serviceExists: form.service.errors.append( "This service name is already in use. Please choose another service name." ) return render_template("services/new.html", form=form) t = Service(form.service.data, form.price.data) db.session().add(t) db.session().commit() return redirect(url_for("services_list"))
def services_create(): if current_user.employee is not True: return redirect(url_for("my_appointments")) form = ServiceForm(request.form) if not form.validate(): return render_template("services/new.html", form=form) service_exists = Service.query.filter_by(service=form.service.data).first() if service_exists: form.service.errors.append( "This service name is already in use. Please choose another service name." ) return render_template("services/new.html", form=form) new_service = Service(form.service.data, form.price.data) db.session().add(new_service) db.session().commit() return redirect(url_for("services_list"))
def services_form(): if current_user.employee is not True: return redirect(url_for("my_appointments")) return render_template("services/new.html", form=ServiceForm())
def services_update(): return render_template("services/update.html", services=Service.query.all(), form=ServiceForm())
def services_form(): return render_template("services/new.html", form=ServiceForm())