pre-commit changes
This commit is contained in:
@@ -1,47 +1,61 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, session, request
|
||||
from checker import check_auth
|
||||
from .model import index_waybill, form_waybill, clear, button_click, transaction_order_model
|
||||
from datetime import datetime
|
||||
|
||||
waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates', static_folder='static')
|
||||
from checker import check_auth
|
||||
from flask import (Blueprint, redirect, render_template, request, session,
|
||||
url_for)
|
||||
|
||||
@waybill_bp.route('/', methods=['GET'])
|
||||
from .model import (button_click, clear, form_waybill, index_waybill,
|
||||
transaction_order_model)
|
||||
|
||||
waybill_bp = Blueprint(
|
||||
"waybill_bp", __name__, template_folder="templates", static_folder="static"
|
||||
)
|
||||
|
||||
|
||||
@waybill_bp.route("/", methods=["GET"])
|
||||
@check_auth
|
||||
def index():
|
||||
lst = index_waybill()
|
||||
if lst is not None:
|
||||
waybill = form_waybill()
|
||||
return render_template('waybill.html', items=lst, waybill=waybill)
|
||||
return render_template("waybill.html", items=lst, waybill=waybill)
|
||||
else:
|
||||
return render_template('error.html', error_message="Ошибка в подключении к СУБД")
|
||||
return render_template(
|
||||
"error.html", error_message="Ошибка в подключении к СУБД"
|
||||
)
|
||||
|
||||
@waybill_bp.route('/', methods=['POST'])
|
||||
|
||||
@waybill_bp.route("/", methods=["POST"])
|
||||
@check_auth
|
||||
def waybill_main():
|
||||
status = button_click(request)
|
||||
if status:
|
||||
return redirect(url_for('waybill_bp.index'))
|
||||
return redirect(url_for("waybill_bp.index"))
|
||||
else:
|
||||
return render_template("error.html", error_message="Товар не был добавлен в корзину")
|
||||
return render_template(
|
||||
"error.html", error_message="Товар не был добавлен в корзину"
|
||||
)
|
||||
|
||||
@waybill_bp.route('/clear', methods=['GET'])
|
||||
|
||||
@waybill_bp.route("/clear", methods=["GET"])
|
||||
@check_auth
|
||||
def clear_waybill():
|
||||
clear()
|
||||
return redirect(url_for('waybill_bp.index'))
|
||||
return redirect(url_for("waybill_bp.index"))
|
||||
|
||||
@waybill_bp.route('/save_order')
|
||||
|
||||
@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',"")
|
||||
if not session.get("waybill", {}):
|
||||
return redirect(url_for("waybill_bp.index"))
|
||||
|
||||
user_id = session.get("user_id", "")
|
||||
current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
result = transaction_order_model(user_id, current_date)
|
||||
if result.status:
|
||||
print("Order success")
|
||||
return render_template("order_finish.html", order_id = result.result[0])
|
||||
return render_template("order_finish.html", order_id=result.result[0])
|
||||
else:
|
||||
return render_template("error.html", error_message=result.error_message)
|
||||
return render_template("error.html", error_message=result.error_message)
|
||||
|
||||
Reference in New Issue
Block a user