示例#1
0
 def test_update_hole(add_wall):
     wall = Wall.query.first()
     Wall.add_hole(wall.id, width=1.2, height=2.0, amount=2)
     assert wall.holes[0].width == 1.2
     assert wall.holes[0].height == 2.0
     assert wall.holes[0].amount == 2
     assert wall.wall_area_to_survey == 27.75
     hole = wall.holes[0]
     Wall.edit_hole(hole.id, width=1.5, height=2.5, amount=1)
     assert wall.holes[0].width == 1.5
     assert wall.holes[0].height == 2.5
     assert wall.holes[0].amount == 1
     assert wall.wall_area_to_survey == 28.8
示例#2
0
def edit_hole() -> str:
    wall_id = request.args.get("wall_id")
    hole_id = request.args.get("hole_id")
    hole = Hole.query.filter_by(id=hole_id).first()
    form = HoleForm()
    if form.validate_on_submit():
        Wall.edit_hole(hole_id, **form.data)
        flash("You modified the hole.")
        return redirect(url_for("masonry_works.holes", wall_id=wall_id))
    elif request.method == "GET":
        form.width.data = hole.width
        form.height.data = hole.height
        form.amount.data = hole.amount
    return render_template(
        "production/masonry_works/forms/hole_form.html",
        title="Edit Hole",
        form=form,
    )