From 2d1f992490a138eabce8410d15895c1cc85a67e6 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 15:53:13 +0300 Subject: [PATCH 1/6] result tuple in waybill outside of loop --- App/Waybill/model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 4335e07..8697dce 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -121,7 +121,7 @@ def transaction_order_model(user_id: int, current_date: date) -> InfoRespronse: ), ) cursor.execute(_sql) - result = tuple([order_id]) + result = tuple([order_id]) if result is None: return InfoRespronse((), error_message="Заказ не был создан", status=False) clear() From 254f4ff36025ad0d4fad503f2886d65fd3eef78c Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 16:51:25 +0300 Subject: [PATCH 2/6] Dockerfile and build --- Dockerfile | 18 ++++++++++++++++++ build.sh | 4 ++++ requirements.txt | Bin 130 -> 110 bytes 3 files changed, 22 insertions(+) create mode 100644 Dockerfile create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..974ef27 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Python image as a base +FROM python:3.9.20-alpine3.19 + +# Set the working directory inside the container +WORKDIR /app + +# Copy the contents of the 'App' folder to the working directory +COPY App/ /app + +# Copy the requirements file to the working directory +COPY requirements.txt /app + +# Install the dependencies from the requirements file +RUN pip install --no-cache-dir -r requirements.txt + +EXPOSE 5001 +# Command to run the application +CMD ["gunicorn", "--bind", "0.0.0.0:5001", "app:app"] diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..418d6d2 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t tsettaro/kursovaya-ris:latest . +docker push tsettaro/kursovaya-ris:latest \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 4e407bfe1d0af66f30bb7a23e15ebc7b833d1661..fc9471b3581e08ed16536959c9c12db8be88ff97 100644 GIT binary patch literal 110 zcmYc;sw^nUPcKR=$f&fnH8IvR&@<+8%SkNGwzY+DyfX8$5{*DSLp>9&f}+&;7LHqSHs51%E3afUaJrKB)SNL nhp!l198zZSoypQaE9B%#MM-9PAn(iTZgjMavft%cEVSDX?~xPO From 07e40e0e47b656bcad2650df16db4573a6bb2aca Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 17:24:55 +0300 Subject: [PATCH 3/6] Redirect from logout to main_menu --- App/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/App/app.py b/App/app.py index 97f561d..34ca2a7 100644 --- a/App/app.py +++ b/App/app.py @@ -2,7 +2,7 @@ import json import os from Auth import auth_bp -from flask import Flask, render_template, session +from flask import Flask, redirect, render_template, session from Report import report_bp from Requests import requests_bp from Waybill import waybill_bp @@ -45,7 +45,7 @@ def index(): @app.route("/logout") def logout(): session.clear() - return render_template("main_menu.html", ses=session) + return redirect("/") if __name__ == "__main__": From eacce0130aff7e117eb526415df99fb6d53c6131 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 21:02:35 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/model.py | 4 +-- App/Waybill/templates/waybill.html | 40 +++++++++++++++++++----------- App/cache/wrapper.py | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 8697dce..b13b035 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -74,12 +74,12 @@ def button_click(request): session["total"] = str(int(session["total"]) + price) session.modified = True else: - print("NEW WORKPIECE") + # print("NEW WORKPIECE") pr_id = product["work_id"] price = product["price"] session["waybill"][str(pr_id)] = "1" session["total"] = str(int(session["total"]) + price) - print(session["waybill"]) + # print(session["waybill"]) session.modified = True elif request.form.get("product_display_minus"): diff --git a/App/Waybill/templates/waybill.html b/App/Waybill/templates/waybill.html index 4698e25..43c6eb3 100644 --- a/App/Waybill/templates/waybill.html +++ b/App/Waybill/templates/waybill.html @@ -39,22 +39,34 @@

Накладная

