testing code
This commit is contained in:
@@ -4,7 +4,7 @@ from flask_login import login_required, current_user
|
||||
from model.Report import ReportHelper
|
||||
from model.Log import LogHelper
|
||||
import os
|
||||
|
||||
from model.UnifiedReportService import UnifiedReportService
|
||||
# DOWNLOAD_FOLDER = "static/download"
|
||||
report_bp = Blueprint("report", __name__)
|
||||
|
||||
@@ -33,11 +33,13 @@ def search_contractor():
|
||||
return jsonify(data)
|
||||
|
||||
# ---------------- Contractor Report by contractor id ----------------
|
||||
|
||||
@report_bp.route('/contractor_report/<int:contractor_id>')
|
||||
@login_required
|
||||
def contractor_report(contractor_id):
|
||||
|
||||
data = ReportHelper.get_contractor_report(contractor_id)
|
||||
# data = UnifiedReportService.get_report(contractor_id)
|
||||
data = UnifiedReportService.get_report(contractor_id=contractor_id)
|
||||
|
||||
return render_template(
|
||||
'subcontractor_report.html',
|
||||
@@ -49,11 +51,10 @@ def contractor_report(contractor_id):
|
||||
|
||||
@report_bp.route('/download_report/<int:contractor_id>')
|
||||
def download_report(contractor_id):
|
||||
output_file, error = ReportHelper.create_contractor_report(contractor_id)
|
||||
|
||||
if error:
|
||||
return error, 404
|
||||
|
||||
|
||||
# Send the file to the user
|
||||
return send_file(output_file, as_attachment=True)
|
||||
file_path = UnifiedReportService.download(contractor_id=contractor_id)
|
||||
|
||||
if not file_path:
|
||||
return "Report not found", 404
|
||||
|
||||
return send_file(file_path, as_attachment=True)
|
||||
Reference in New Issue
Block a user