This repository has been archived on 2025-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
Files
RIS/App/Requests/requests.py

39 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import request, Blueprint, render_template, session
from os import path
from Database.sql_provider import SQLProvider
from checker import check_auth
from .requests_route import route
import json
with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f:
requests_list = json.load(f)
sql_provider = SQLProvider(path.join(path.dirname(__file__), 'sql'))
requests_bp = Blueprint('requests_bp', __name__, template_folder='templates')
@requests_bp.route('/', methods=['GET', 'POST'])
@check_auth
def requests():
if request.method == 'GET':
return render_template('zapros_menu.html', options=requests_list)
else:
return 'error'
@requests_bp.route('/req1', methods=['GET', 'POST'])
@check_auth
def sklad_zapros():
if request.method == 'GET':
zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql')
if zagotovki.status:
return render_template('sklad_zapros.html', materials=zagotovki.result)
else:
return zagotovki.error_message
else:
material = dict(request.form)
zagotovki = route(session['db_config'], material, sql_provider, 'zapros1.sql')
if zagotovki.status:
categories = ['Вес (в кг.)', 'Цена (в руб.)', 'Количество', 'Дата последнего обновления']
header = f'Заготовки на складе из материала \'{material["material"]}\''
return render_template('output.html', items=zagotovki.result, titles = categories, object=header)
else:
return zagotovki.error_message