def test_update_processing_when_done_above_1(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.6) processing = wall.processing[0] Wall.edit_processing(processing.id, done=1.35) assert wall.processing[0].done == 1.0 assert wall.left_to_sale == 0.0
def test_update_processing_when_overrun(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.6) Wall.add_processing(wall.id, year=2020, month="December", done=0.3) assert wall.processing.filter_by(id=1).first().done == 0.6 assert wall.processing.filter_by(id=2).first().done == 0.3 assert wall.left_to_sale == 0.1 Wall.edit_processing(2, done=0.5) assert wall.processing.filter_by(id=1).first().done == 0.6 assert wall.processing.filter_by(id=2).first().done == 0.4 assert wall.left_to_sale == 0.0
def test_update_processing(add_wall): wall = Wall.query.first() Wall.add_processing(wall.id, year=2020, month="December", done=0.3) assert wall.processing[0].year == 2020 assert wall.processing[0].month == "December" assert wall.processing[0].done == 0.3 assert wall.left_to_sale == 0.7 processing = wall.processing[0] Wall.edit_processing(processing.id, year=2021, month="January", done=0.6) assert wall.processing[0].year == 2021 assert wall.processing[0].month == "January" assert wall.processing[0].done == 0.6 assert wall.left_to_sale == 0.4
def edit_processing() -> str: wall_id = request.args.get("wall_id") proc_id = request.args.get("proc_id") processing = Processing.query.filter_by(id=proc_id).first() form = ProcessingForm() if form.validate_on_submit(): Wall.edit_processing(proc_id, **form.data) flash("You modified the processing.") return redirect(url_for("masonry_works.processing", wall_id=wall_id)) elif request.method == "GET": form.year.data = processing.year form.month.data = processing.month form.done.data = processing.done return render_template( "production/masonry_works/forms/processing_form.html", title="Edit Processing", form=form, )