Пример #1
0
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"))
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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"))
Пример #5
0
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"))
Пример #6
0
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"))
Пример #7
0
def services_form():

    if current_user.employee is not True:
        return redirect(url_for("my_appointments"))

    return render_template("services/new.html", form=ServiceForm())
Пример #8
0
def services_update():
    return render_template("services/update.html",
                           services=Service.query.all(),
                           form=ServiceForm())
Пример #9
0
def services_form():
    return render_template("services/new.html", form=ServiceForm())