Merge branch 'Debug'
This commit is contained in:
@@ -13,13 +13,13 @@ class InfoRespronse:
|
||||
|
||||
def auth_model(input_data) -> InfoRespronse:
|
||||
_sql = sql_provider.get('auth.sql', input_data)
|
||||
result = select_list(current_app.config['db_config'], _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(result,
|
||||
error_message = 'Произошла ошибка на этапе авторизации',
|
||||
user = select_list(current_app.config['db_config'], _sql)
|
||||
if user is None:
|
||||
return InfoRespronse((),
|
||||
error_message = 'Ошибка при подключении к БД',
|
||||
status=False)
|
||||
elif len(result) == 0:
|
||||
return InfoRespronse(result,
|
||||
elif len(user) == 0:
|
||||
return InfoRespronse((),
|
||||
error_message = 'Пользователь не найден',
|
||||
status=False)
|
||||
return InfoRespronse(result, error_message='', status=True)
|
||||
return InfoRespronse(user, error_message='', status=True)
|
||||
@@ -1,3 +1,4 @@
|
||||
SELECT login, user_role FROM $table
|
||||
WHERE login = '$login'
|
||||
AND password = '$password';
|
||||
AND password = '$password'
|
||||
LIMIT 1;
|
||||
@@ -1,7 +1,7 @@
|
||||
from flask import request, Blueprint, render_template
|
||||
from os import path
|
||||
from checker import check_auth
|
||||
from .requests_model import sklad, get_goods, get_sellers, materials_per_seller
|
||||
from .requests_model import sklad, materials_per_seller
|
||||
from datetime import date
|
||||
import json
|
||||
|
||||
@@ -20,11 +20,8 @@ def requests():
|
||||
@check_auth
|
||||
def sklad_zapros():
|
||||
if request.method == 'GET':
|
||||
zagotovki = get_goods()
|
||||
if zagotovki.status:
|
||||
return render_template('zagotovki.html', materials=zagotovki.result, header='Количество заготовок на складе')
|
||||
else:
|
||||
return render_template('error.html', error_message=zagotovki.error_message)
|
||||
materials = ['Сталь', 'Золото', 'Дерево', 'Стекло', 'Медь', 'Цемент']
|
||||
return render_template('zagotovki.html', materials=materials, header='Количество заготовок на складе')
|
||||
else:
|
||||
material = dict(request.form)
|
||||
zagotovki = sklad(material)
|
||||
@@ -57,11 +54,8 @@ def zagotovki_ship():
|
||||
@check_auth
|
||||
def sellers_ship():
|
||||
if request.method == 'GET':
|
||||
zagotovki = get_sellers()
|
||||
if zagotovki.status:
|
||||
return render_template('sellers_ship.html', sellers=zagotovki.result, year_from='2000', year_to=str(date.today().year))
|
||||
else:
|
||||
return render_template('error.html', error_message=zagotovki.error_message)
|
||||
sellers = ['Car and bikes', 'Doto', 'LPD', 'Neva', 'PGG', 'Robot', 'Rost']
|
||||
return render_template('sellers_ship.html', sellers=sellers, year_from='2000', year_to=str(date.today().year))
|
||||
else:
|
||||
seller = dict(request.form)
|
||||
zagotovki = materials_per_seller(seller)
|
||||
|
||||
@@ -11,30 +11,12 @@ class InfoRespronse:
|
||||
error_message: str
|
||||
status: bool
|
||||
|
||||
def get_goods() -> InfoRespronse:
|
||||
_sql = sql_provider.get('zagotovki.sql', {})
|
||||
result = select_list(current_app.config['db_config'], _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(result,
|
||||
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||
status=False)
|
||||
return InfoRespronse(result, error_message='', status=True)
|
||||
|
||||
def get_sellers() -> InfoRespronse:
|
||||
_sql = sql_provider.get('sellers.sql', {})
|
||||
result = select_list(current_app.config['db_config'], _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(result,
|
||||
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||
status=False)
|
||||
return InfoRespronse(result, error_message='', status=True)
|
||||
|
||||
def sklad(input_data) -> InfoRespronse:
|
||||
_sql = sql_provider.get('zapros1.sql', input_data)
|
||||
print("sql = ", _sql)
|
||||
result = select_list(current_app.config['db_config'], _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(result,
|
||||
return InfoRespronse((),
|
||||
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||
status=False)
|
||||
return InfoRespronse(result, error_message='', status=True)
|
||||
@@ -43,7 +25,7 @@ def materials_per_seller(input_data) -> InfoRespronse:
|
||||
_sql = sql_provider.get('zapros3.sql', input_data)
|
||||
result = select_list(current_app.config['db_config'], _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(result,
|
||||
return InfoRespronse((),
|
||||
error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором',
|
||||
status=False)
|
||||
return InfoRespronse(result, error_message='', status=True)
|
||||
@@ -1,3 +0,0 @@
|
||||
SELECT name FROM sellers
|
||||
ORDER BY name
|
||||
LIMIT 100;
|
||||
@@ -1 +0,0 @@
|
||||
SELECT DISTINCT material FROM workpiece
|
||||
@@ -16,7 +16,7 @@
|
||||
<form action="" method="post">
|
||||
<select name="seller">
|
||||
{% for item in sellers %}
|
||||
<option value="{{ item['name'] }}">{{ item['name'] }}</option>
|
||||
<option value="{{ item }}">{{ item }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<p>Выберите год:</p>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<p>Выберите материал<p></p>
|
||||
<select name="material">
|
||||
{% for item in materials %}
|
||||
<option value="{{ item['material'] }}">{{ item['material'] }}</option>
|
||||
<option value="{{ item }}">{{ item }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="Отправить">
|
||||
|
||||
9
App/Waybill/__init__.py
Normal file
9
App/Waybill/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from flask import request, Blueprint, render_template, session, current_app, redirect, url_for
|
||||
from checker import check_auth
|
||||
waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates')
|
||||
|
||||
@waybill_bp.route('/', methods=['GET', 'POST'])
|
||||
@check_auth
|
||||
def waybill():
|
||||
if request.method == 'GET':
|
||||
return render_template('waybill.html')
|
||||
10
App/Waybill/templates/waybill.html
Normal file
10
App/Waybill/templates/waybill.html
Normal file
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Авторизация</title>
|
||||
<link href="/static/css/auth.css" type="text/css" rel="stylesheet">
|
||||
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Заглушка для примера составления накладной</h1>
|
||||
@@ -1,5 +1,6 @@
|
||||
from flask import Flask, render_template, session
|
||||
from Requests import requests_bp
|
||||
from Waybill import waybill_bp
|
||||
from Auth import auth_bp
|
||||
from Report import report_bp
|
||||
import os, json
|
||||
@@ -15,6 +16,7 @@ app.config.update(
|
||||
app.register_blueprint(requests_bp, url_prefix='/requests')
|
||||
app.register_blueprint(auth_bp, url_prefix='/auth')
|
||||
app.register_blueprint(report_bp, url_prefix='/report')
|
||||
app.register_blueprint(waybill_bp, url_prefix='/waybill')
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"manager": ["auth_bp", "requests_bp"],
|
||||
"boss": ["auth_bp", "requests_bp"],
|
||||
"sellers": ["auth_bp", "requests_bp", "waybill_bp"]
|
||||
"Менеджер": ["auth_bp", "requests_bp"],
|
||||
"Управляющий": ["auth_bp", "requests_bp"],
|
||||
"Поставщик": ["auth_bp", "requests_bp", "waybill_bp"]
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
<a href="{{ url_for('logout') }}"><button>Выход</button></a>
|
||||
</div>
|
||||
<h1>Здравствуйте, {{ ses['login'] }}!</h1>
|
||||
<h2> Ваша роль: {{ ses['role'] }}</h2>
|
||||
{% if ses['access_user'] == 'in' %}
|
||||
<!-- Not implemented -->
|
||||
<nav class="menu">
|
||||
@@ -20,7 +21,6 @@
|
||||
{% else %}
|
||||
<nav class="menu">
|
||||
<!-- Not implemented -->
|
||||
<!-- <a href="{{ url_for('requests_bp.requests') }}"><button>Запросы</button></a> -->
|
||||
<a href="{{ url_for('waybill_bp.waybill') }}"><button>Новая накладная</button></a>
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user