From b3f856b401e7876bb92ebda02bbb37b504e4ff09 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Sun, 1 Dec 2024 20:16:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=8F=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=81=D1=83=D1=89=D0=BD=D0=BE=D1=81=D1=82=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=BA=D0=BB=D0=B0=D0=B4=D0=BD=D0=BE=D0=B9=20+?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20waybill.css=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=83=D1=8E?= =?UTF-8?q?=20=D0=BF=D0=B0=D0=BF=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/__init__.py | 26 ++++++++++++++++-------- App/Waybill/model.py | 7 +++++-- App/{ => Waybill}/static/css/waybill.css | 0 App/Waybill/templates/card.html | 2 +- App/Waybill/templates/waybill.html | 25 ++++++++++++----------- App/static/css/output.css | 14 ------------- 6 files changed, 36 insertions(+), 38 deletions(-) rename App/{ => Waybill}/static/css/waybill.css (100%) delete mode 100644 App/static/css/output.css diff --git a/App/Waybill/__init__.py b/App/Waybill/__init__.py index 78dd921..0c69085 100644 --- a/App/Waybill/__init__.py +++ b/App/Waybill/__init__.py @@ -1,16 +1,24 @@ from flask import request, Blueprint, render_template, session, current_app, redirect, url_for from checker import check_auth -from .model import waybill_model -waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates') +from .model import workpiece_list, clear +waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates', static_folder='static') -@waybill_bp.route('/', methods=['GET', 'POST']) +@waybill_bp.route('/', methods=['GET']) @check_auth +def index(): + lst = workpiece_list() + if lst.status: + return render_template('waybill.html', items=lst.result) + else: + return render_template('error.html', error_message=lst.error_message) + +@waybill_bp.route('/clear', methods=['GET']) +@check_auth +def clear_basket(): + clear() + return redirect(url_for('waybill_bp.index')) + +@waybill_bp.route('/', methods=['POST']) def waybill(): - if request.method == 'GET': - pack = waybill_model() - if pack.status: - return render_template('waybill.html', items=pack.result) - else: - return render_template('error.html', error_message=pack.error_message) print(request.form) return 'OK' \ No newline at end of file diff --git a/App/Waybill/model.py b/App/Waybill/model.py index d63f599..a1eda22 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -1,6 +1,6 @@ from .db.sql_provider import SQLProvider from .db.work import select_list -from flask import current_app +from flask import current_app, session from dataclasses import dataclass import os @@ -12,8 +12,11 @@ class InfoRespronse: sql_provider = SQLProvider(os.path.join(os.path.dirname(__file__), 'sql')) +def clear(): + if session.get('basket',{}): + session.pop('basket') -def waybill_model() -> InfoRespronse: +def workpiece_list() -> InfoRespronse: _sql = sql_provider.get('goods.sql', {}) result = select_list(current_app.config['db_config'], _sql) if result is None: diff --git a/App/static/css/waybill.css b/App/Waybill/static/css/waybill.css similarity index 100% rename from App/static/css/waybill.css rename to App/Waybill/static/css/waybill.css diff --git a/App/Waybill/templates/card.html b/App/Waybill/templates/card.html index a687103..2963232 100644 --- a/App/Waybill/templates/card.html +++ b/App/Waybill/templates/card.html @@ -9,7 +9,7 @@
diff --git a/App/Waybill/templates/waybill.html b/App/Waybill/templates/waybill.html index a52256f..937ec17 100644 --- a/App/Waybill/templates/waybill.html +++ b/App/Waybill/templates/waybill.html @@ -5,17 +5,16 @@ Оформление накладной - + -
- +
-

Список товаров

+

Список заготовок

{% for item in items %}
@@ -25,15 +24,17 @@
- +
-

Корзина

-
    -
  • Корзина пуста
  • -
-
-
Итог: 0 ₽
-
+

Накладная

+ {% if basket %} + {% for item in basket %} + {{ components.render_item(item, show_form = False, show_amount = True) }} + {% endfor %} + + {% else %} + Ваша накладная пуста + {% endif %}
diff --git a/App/static/css/output.css b/App/static/css/output.css deleted file mode 100644 index e91e70a..0000000 --- a/App/static/css/output.css +++ /dev/null @@ -1,14 +0,0 @@ -table { - border: 1px solid black; - border-collapse: collapse; - background: white; - margin: 0 auto; -} -th { - background-color: #d3d3d3; -} -th, td { - border: 1px solid black; - padding: 5px; - text-align: center; -}