lavkach3
1from fastapi import APIRouter, Depends
2from fastapi import Request
3from fastapi.responses import HTMLResponse
4
5from app.front.template_spec import templates
6from app.front.utills import BasePermit
7from core.frontend.constructor import ClassView
8
9product_router = APIRouter()
10
11class ProductPermit(BasePermit):
12permits = ['product_list']
13
14@product_router.get("", response_class=HTMLResponse, dependencies=[Depends(ProductPermit)])
15async def product(request: Request):
16cls = ClassView(request, model='product')
17template = f'widgets/list{"" if request.scope["htmx"].hx_request else "-full"}.html'
18return templates.TemplateResponse(request, template, context={'cls': cls})
19
20