-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from georgejkaye/login-box
Change login box to combined login and settings page
- Loading branch information
Showing
10 changed files
with
317 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from dataclasses import dataclass | ||
from typing import Annotated | ||
from cookiebreaks.api.routers.users import get_current_user | ||
from cookiebreaks.api.routers.utils import ( | ||
BreakExternal, | ||
ClaimExternal, | ||
get_breaks, | ||
get_claims, | ||
) | ||
from cookiebreaks.core.database import select_settings | ||
from cookiebreaks.core.structs import Settings, User | ||
from fastapi import APIRouter, Depends | ||
|
||
|
||
router = APIRouter(prefix="/data", tags=["data"]) | ||
|
||
|
||
@dataclass | ||
class Data: | ||
settings: Settings | ||
breaks: list[BreakExternal] | ||
claims: list[ClaimExternal] | ||
|
||
|
||
@router.get("", response_model=Data, summary="Get all data") | ||
def get_settings( | ||
current_user: Annotated[User, Depends(get_current_user)], | ||
): | ||
settings = select_settings() | ||
breaks = get_breaks(current_user=current_user) | ||
claims = get_claims(current_user=current_user) | ||
return Data(settings, breaks, claims) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from datetime import time | ||
from decimal import Decimal | ||
from typing import Annotated, Optional | ||
from cookiebreaks.api.routers.users import is_admin | ||
from cookiebreaks.core.database import select_settings | ||
from cookiebreaks.core.structs import Settings, User | ||
from fastapi import APIRouter, Depends | ||
|
||
|
||
router = APIRouter(prefix="/settings", tags=["settings"]) | ||
|
||
|
||
@router.get("", response_model=Settings, summary="Get settings") | ||
def get_settings(): | ||
settings = select_settings() | ||
return settings | ||
|
||
|
||
@router.post("", response_model=Settings, summary="Update settings") | ||
def post_settings( | ||
user: Annotated[User, Depends(is_admin)], | ||
day: int, | ||
time: time, | ||
budget: Decimal, | ||
location: str, | ||
): | ||
set_settings(day, time, budget, location) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.