Revize 35168e5f
Přidáno uživatelem Matěj Zeman před více než 2 roky(ů)
server/sql_app/api/pcs_web.py | ||
---|---|---|
42 | 42 |
current_user = "guest" |
43 | 43 |
return templates.TemplateResponse("pcs_normal.html", {"request": request, "pcs": pcs, "user": current_user}) |
44 | 44 |
|
45 |
|
|
46 |
@pcs_web.get("/pc-team/{pc_id}", response_class=HTMLResponse) |
|
47 |
async def connect_pc_team(request: Request, pc_id: int, db: Session = Depends(get_db), |
|
48 |
Authorize: AuthJWT = Depends()): |
|
49 |
""" |
|
50 |
Returns template with Form for connecting pc with team |
|
51 |
""" |
|
52 |
Authorize.jwt_optional() |
|
53 |
current_user = Authorize.get_jwt_subject() |
|
54 |
if current_user != "admin": |
|
55 |
return RedirectResponse(url=f"/logs-web", status_code=303) |
|
56 |
pc = crud.get_pc(db, pc_id) |
|
57 |
teams = crud.get_teams(db, 0, 100) |
|
58 |
return templates.TemplateResponse("pcteam.html", |
|
59 |
{"request": request, "pc": pc, "teams": teams}) |
|
60 |
|
|
61 |
|
|
62 |
@pcs_web.post("/pcs-web/{pc_id}") |
|
63 |
async def connect_post(pc_id: int, team: str = Form(...), db: Session = Depends(get_db), |
|
64 |
Authorize: AuthJWT = Depends()): |
|
65 |
""" |
|
66 |
Endpoint called from within form for connecting pc with team. Updates certain pc with new team. |
|
67 |
""" |
|
68 |
Authorize.jwt_optional() |
|
69 |
current_user = Authorize.get_jwt_subject() |
|
70 |
if current_user != "admin": |
|
71 |
return RedirectResponse(url=f"/logs-web", status_code=303) |
|
72 |
old_pc = crud.update_pc(db, pc_id, team) |
|
73 |
return RedirectResponse(url=f"/pcs-web", status_code=303) |
Také k dispozici: Unified diff
Fixed minor issues. View on keyman devices changed. Changed database for new keyman x license connection.