file format of client and sub-con excel files and download exce formate
This commit is contained in:
27
app/routes/file_format.py
Normal file
27
app/routes/file_format.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from flask import Blueprint, render_template, send_from_directory, abort, current_app
|
||||
import os
|
||||
|
||||
file_format = Blueprint("file_format", __name__)
|
||||
|
||||
@file_format.route("/file_format")
|
||||
def download_format():
|
||||
return render_template("ex_format.html", title="Download File Formats")
|
||||
|
||||
|
||||
@file_format.route("/file_format/download/<filename>")
|
||||
def download_excel_format(filename):
|
||||
|
||||
download_folder = os.path.join(
|
||||
current_app.root_path, "static", "downloads/format"
|
||||
)
|
||||
|
||||
file_path = os.path.join(download_folder, filename)
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
abort(404)
|
||||
|
||||
return send_from_directory(
|
||||
directory=download_folder,
|
||||
path=filename,
|
||||
as_attachment=True
|
||||
)
|
||||
@@ -13,10 +13,8 @@ def import_file():
|
||||
file = request.files.get("file")
|
||||
subcontractor_id = request.form.get("subcontractor_id")
|
||||
RA_Bill_No = request.form.get("RA_Bill_No")
|
||||
# file_type = request.form.get("file_type")
|
||||
|
||||
|
||||
service = FileService()
|
||||
# success, msg = service.handle_file_upload(file, subcontractor_id, file_type)
|
||||
success, msg = service.handle_file_upload(file, subcontractor_id, RA_Bill_No)
|
||||
|
||||
flash(msg, "success" if success else "danger")
|
||||
@@ -31,8 +29,6 @@ def client_import_file():
|
||||
|
||||
if request.method == "POST":
|
||||
file = request.files.get("file")
|
||||
# subcontractor_id = request.form.get("subcontractor_id")
|
||||
# file_type = request.form.get("file_type")
|
||||
RA_Bill_No = request.form.get("RA_Bill_No")
|
||||
|
||||
service = FileService()
|
||||
|
||||
Reference in New Issue
Block a user