{% if waybill %} - {% for item in waybill %} - {{ card.render_item(item, show_form = False, show_amount = True) }} - {% endfor %} -
-
Итого: {{ session.get('total', '0') }} ₽
+
+
+
+ {% for item in waybill %} +
+ {{ card.render_item(item, show_form = False, show_amount = True) }} +
+ {% endfor %} +
+
+
+
Итого: {{ session.get('total', '0') }} ₽
+ +
- {% else %} - Ваша накладная пуста - +
+
+ Ваша накладная пуста +
+ +
{% endif %}
diff --git a/App/cache/wrapper.py b/App/cache/wrapper.py index e4a0bba..50f65b0 100644 --- a/App/cache/wrapper.py +++ b/App/cache/wrapper.py @@ -17,7 +17,7 @@ def fetch_from_cache(cache_name: str, cache_config: dict): @wraps(f) def wrapper(*args, **kwargs): cached_value = cache_conn.get_value(cache_name) - print("cached_value=", cached_value) + # print("cached_value=", cached_value) if cached_value: return cached_value response = f(*args, **kwargs) From 7e46ccd589e02da0e06b6602d5aad2d88f82b3ef Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 21:22:54 +0300 Subject: [PATCH 5/6] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/sql/ship_seller.sql | 4 ++-- App/Requests/sql/sklad_workpiece.sql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/App/Requests/sql/ship_seller.sql b/App/Requests/sql/ship_seller.sql index f97bfb8..bcfce65 100644 --- a/App/Requests/sql/ship_seller.sql +++ b/App/Requests/sql/ship_seller.sql @@ -1,7 +1,7 @@ SELECT DATE_FORMAT(w.waybill_date, '%Y-%m-%d') AS 'Дата поставки', TIME_FORMAT(w.waybill_date, '%H:%i') AS 'Время поставки', - SUM(w.total) AS 'Общая сумма (в рублях)', - SUM(wl.amount) as 'Общее количество заготовок' + SUM(w.total) AS 'Общая сумма (в ₽)', + SUM(wl.amount) as 'Общее количество заготовок (в шт.)' FROM waybill w JOIN (SELECT waybill_id, SUM(amount) AS amount FROM waybill_lines wl GROUP BY waybill_id)wl USING (waybill_id) diff --git a/App/Requests/sql/sklad_workpiece.sql b/App/Requests/sql/sklad_workpiece.sql index 14f8729..d925e29 100644 --- a/App/Requests/sql/sklad_workpiece.sql +++ b/App/Requests/sql/sklad_workpiece.sql @@ -2,7 +2,7 @@ SELECT DATE_FORMAT(w.waybill_date, '%Y-%m-%d') AS 'Дата поставки', TIME_FORMAT(w.waybill_date, '%H:%i') AS 'Время поставки', s.name AS 'Поставщик', - wl.amount AS 'Количество' + wl.amount AS 'Количество (в шт.)' FROM waybill w JOIN (SELECT waybill_id, work_id, amount FROM waybill_lines) wl USING(waybill_id) From b98805bc5dd3065c223356c8a7f74d4d2b08acfe Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 12 Dec 2024 21:26:16 +0300 Subject: [PATCH 6/6] =?UTF-8?q?=D0=A2=D0=BE=20=D0=B6=D0=B5=20=D1=81=D0=B0?= =?UTF-8?q?=D0=BC=D0=BE=D0=B5,=20=D0=BD=D0=BE=20=D1=81=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/sql/sellers_report.sql | 2 +- App/Report/sql/workpiece_report.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/App/Report/sql/sellers_report.sql b/App/Report/sql/sellers_report.sql index 49855a7..18b4e32 100644 --- a/App/Report/sql/sellers_report.sql +++ b/App/Report/sql/sellers_report.sql @@ -1,6 +1,6 @@ SELECT s.name AS Поставщик, - reports.sum AS 'Сумма в рублях', + reports.sum AS 'Сумма (в ₽)', reports.count AS 'Количество поставок' FROM reports JOIN sellers s ON reports.item_id = s.sel_id diff --git a/App/Report/sql/workpiece_report.sql b/App/Report/sql/workpiece_report.sql index 6abe547..ac9c8e2 100644 --- a/App/Report/sql/workpiece_report.sql +++ b/App/Report/sql/workpiece_report.sql @@ -1,6 +1,6 @@ SELECT w.name AS Наименование, - reports.sum AS 'Сумма в рублях', - reports.count AS 'Количество поставленных заготовок' + reports.sum AS 'Сумма (в ₽)', + reports.count AS 'Количество поставленных заготовок (в шт.)' from reports JOIN workpiece w ON reports.item_id = w.work_id WHERE report_category_id = '$id' AND (month = '$month' AND year = '$year')