Refactor transport calculation into shared domain
This commit is contained in:
@@ -33,6 +33,7 @@ from pdf_report import (
|
||||
safe_report_filename,
|
||||
)
|
||||
from roll_calculation import calculate_roll, modify_calculation
|
||||
from transport_calculation import analyze_transport, transport_presets
|
||||
|
||||
app = Flask(__name__)
|
||||
auth = HTTPBasicAuth()
|
||||
@@ -155,7 +156,11 @@ def log_access(username, endpoint, method, status=200):
|
||||
def index():
|
||||
"""Main calculator page - requires authentication"""
|
||||
log_access(auth.current_user(), "/", "GET")
|
||||
return render_template("roll_calculator.html", core_presets=CORE_PRESETS)
|
||||
return render_template(
|
||||
"roll_calculator.html",
|
||||
core_presets=CORE_PRESETS,
|
||||
transport_presets=transport_presets(),
|
||||
)
|
||||
|
||||
|
||||
@app.route("/static/<path:filename>", methods=["GET"])
|
||||
@@ -212,6 +217,15 @@ def modify_roll_calculation():
|
||||
return jsonify(result), 200
|
||||
|
||||
|
||||
@app.route("/api/calculations/transport", methods=["POST"])
|
||||
@auth.login_required
|
||||
def create_transport_calculation():
|
||||
"""Execute the shared transport-capacity calculation."""
|
||||
result = analyze_transport(request.get_json(silent=True))
|
||||
log_access(auth.current_user(), "/api/calculations/transport", "POST")
|
||||
return jsonify(result), 200
|
||||
|
||||
|
||||
def _create_pdf(calculation_request):
|
||||
result = calculate_roll(calculation_request, build_info=BUILD_INFO)
|
||||
report = report_from_calculation_result(result)
|
||||
|
||||
Reference in New Issue
Block a user