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/__init__.py

42 lines
1.7 KiB
Python

from flask import request, Blueprint, render_template, url_for
from os import path
from checker import check_auth
from .requests_model import sklad, materials_per_seller, sellers_names, materials_names
import json
with open(path.join(path.dirname(__file__), 'zapros_menu.json'), encoding='utf-8') as f:
requests_list = json.load(f)
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)
@requests_bp.route('/sklad', methods=['GET', 'POST'])
@check_auth
def sklad_zapros():
if request.method == 'GET':
return render_template('zagotovki.html')
else:
zagotovki = sklad(request)
if zagotovki.status:
header = f'Заготовки на складе из материала \"{material["material"]}\"'
return render_template('output.html', items=zagotovki.result, header=header)
else:
return render_template('error.html', error_message=zagotovki.error_message)
@requests_bp.route('/shipments', methods=['GET', 'POST'])
@check_auth
def sellers_ship():
if request.method == 'GET':
return render_template('sellers_ship.html')
else:
zagotovki = materials_per_seller(request)
if zagotovki.status:
header = f'Поставки от поставщика \"{seller["seller"]}\"'
return render_template('output.html', items=zagotovki.result, header=header, link=url_for('requests_bp.requests'))
else:
return render_template('error.html', error_message=zagotovki.error_message)