modification ui changes base pages,login, manus and from chnages and adding filds. V2 commit
This commit is contained in:
110
main.py
110
main.py
@@ -6,6 +6,7 @@ import io
|
||||
import mysql.connector
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
|
||||
from AppCode.Config import DBConfig
|
||||
from AppCode.FileHandler import FileHandler
|
||||
from AppCode.DocumentHandler import DocumentHandler
|
||||
@@ -14,20 +15,26 @@ from AppCode.AOHandler import AOHandler
|
||||
from AppCode.CITHandler import CITHandler
|
||||
from AppCode.ITATHandler import ITATHandler
|
||||
from AppCode.YearGet import YearGet
|
||||
from AppCode.LoginAuth import LoginAuth
|
||||
|
||||
|
||||
|
||||
# Server
|
||||
app = Flask(__name__)
|
||||
app.secret_key="secret1234"
|
||||
app.config['UPLOAD_FOLDER'] = FileHandler.UPLOAD_FOLDER
|
||||
auth = LoginAuth()
|
||||
app.register_blueprint(auth.bp)
|
||||
|
||||
|
||||
# welcome page
|
||||
@app.route('/')
|
||||
@auth.login_required
|
||||
def welcome():
|
||||
return render_template('welcome.html')
|
||||
return render_template('index.html')
|
||||
|
||||
# Dashboard page
|
||||
@app.route('/dashboard')
|
||||
@auth.login_required
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@@ -35,7 +42,7 @@ def index():
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in FileHandler.ALLOWED_EXTENSIONS
|
||||
|
||||
|
||||
|
||||
# Upload File route
|
||||
@app.route('/upload', methods=['GET', 'POST'])
|
||||
def upload_file():
|
||||
@@ -97,7 +104,6 @@ def display_itr():
|
||||
@app.route('/itr/add', methods=['GET', 'POST'])
|
||||
def add_itr():
|
||||
if request.method == 'POST':
|
||||
|
||||
itr = ITRHandler()
|
||||
itr.add_itr(request.form)
|
||||
itr.close()
|
||||
@@ -121,8 +127,6 @@ def update_itr(id):
|
||||
|
||||
if request.method == 'POST':
|
||||
data = {k: request.form.get(k, 0) for k in request.form}
|
||||
print("itr data-->",data)
|
||||
|
||||
itr.update(id, data=data)
|
||||
itr.close()
|
||||
return redirect(url_for('display_itr'))
|
||||
@@ -132,23 +136,6 @@ def update_itr(id):
|
||||
return render_template('update_itr.html', record=record)
|
||||
|
||||
|
||||
# new new -- check year in table existe or not by using ajax calling.
|
||||
@app.route('/check_year', methods=['POST'])
|
||||
def check_year():
|
||||
table_name = request.json.get("table")
|
||||
year = request.json.get("year")
|
||||
|
||||
conn = DBConfig.get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = f"SELECT COUNT(*) FROM {table_name} WHERE year = %s"
|
||||
cursor.execute(query, (year,))
|
||||
result = cursor.fetchone()[0]
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
return {"exists": result > 0}
|
||||
|
||||
|
||||
## ===============================================
|
||||
@@ -210,7 +197,7 @@ def delete_ao(id):
|
||||
## CIT (Commissioner of Income Tax) Routes
|
||||
## =======================================================
|
||||
|
||||
# DISPLAY all CIT records
|
||||
# 1 DISPLAY all CIT records
|
||||
@app.route('/cit_records')
|
||||
def display_cit():
|
||||
cit = CITHandler()
|
||||
@@ -218,6 +205,7 @@ def display_cit():
|
||||
cit.close()
|
||||
return render_template('display_cit.html', cit_records=cit_records)
|
||||
|
||||
# 2 new CIT records add
|
||||
@app.route('/cit/add', methods=['GET', 'POST'])
|
||||
def add_cit():
|
||||
if request.method == 'POST':
|
||||
@@ -229,7 +217,7 @@ def add_cit():
|
||||
|
||||
return render_template('add_cit.html')
|
||||
|
||||
|
||||
# 3 delete CIT records by id
|
||||
@app.route('/cit/delete/<int:id>', methods=['POST'])
|
||||
def delete_cit(id):
|
||||
cit = CITHandler()
|
||||
@@ -238,7 +226,7 @@ def delete_cit(id):
|
||||
flash("CIT record deleted successfully!", "success")
|
||||
return redirect(url_for('display_cit'))
|
||||
|
||||
|
||||
# 4 update CIT records by id
|
||||
@app.route('/cit/update/<int:id>', methods=['GET', 'POST'])
|
||||
def update_cit(id):
|
||||
cit = CITHandler()
|
||||
@@ -262,7 +250,7 @@ def update_cit(id):
|
||||
## ITAT (Income Tax Appellate Tribunal) Routes
|
||||
## =======================================================
|
||||
|
||||
# DISPLAY all ITAT records
|
||||
# 1.DISPLAY all ITAT records
|
||||
@app.route('/itat_records')
|
||||
def display_itat():
|
||||
itat = ITATHandler()
|
||||
@@ -270,16 +258,22 @@ def display_itat():
|
||||
itat.close()
|
||||
return render_template('display_itat.html', records=records)
|
||||
|
||||
|
||||
@app.route('/itat/delete/<int:id>', methods=['POST'])
|
||||
def delete_itat(id):
|
||||
# 2.Add new ITAT records
|
||||
@app.route('/itat/add', methods=['GET', 'POST'])
|
||||
def add_itat():
|
||||
itat = ITATHandler()
|
||||
itat.delete_itat_by_id(id)
|
||||
|
||||
if request.method == 'POST':
|
||||
data = {k: request.form.get(k, 0) for k in request.form}
|
||||
itat.add_itat(data)
|
||||
itat.close()
|
||||
flash("ITAT record added successfully!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
itat.close()
|
||||
flash("ITAT Record Deleted!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
return render_template('add_itat.html')
|
||||
|
||||
# 3.Update ITAT records by id
|
||||
@app.route('/itat/update/<int:id>', methods=['GET', 'POST'])
|
||||
def update_itat(id):
|
||||
itat = ITATHandler()
|
||||
@@ -306,28 +300,26 @@ def update_itat(id):
|
||||
itat.close()
|
||||
return render_template('update_itat.html', record=record)
|
||||
|
||||
|
||||
@app.route('/itat/add', methods=['GET', 'POST'])
|
||||
def add_itat():
|
||||
# 3.delete ITAT records by id
|
||||
@app.route('/itat/delete/<int:id>', methods=['POST'])
|
||||
def delete_itat(id):
|
||||
itat = ITATHandler()
|
||||
|
||||
if request.method == 'POST':
|
||||
data = {k: request.form.get(k, 0) for k in request.form}
|
||||
itat.add_itat(data)
|
||||
itat.close()
|
||||
flash("ITAT record added successfully!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
itat.delete_itat_by_id(id)
|
||||
itat.close()
|
||||
return render_template('add_itat.html')
|
||||
flash("ITAT Record Deleted!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
|
||||
# report form
|
||||
|
||||
|
||||
## =======================================================
|
||||
## All Report Routes
|
||||
## =======================================================
|
||||
# report page
|
||||
@app.route('/reports')
|
||||
def reports():
|
||||
return render_template("reports.html")
|
||||
|
||||
|
||||
# Itr report download by year
|
||||
@app.route('/itr_report', methods=['GET'])
|
||||
def itr_report():
|
||||
@@ -437,13 +429,33 @@ def itat_report():
|
||||
|
||||
return render_template("itat_reports.html", years=years)
|
||||
|
||||
|
||||
# summary report
|
||||
@app.route('/summary_report', methods=['GET'])
|
||||
def summary_report():
|
||||
docHandler = DocumentHandler()
|
||||
return docHandler.Summary_report(request=request)
|
||||
|
||||
|
||||
# new new -- check year in table existe or not by using ajax calling.
|
||||
@app.route('/check_year', methods=['POST'])
|
||||
def check_year():
|
||||
table_name = request.json.get("table")
|
||||
year = request.json.get("year")
|
||||
|
||||
conn = DBConfig.get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = f"SELECT COUNT(*) FROM {table_name} WHERE year = %s"
|
||||
cursor.execute(query, (year,))
|
||||
result = cursor.fetchone()[0]
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
return {"exists": result > 0}
|
||||
|
||||
|
||||
# run
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5003, debug=True)
|
||||
|
||||
Reference in New Issue
Block a user