updated code by aakash
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
from flask import Blueprint, render_template, request, jsonify
|
||||
from flask import Blueprint, render_template, request, jsonify,send_file
|
||||
from flask_login import login_required, current_user
|
||||
|
||||
from model.Report import ReportHelper
|
||||
from model.Log import LogHelper
|
||||
|
||||
|
||||
report_bp = Blueprint("report", __name__)
|
||||
|
||||
|
||||
@@ -46,8 +45,10 @@ def contractor_report(contractor_id):
|
||||
|
||||
# ---------------- Contractor Download Report by contractor id ----------------
|
||||
@report_bp.route('/download_report/<int:contractor_id>')
|
||||
@login_required
|
||||
def download_report(contractor_id):
|
||||
output_file, error = ReportHelper.create_contractor_report(contractor_id)
|
||||
|
||||
if error:
|
||||
return error, 404
|
||||
|
||||
return ReportHelper().download_report(contractor_id=contractor_id)
|
||||
|
||||
return send_file(output_file, as_attachment=True)
|
||||
Reference in New Issue
Block a user