Основной бизнес-процесс

Оформление накладных
This commit is contained in:
2024-12-03 17:46:41 +03:00
parent 453801f2e9
commit ee6a2f9756
9 changed files with 77 additions and 48 deletions

View File

@@ -1,16 +1,28 @@
from flask import request, Blueprint, render_template, session, current_app, redirect, url_for
from flask import request, Blueprint, render_template, session, redirect, url_for
from checker import check_auth
from .model import workpiece_list, clear
from .model import index_waybill, form_waybill, clear, button_click, transaction_order_model
from datetime import date
waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates', static_folder='static')
@waybill_bp.route('/', methods=['GET'])
@check_auth
def index():
lst = workpiece_list()
if lst.status:
return render_template('waybill.html', items=lst.result)
lst = index_waybill()
if lst is not None:
waybill = form_waybill()
return render_template('waybill.html', items=lst, waybill=waybill)
else:
return render_template('error.html', error_message=lst.error_message)
return render_template('error.html', error_message="Ошибка в подключении к СУБД")
@waybill_bp.route('/', methods=['POST'])
@check_auth
def waybill_main():
status = button_click(request)
if status:
return redirect(url_for('waybill_bp.index'))
else:
return render_template("error.html", error_message="Товар не был добавлен в корзину")
@waybill_bp.route('/clear', methods=['GET'])
@check_auth
@@ -18,7 +30,19 @@ def clear_waybill():
clear()
return redirect(url_for('waybill_bp.index'))
@waybill_bp.route('/', methods=['POST'])
def waybill():
print(request.form)
return 'OK'
@waybill_bp.route('/save_order')
@check_auth
def save_order():
if not session.get('waybill',{}):
return redirect(url_for('waybill_bp.index'))
user_id = session.get('user_id',"")
current_date = date.today().strftime("%Y-%m-%d") + ' ' + date.today().strftime("%H:%M:%S")
result = transaction_order_model(user_id, current_date)
if result.status:
print("Order success")
return "OK"
# return render_template("order_finish.html", order_id = result.result[0])
else:
return render_template("error.html", error_message=result.error_message)