modification of datatime() new added entry created
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -39,7 +39,7 @@ class ManholeDomesticChamber(db.Model):
|
||||
|
||||
Domestic_Chambers = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HanholeDomesticChamberConstruction {self.Location}>"
|
||||
|
||||
@@ -57,7 +57,7 @@ class ManholeExcavation(db.Model):
|
||||
Remarks = db.Column(db.String(500))
|
||||
Total = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HanholeExcavation {self.Location}>"
|
||||
|
||||
@@ -35,7 +35,7 @@ class ManholeDomesticChamberClient(db.Model):
|
||||
|
||||
Domestic_Chambers = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HanholeDomesticChamberConstruction {self.Location}>"
|
||||
|
||||
@@ -73,7 +73,7 @@ class ManholeExcavationClient(db.Model):
|
||||
Remarks = db.Column(db.String(500))
|
||||
Total = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HanholeExcavation {self.Location}>"
|
||||
|
||||
@@ -14,7 +14,7 @@ class Subcontractor(db.Model):
|
||||
email_id = db.Column(db.String(150))
|
||||
contact_person = db.Column(db.String(150))
|
||||
status = db.Column(db.String(20), default="Active")
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Subcontractor {self.subcontractor_name}>"
|
||||
|
||||
@@ -78,7 +78,7 @@ class TrenchExcavationClient(db.Model):
|
||||
Remarks = db.Column(db.String(500))
|
||||
Total = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<TrenchExcavation {self.Location}>"
|
||||
|
||||
@@ -68,7 +68,7 @@ class TrenchExcavation(db.Model):
|
||||
Remarks = db.Column(db.String(500))
|
||||
Total = db.Column(db.Float)
|
||||
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
created_at = db.Column(db.DateTime, default=datetime.today)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<TrenchExcavation {self.Location}>"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -4,6 +4,7 @@ from app.models.subcontractor_model import Subcontractor
|
||||
|
||||
file_import_bp = Blueprint("file_import", __name__, url_prefix="/file")
|
||||
|
||||
# this route import Subcontractor files
|
||||
@file_import_bp.route("/import", methods=["GET", "POST"])
|
||||
def import_file():
|
||||
subcontractors = Subcontractor.query.all()
|
||||
@@ -11,16 +12,18 @@ def 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")
|
||||
# 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, file_type)
|
||||
success, msg = service.handle_file_upload(file, subcontractor_id)
|
||||
|
||||
flash(msg, "success" if success else "danger")
|
||||
|
||||
return render_template("file_import.html", title="Sub-cont. File Import", subcontractors=subcontractors)
|
||||
|
||||
|
||||
# this route import client files
|
||||
@file_import_bp.route("/import_client", methods=["GET", "POST"])
|
||||
def client_import_file():
|
||||
subcontractors = Subcontractor.query.all()
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
from flask import Blueprint, render_template, request, send_file, flash
|
||||
from app import db
|
||||
import pandas as pd
|
||||
import io
|
||||
|
||||
from app.models.subcontractor_model import Subcontractor
|
||||
|
||||
from app.models.trench_excavation_model import TrenchExcavation
|
||||
from app.models.tr_ex_client_model import TrenchExcavationClient
|
||||
from app.models.manhole_excavation_model import ManholeExcavation
|
||||
@@ -8,11 +12,6 @@ from app.models.mh_ex_client_model import ManholeExcavationClient
|
||||
from app.models.manhole_domestic_chamber_model import ManholeDomesticChamber
|
||||
from app.models.mh_dc_client_model import ManholeDomesticChamberClient
|
||||
|
||||
from app import db
|
||||
|
||||
import pandas as pd
|
||||
import io
|
||||
|
||||
|
||||
generate_report_bp = Blueprint("generate_report", __name__, url_prefix="/report")
|
||||
|
||||
|
||||
Binary file not shown.
@@ -20,12 +20,13 @@ class FileService:
|
||||
def allowed_file(self, filename):
|
||||
return "." in filename and filename.rsplit(".", 1)[1].lower() in Config.ALLOWED_EXTENSIONS
|
||||
|
||||
def handle_file_upload(self, file, subcontractor_id, file_type):
|
||||
# def handle_file_upload(self, file, subcontractor_id, file_type):
|
||||
def handle_file_upload(self, file, subcontractor_id):
|
||||
|
||||
if not subcontractor_id:
|
||||
return False, "Please select subcontractor."
|
||||
if not file_type:
|
||||
return False, "Please select file type."
|
||||
# if not file_type:
|
||||
# return False, "Please select file type."
|
||||
if not file or file.filename == "":
|
||||
return False, "No file selected."
|
||||
if not self.allowed_file(file.filename):
|
||||
@@ -40,36 +41,52 @@ class FileService:
|
||||
filepath = os.path.join(folder, filename)
|
||||
file.save(filepath)
|
||||
|
||||
print("name::::",filename)
|
||||
|
||||
try:
|
||||
df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
|
||||
|
||||
# df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
|
||||
df = pd.read_excel(filepath, sheet_name ="Tr.Ex.", header=0)
|
||||
df1 = pd.read_excel(filepath, sheet_name="MH Ex.", header=0)
|
||||
df2 = pd.read_excel(filepath, sheet_name="MH & DC", header=0)
|
||||
|
||||
print("\n=== Uploaded File Preview ===")
|
||||
print(df.head())
|
||||
print(" file name h:",df)
|
||||
print("=============================\n")
|
||||
print(" file name h1:",df1)
|
||||
# print(df.head())
|
||||
print("=============================\n")
|
||||
print(" file name h1:",df2)
|
||||
|
||||
self.process_trench_excavation(df,subcontractor_id)
|
||||
self.process_manhole_excavation(df1,subcontractor_id)
|
||||
self.process_manhole_domestic_chamber(df2, subcontractor_id)
|
||||
|
||||
# Trench Excavation save (subcontractor)
|
||||
if file_type == "trench_excavation":
|
||||
return self.process_trench_excavation(df, subcontractor_id)
|
||||
|
||||
# Manhole Excavation save (subcontractor)
|
||||
if file_type == "manhole_excavation":
|
||||
return self.process_manhole_excavation(df, subcontractor_id)
|
||||
|
||||
# Manhole and Domestic Chamber Construction save (subcontractor)
|
||||
if file_type == "manhole_domestic_chamber":
|
||||
return self.process_manhole_domestic_chamber(df, subcontractor_id)
|
||||
|
||||
# Tr Ex save (client)
|
||||
if file_type =="tr_ex_client":
|
||||
return self.client_trench_excavation(df, subcontractor_id)
|
||||
# df = pd.read_csv(filepath) if filename.endswith(".csv") else pd.read_excel(filepath)
|
||||
|
||||
# Mh Ex save (client)
|
||||
if file_type =="mh_ex_client":
|
||||
return self.client_manhole_excavation(df, subcontractor_id)
|
||||
# # Trench Excavation save (subcontractor)
|
||||
# if file_type == "trench_excavation":
|
||||
# return self.process_trench_excavation(df, subcontractor_id)
|
||||
|
||||
# # Manhole Excavation save (subcontractor)
|
||||
# if file_type == "manhole_excavation":
|
||||
# return self.process_manhole_excavation(df, subcontractor_id)
|
||||
|
||||
# # Manhole and Domestic Chamber Construction save (subcontractor)
|
||||
# if file_type == "manhole_domestic_chamber":
|
||||
# return self.process_manhole_domestic_chamber(df, subcontractor_id)
|
||||
|
||||
# # Tr Ex save (client)
|
||||
# if file_type =="tr_ex_client":
|
||||
# return self.client_trench_excavation(df, subcontractor_id)
|
||||
|
||||
# Mh and Dc save (client)
|
||||
if file_type == "mh_dc_client":
|
||||
return self.client_manhole_domestic_chamber(df, subcontractor_id)
|
||||
# # Mh Ex save (client)
|
||||
# if file_type =="mh_ex_client":
|
||||
# return self.client_manhole_excavation(df, subcontractor_id)
|
||||
|
||||
# # Mh and Dc save (client)
|
||||
# if file_type == "mh_dc_client":
|
||||
# return self.client_manhole_domestic_chamber(df, subcontractor_id)
|
||||
|
||||
return True, "File uploaded successfully."
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</select>
|
||||
|
||||
<!-- 2. FILE TYPE (MODEL NAME) -->
|
||||
<label class="form-label">Select File Type</label>
|
||||
<!-- <label class="form-label">Select File Type</label>
|
||||
<select name="file_type" id="file_type" class="form-select mb-3" required>
|
||||
<option value="">-- Select File Type --</option>
|
||||
<option value="">Subcontractor Sheet</option>
|
||||
@@ -26,7 +26,7 @@
|
||||
<option value="manhole_excavation">Manhole Excavation (Mh.Ex)</option>
|
||||
<option value="manhole_domestic_chamber">Manhole & Domestic Chambers Construction (MH & DC)</option>
|
||||
<option value="">Laying Sheet</option>
|
||||
</select>
|
||||
</select> -->
|
||||
|
||||
<!-- 3. FILE UPLOAD -->
|
||||
<label class="form-label">Choose File</label>
|
||||
@@ -36,4 +36,4 @@
|
||||
</form>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user