Revize 35168e5f
Přidáno uživatelem Matěj Zeman před více než 2 roky(ů)
server/sql_app/api/teams_web.py | ||
---|---|---|
59 | 59 |
@teams_web.post("/teams-web-con") |
60 | 60 |
def create_team(name: str = Form(...), db: Session = Depends(get_db), Authorize: AuthJWT = Depends()): |
61 | 61 |
""" |
62 |
Endpoint called from within form for creating new team. Creates new team and returns all teams in database
|
|
62 |
Endpoint called from within form for creating new team. Creates new team and redirects to view with all teams
|
|
63 | 63 |
""" |
64 | 64 |
Authorize.jwt_optional() |
65 | 65 |
current_user = Authorize.get_jwt_subject() |
... | ... | |
74 | 74 |
if team is None: |
75 | 75 |
print("something went wrong") |
76 | 76 |
return RedirectResponse(url=f"/teams-web", status_code=303) |
77 |
|
|
78 |
|
|
79 |
@teams_web.get("/team-change/{team_id}", response_class=HTMLResponse) |
|
80 |
async def team_change_web(request: Request, team_id: int, db: Session = Depends(get_db), |
|
81 |
Authorize: AuthJWT = Depends()): |
|
82 |
""" |
|
83 |
Returns template with form for changing teams name |
|
84 |
""" |
|
85 |
Authorize.jwt_optional() |
|
86 |
current_user = Authorize.get_jwt_subject() |
|
87 |
if current_user != "admin": |
|
88 |
return RedirectResponse(url=f"/logs-web", status_code=303) |
|
89 |
team = crud.get_team(db, team_id) |
|
90 |
return templates.TemplateResponse("team_change.html", {"request": request, "team": team}) |
|
91 |
|
|
92 |
@teams_web.post("/teams-change-process/{team_id}") |
|
93 |
async def team_change_process(team_id: int, db:Session = Depends(get_db), name: str = Form(...), |
|
94 |
Authorize: AuthJWT = Depends()): |
|
95 |
""" |
|
96 |
Changes teams name to a new one given by user |
|
97 |
""" |
|
98 |
Authorize.jwt_optional() |
|
99 |
current_user = Authorize.get_jwt_subject() |
|
100 |
if current_user != "admin": |
|
101 |
return RedirectResponse(url=f"/logs-web", status_code=303) |
|
102 |
team = crud.change_team(db, team_id, name) |
|
103 |
return RedirectResponse(url=f"/teams-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.