diff --git a/app/api/api_v1/endpoints/match.py b/app/api/api_v1/endpoints/match.py deleted file mode 100644 index 1f43fed..0000000 --- a/app/api/api_v1/endpoints/match.py +++ /dev/null @@ -1,96 +0,0 @@ -from typing import Any, List - -from fastapi import APIRouter, Body, Depends, HTTPException -from fastapi.encoders import jsonable_encoder -from pydantic.networks import EmailStr -from sqlalchemy.orm import Session - -from app import crud -from app.api import deps - -from app.models.player import Player, PlayerCreate, PlayerUpdate -from app.models.user import User - -router = APIRouter() - - -@router.get("/{id}", response_model=Player) -def read_player( - *, - db: Session = Depends(deps.get_db), - firstname: str, - lastname: str, - current_user: User = Depends(deps.get_current_active_user), -) -> Any: - """ - Get player by firstname and lastname. - """ - player = crud.player.get_player_by_name( - db=db, firstname=firstname, lastname=lastname - ) - if not player: - raise HTTPException(status_code=404, detail="player not found") - if not crud.user.is_superuser(current_user): - raise HTTPException(status_code=400, detail="Not enough permissions") - return player - - -@router.post("/", response_model=List[Player]) -def create_player( - *, - db: Session = Depends(deps.get_db), - players_in: list[PlayerCreate], - current_user: User = Depends(deps.get_current_active_superuser), -) -> Any: - """ - Create new user. - """ - player_out = [] - for player_in in players_in: - player = crud.player.get_player_by_name( - db, firstname=player_in.firstname, lastname=player_in.lastname - ) - if player: - raise HTTPException( - status_code=400, - detail=f"The user with this username already exists in the " - f"system. Player is {player}", - ) - player = crud.player.create(db, obj_in=player_in) - player_out.append(player) - - return player_out - - -@router.get("/", response_model=List[Player]) -def get_players( - db: Session = Depends(deps.get_db), - skip: int = 0, - limit: int = 100, - current_user: User = Depends(deps.get_current_active_superuser), -) -> Any: - """ - Retrieve all players. - """ - player = crud.player.get_multi(db, skip=skip, limit=limit) - return player - - -@router.post("/{id}", response_model=Player) -def update_player( - *, - db: Session = Depends(deps.get_db), - id: int, - player_in: PlayerUpdate, - current_user: User = Depends(deps.get_current_active_user), -) -> Any: - """ - Update player. - """ - - player = crud.player.get(db=db, id=id) - if not player: - raise HTTPException(status_code=404, detail="Player not found") - - player = crud.player.update(db=db, db_obj=player, obj_in=player_in) - return player diff --git a/app/db/base.py b/app/db/base.py deleted file mode 100644 index 4e02b30..0000000 --- a/app/db/base.py +++ /dev/null @@ -1,4 +0,0 @@ -from app.db.base_class import Base # noqa - -# from app.models.item import Item # noqa -from app.models.user import User # noqa diff --git a/app/models/match.py b/app/models/match.py deleted file mode 100644 index 9f014f5..0000000 --- a/app/models/match.py +++ /dev/null @@ -1,24 +0,0 @@ -from typing import Optional - -from sqlmodel import SQLModel, Field - -from app.db.base_class import Base - - -class Match(SQLModel, Base, table=True): - matchname: Optional[str] = Field(nullable=False) - -""" - match_id = Column(Integer, primary_key=True) - team_1 = Column(ForeignKey("team.id"), nullable=False) - team_2 = Column(ForeignKey("team.id"), nullable=False) - day = Column(ForeignKey("matchday.id"), nullable=False) - winner = Column(ForeignKey("team.team_id"), nullable=True) - team_1_result = Column(Integer, nullable=True) - team_2_result = Column(Integer, nullable=True) - - matchday = relationship("Matchday") - team = relationship("Team", primaryjoin="Match.team_1 == Team.team_id") - team1 = relationship("Team", primaryjoin="Match.team_2 == Team.team_id") - team2 = relationship("Team", primaryjoin="Match.winner == Team.team_id") -""" \ No newline at end of file diff --git a/.flake8 b/backend/.flake8 similarity index 100% rename from .flake8 rename to backend/.flake8 diff --git a/.gitignore b/backend/.gitignore similarity index 100% rename from .gitignore rename to backend/.gitignore diff --git a/README.md b/backend/README.md similarity index 100% rename from README.md rename to backend/README.md diff --git a/app/__init__.py b/backend/app/__init__.py similarity index 100% rename from app/__init__.py rename to backend/app/__init__.py diff --git a/app/api/__init__.py b/backend/app/api/__init__.py similarity index 100% rename from app/api/__init__.py rename to backend/app/api/__init__.py diff --git a/app/api/api_v1/__init__.py b/backend/app/api/api_v1/__init__.py similarity index 100% rename from app/api/api_v1/__init__.py rename to backend/app/api/api_v1/__init__.py diff --git a/app/api/api_v1/api.py b/backend/app/api/api_v1/api.py similarity index 50% rename from app/api/api_v1/api.py rename to backend/app/api/api_v1/api.py index 4d9a457..49b73fe 100644 --- a/app/api/api_v1/api.py +++ b/backend/app/api/api_v1/api.py @@ -1,11 +1,11 @@ from fastapi import APIRouter -from app.api.api_v1.endpoints import users -from app.api.api_v1.endpoints import login -from app.api.api_v1.endpoints import player -from app.api.api_v1.endpoints import team -from app.api.api_v1.endpoints import match -from app.api.api_v1.endpoints import matchday +from backend.app.api.api_v1.endpoints import users +from backend.app.api.api_v1.endpoints import login +from backend.app.api.api_v1.endpoints import player +from backend.app.api.api_v1.endpoints import team +from backend.app.api.api_v1.endpoints import match +from backend.app.api.api_v1.endpoints import matchday api_router = APIRouter() api_router.include_router(login.router, tags=["login"]) @@ -13,4 +13,4 @@ api_router.include_router(users.router, prefix="/users", tags=["users"]) api_router.include_router(player.router, prefix="/player", tags=["player"]) api_router.include_router(team.router, prefix="/team", tags=["team"]) api_router.include_router(matchday.router, prefix="/matchday", tags=["matchday"]) -#api_router.include_router(match.router, prefix="/match", tags=["match"]) +api_router.include_router(match.router, prefix="/match", tags=["match"]) diff --git a/app/api/api_v1/endpoints/__init__.py b/backend/app/api/api_v1/endpoints/__init__.py similarity index 100% rename from app/api/api_v1/endpoints/__init__.py rename to backend/app/api/api_v1/endpoints/__init__.py diff --git a/app/api/api_v1/endpoints/login.py b/backend/app/api/api_v1/endpoints/login.py similarity index 86% rename from app/api/api_v1/endpoints/login.py rename to backend/app/api/api_v1/endpoints/login.py index 8765553..94eaeb8 100644 --- a/app/api/api_v1/endpoints/login.py +++ b/backend/app/api/api_v1/endpoints/login.py @@ -5,15 +5,15 @@ from fastapi import APIRouter, Body, Depends, HTTPException from fastapi.security import OAuth2PasswordRequestForm from sqlalchemy.orm import Session -from app import crud -from app.api import deps -from app.core import security -from app.core.config import settings -from app.core.security import get_password_hash -from app.models.msg import Msg -from app.models.token import Token -from app.models.user import User -from app.utils import ( +from backend.app import crud +from backend.app.api import deps +from backend.app.core import security +from backend.app.core.config import settings +from backend.app.core.security import get_password_hash +from backend.app.models.msg import Msg +from backend.app.models.token import Token +from backend.app.models.user import User +from backend.app.utils import ( generate_password_reset_token, send_reset_password_email, verify_password_reset_token, diff --git a/backend/app/api/api_v1/endpoints/match.py b/backend/app/api/api_v1/endpoints/match.py new file mode 100644 index 0000000..e968188 --- /dev/null +++ b/backend/app/api/api_v1/endpoints/match.py @@ -0,0 +1,83 @@ +from typing import Any, List + +from fastapi import APIRouter, Depends, HTTPException +from sqlalchemy.orm import Session + +from backend.app import crud +from backend.app.api import deps + +from backend.app.models.match import Match, MatchCreate, MatchUpdate +from backend.app.models.user import User + +router = APIRouter() + + +@router.get("/{match_id}", response_model=Match) +def read_match( + *, + db: Session = Depends(deps.get_db), + match_id: int, + current_user: User = Depends(deps.get_current_active_user), +) -> Any: + """ + Get match by id. + """ + match = crud.match.get( + db=db, id=match_id + ) + if not match: + raise HTTPException(status_code=404, detail="match not found") + if not crud.user.is_superuser(current_user): + raise HTTPException(status_code=400, detail="Not enough permissions") + return match + + +@router.post("/", response_model=Match) +def create_match( + *, + db: Session = Depends(deps.get_db), + match_in: MatchCreate, + current_user: User = Depends(deps.get_current_active_superuser), +) -> Any: + """ + Create new user. + """ + + match = crud.match.create(db, obj_in=match_in) + + + return match + + +@router.get("/", response_model=List[Match]) +def get_matchs( + db: Session = Depends(deps.get_db), + skip: int = 0, + limit: int = 100, + current_user: User = Depends(deps.get_current_active_superuser), +) -> Any: + """ + Retrieve all matchs. + """ + match = crud.match.get_multi(db, skip=skip, limit=limit) + return match + + +@router.post("/{match_id}", response_model=Match) +def update_match( + *, + db: Session = Depends(deps.get_db), + match_id: int, + match_in: MatchUpdate, + current_user: User = Depends(deps.get_current_active_user), +) -> Any: + """ + Update match. + """ + + match = crud.match.get(db=db, id=match_id) + if not match: + raise HTTPException(status_code=404, detail="Match not found") + + match = crud.match.update(db=db, db_obj=match, obj_in=match_in) + return match diff --git a/app/api/api_v1/endpoints/matchday.py b/backend/app/api/api_v1/endpoints/matchday.py similarity index 91% rename from app/api/api_v1/endpoints/matchday.py rename to backend/app/api/api_v1/endpoints/matchday.py index ce32531..e1d430e 100644 --- a/app/api/api_v1/endpoints/matchday.py +++ b/backend/app/api/api_v1/endpoints/matchday.py @@ -3,12 +3,12 @@ from typing import Any, List from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session -from app import crud -from app.api import deps +from backend.app import crud +from backend.app.api import deps -from app.models.matchday import Matchday, MatchdayCreate, MatchdayUpdate, \ +from backend.app.models.matchday import Matchday, MatchdayCreate, MatchdayUpdate, \ MatchdayWithPlayers -from app.models.user import User +from backend.app.models.user import User router = APIRouter() diff --git a/app/api/api_v1/endpoints/player.py b/backend/app/api/api_v1/endpoints/player.py similarity index 89% rename from app/api/api_v1/endpoints/player.py rename to backend/app/api/api_v1/endpoints/player.py index 0078c02..4aceed6 100644 --- a/app/api/api_v1/endpoints/player.py +++ b/backend/app/api/api_v1/endpoints/player.py @@ -3,12 +3,12 @@ from typing import Any, List from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session -from app import crud -from app.api import deps +from backend.app import crud +from backend.app.api import deps -from app.models.player import Player, PlayerCreate, PlayerUpdate, \ +from backend.app.models.player import Player, PlayerCreate, PlayerUpdate, \ PlayerTeamsMatchdays -from app.models.user import User +from backend.app.models.user import User router = APIRouter() diff --git a/app/api/api_v1/endpoints/team.py b/backend/app/api/api_v1/endpoints/team.py similarity index 86% rename from app/api/api_v1/endpoints/team.py rename to backend/app/api/api_v1/endpoints/team.py index 2650111..a848d3b 100644 --- a/app/api/api_v1/endpoints/team.py +++ b/backend/app/api/api_v1/endpoints/team.py @@ -4,10 +4,10 @@ from fastapi import APIRouter, Depends, HTTPException from sqlalchemy.orm import Session -from app import crud -from app.api import deps -from app.models.team import Team, TeamCreate, TeamWithPlayers -from app.models.user import User +from backend.app import crud +from backend.app.api import deps +from backend.app.models.team import Team, TeamCreate, TeamWithPlayers +from backend.app.models.user import User router = APIRouter() @@ -40,7 +40,7 @@ def get_teams( """ Retrieve teams. """ - team = crud.team.get_multi( db, skip=skip, limit=limit) + team = crud.team.get_multi(db, skip=skip, limit=limit) return team diff --git a/app/api/api_v1/endpoints/users.py b/backend/app/api/api_v1/endpoints/users.py similarity index 92% rename from app/api/api_v1/endpoints/users.py rename to backend/app/api/api_v1/endpoints/users.py index 6e4c92d..9445fe8 100644 --- a/app/api/api_v1/endpoints/users.py +++ b/backend/app/api/api_v1/endpoints/users.py @@ -5,10 +5,10 @@ from fastapi.encoders import jsonable_encoder from pydantic.networks import EmailStr from sqlalchemy.orm import Session -from app import crud, models -from app.api import deps -from app.core.config import settings -from app.models.user import UserUpdate, User, UserCreate +from backend.app import crud +from backend.app.api import deps +from backend.app.core.config import settings +from backend.app.models.user import UserUpdate, User, UserCreate router = APIRouter() diff --git a/app/api/deps.py b/backend/app/api/deps.py similarity index 83% rename from app/api/deps.py rename to backend/app/api/deps.py index 59d2b78..84e475a 100644 --- a/app/api/deps.py +++ b/backend/app/api/deps.py @@ -6,12 +6,12 @@ from jose import jwt from pydantic import ValidationError from sqlalchemy.orm import Session -from app import crud -from app.models.token import TokenPayload -from app.models.user import User -from app.core import security -from app.core.config import settings -from app.db.session import SessionLocal +from backend.app import crud +from backend.app.models.token import TokenPayload +from backend.app.models.user import User +from backend.app.core import security +from backend.app.core.config import settings +from backend.app.db.session import SessionLocal reusable_oauth2 = OAuth2PasswordBearer( tokenUrl=f"{settings.API_V1_STR}/login/access-token" diff --git a/app/core/__init__.py b/backend/app/core/__init__.py similarity index 100% rename from app/core/__init__.py rename to backend/app/core/__init__.py diff --git a/app/core/config.py b/backend/app/core/config.py similarity index 100% rename from app/core/config.py rename to backend/app/core/config.py diff --git a/app/core/security.py b/backend/app/core/security.py similarity index 91% rename from app/core/security.py rename to backend/app/core/security.py index cdede6c..5a378ba 100644 --- a/app/core/security.py +++ b/backend/app/core/security.py @@ -4,7 +4,7 @@ from typing import Any, Union from jose import jwt from passlib.context import CryptContext -from app.core.config import settings +from backend.app.core.config import settings pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") diff --git a/app/crud/__init__.py b/backend/app/crud/__init__.py similarity index 77% rename from app/crud/__init__.py rename to backend/app/crud/__init__.py index 7275570..da0da80 100644 --- a/app/crud/__init__.py +++ b/backend/app/crud/__init__.py @@ -2,3 +2,4 @@ from .crud_user import user from .crud_player import player from .crud_team import team from .crud_matchday import matchday +from .crud_match import match diff --git a/app/crud/base.py b/backend/app/crud/base.py similarity index 95% rename from app/crud/base.py rename to backend/app/crud/base.py index 83ef4a0..f686c03 100644 --- a/app/crud/base.py +++ b/backend/app/crud/base.py @@ -5,7 +5,7 @@ from pydantic import BaseModel from sqlalchemy.orm import Session from sqlmodel import select -from app.db.base_class import Base +from backend.app.db.base_class import Base ModelType = TypeVar("ModelType", bound=Base) CreateSchemaType = TypeVar("CreateSchemaType", bound=BaseModel) diff --git a/backend/app/crud/crud_match.py b/backend/app/crud/crud_match.py new file mode 100644 index 0000000..8e2bea4 --- /dev/null +++ b/backend/app/crud/crud_match.py @@ -0,0 +1,19 @@ +from sqlalchemy.orm import Session +from backend.app.crud.base import CRUDBase +from backend.app.models.match import Match, MatchCreate, MatchUpdate + + +class CRUDMatch(CRUDBase[Match, MatchCreate, MatchUpdate]): + + def create(self, db: Session, *, obj_in: MatchCreate) -> Match: + db_obj = Match( + **obj_in.dict() + ) + db.add(db_obj) + db.commit() + db.refresh(db_obj) + return db_obj + + + +match = CRUDMatch(Match) diff --git a/app/crud/crud_matchday.py b/backend/app/crud/crud_matchday.py similarity index 82% rename from app/crud/crud_matchday.py rename to backend/app/crud/crud_matchday.py index 5ae875e..bdadaf9 100644 --- a/app/crud/crud_matchday.py +++ b/backend/app/crud/crud_matchday.py @@ -1,11 +1,11 @@ -from typing import Any, Dict, Union, Optional +from typing import Any from sqlmodel import select from sqlalchemy.orm import Session -from app.crud import player as crud_player -from app.crud.base import CRUDBase -from app.models.matchday import Matchday, MatchdayCreate, MatchdayUpdate +from backend.app.crud import player as crud_player +from backend.app.crud.base import CRUDBase +from backend.app.models.matchday import Matchday, MatchdayCreate, MatchdayUpdate class CRUDMatchday(CRUDBase[Matchday, MatchdayCreate, MatchdayUpdate]): diff --git a/app/crud/crud_player.py b/backend/app/crud/crud_player.py similarity index 79% rename from app/crud/crud_player.py rename to backend/app/crud/crud_player.py index 5a60cef..4f834b8 100644 --- a/app/crud/crud_player.py +++ b/backend/app/crud/crud_player.py @@ -1,9 +1,9 @@ -from typing import Any, Dict, Optional, Union +from typing import Optional from sqlalchemy.orm import Session -from app.crud.base import CRUDBase -from app.models.player import Player, PlayerCreate, PlayerUpdate +from backend.app.crud.base import CRUDBase +from backend.app.models.player import Player, PlayerCreate, PlayerUpdate class CRUDPlayer(CRUDBase[Player, PlayerCreate, PlayerUpdate]): diff --git a/app/crud/crud_team.py b/backend/app/crud/crud_team.py similarity index 78% rename from app/crud/crud_team.py rename to backend/app/crud/crud_team.py index 6e7162c..7dbdbb4 100644 --- a/app/crud/crud_team.py +++ b/backend/app/crud/crud_team.py @@ -1,11 +1,8 @@ -from typing import Any, Dict, Optional, Union, List - from sqlalchemy.orm import Session -from sqlmodel import select -from app.crud.base import CRUDBase -from app.crud import player as crud_player -from app.models.team import Team, TeamCreate, TeamUpdate +from backend.app.crud.base import CRUDBase +from backend.app.crud import player as crud_player +from backend.app.models.team import Team, TeamCreate, TeamUpdate class CRUDTeam(CRUDBase[Team, TeamCreate, TeamUpdate]): diff --git a/app/crud/crud_user.py b/backend/app/crud/crud_user.py similarity index 87% rename from app/crud/crud_user.py rename to backend/app/crud/crud_user.py index 514182c..3ee3757 100644 --- a/app/crud/crud_user.py +++ b/backend/app/crud/crud_user.py @@ -2,9 +2,9 @@ from typing import Any, Dict, Optional, Union from sqlalchemy.orm import Session -from app.core.security import get_password_hash, verify_password -from app.crud.base import CRUDBase -from app.models.user import User, UserCreate, UserUpdate +from backend.app.core.security import get_password_hash, verify_password +from backend.app.crud.base import CRUDBase +from backend.app.models.user import User, UserCreate, UserUpdate diff --git a/app/db/__init__.py b/backend/app/db/__init__.py similarity index 100% rename from app/db/__init__.py rename to backend/app/db/__init__.py diff --git a/backend/app/db/base.py b/backend/app/db/base.py new file mode 100644 index 0000000..9de7494 --- /dev/null +++ b/backend/app/db/base.py @@ -0,0 +1,4 @@ +from backend.app.db.base_class import Base # noqa + +# from app.models.item import Item # noqa +from backend.app.models.user import User # noqa diff --git a/app/db/base_class.py b/backend/app/db/base_class.py similarity index 100% rename from app/db/base_class.py rename to backend/app/db/base_class.py diff --git a/app/db/init_db.py b/backend/app/db/init_db.py similarity index 80% rename from app/db/init_db.py rename to backend/app/db/init_db.py index 78d8445..e4832f2 100644 --- a/app/db/init_db.py +++ b/backend/app/db/init_db.py @@ -1,17 +1,16 @@ from sqlalchemy.orm import Session -from app import crud -from app.core.config import settings -from app.db import base # noqa: F401 +from backend.app import crud +from backend.app.core.config import settings # make sure all SQL Alchemy models are imported (app.db.base) before initializing DB # otherwise, SQL Alchemy might fail to initialize relationships properly # for more details: https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/28 -from app.db.base_class import Base -from app.db.session import engine -from app.models.player import Player, PlayerCreate -from app.models.team import TeamCreate, TeamWithPlayers -from app.models.user import UserCreate +from backend.app.db.base_class import Base +from backend.app.db.session import engine +from backend.app.models.player import PlayerCreate +from backend.app.models.team import TeamWithPlayers +from backend.app.models.user import UserCreate def init_db(db: Session) -> None: diff --git a/app/db/session.py b/backend/app/db/session.py similarity index 84% rename from app/db/session.py rename to backend/app/db/session.py index 1d434f2..b8299bb 100644 --- a/app/db/session.py +++ b/backend/app/db/session.py @@ -1,7 +1,7 @@ from sqlalchemy.orm import sessionmaker -from app.core.config import settings +from backend.app.core.config import settings from sqlmodel import create_engine, SQLModel diff --git a/app/main.py b/backend/app/main.py similarity index 70% rename from app/main.py rename to backend/app/main.py index 3a1b06d..53446df 100644 --- a/app/main.py +++ b/backend/app/main.py @@ -1,15 +1,13 @@ import logging -import uvicorn from fastapi import FastAPI -from loguru import logger from starlette.middleware.cors import CORSMiddleware -from app.api.api_v1.api import api_router -from app.core.config import settings -from app.db.init_db import init_db -from app.db.session import SessionLocal, create_db_and_tables -from app.utils import configure_log_handler +from backend.app.api.api_v1.api import api_router +from backend.app.core.config import settings +from backend.app.db.init_db import init_db +from backend.app.db.session import SessionLocal, create_db_and_tables +from backend.app.utils import configure_log_handler db = SessionLocal() configure_log_handler(log_level=logging.DEBUG) diff --git a/app/models/__init__.py b/backend/app/models/__init__.py similarity index 50% rename from app/models/__init__.py rename to backend/app/models/__init__.py index 1631f42..ea08211 100644 --- a/app/models/__init__.py +++ b/backend/app/models/__init__.py @@ -1,6 +1,6 @@ -from app.models.matchday import Matchday, MatchdayWithPlayers -from app.models.player import Player, PlayerTeamsMatchdays -from app.models.team import Team, TeamWithPlayers +from backend.app.models.matchday import Matchday, MatchdayWithPlayers +from backend.app.models.player import Player, PlayerTeamsMatchdays +from backend.app.models.team import Team, TeamWithPlayers Player.update_forward_refs(Team=Team, Matchday=Matchday) diff --git a/backend/app/models/match.py b/backend/app/models/match.py new file mode 100644 index 0000000..cbbbd14 --- /dev/null +++ b/backend/app/models/match.py @@ -0,0 +1,30 @@ +from typing import Optional + +from sqlmodel import SQLModel, Field + +from backend.app.db.base_class import Base + + +class MatchBase(SQLModel): + team_1_result: int | None + team_2_result: int | None + + +class Match(MatchBase, Base, table=True): + team_1: Optional[int] = Field(default=None, foreign_key="team.id") + team_2: Optional[int] = Field(default=None, foreign_key="team.id") + winner: Optional[int] = Field(default=None, foreign_key="team.id") + day: Optional[int] = Field(default=None, foreign_key="matchday.id") + + +class MatchCreate(MatchBase): + team_1: Optional[int] + team_2: Optional[int] + winner: Optional[int] + day: Optional[int] + +class MatchUpdate(MatchBase): + team_1: Optional[int] + team_2: Optional[int] + winner: Optional[int] + day: Optional[int] diff --git a/app/models/matchday.py b/backend/app/models/matchday.py similarity index 76% rename from app/models/matchday.py rename to backend/app/models/matchday.py index 46fce98..a4bfa05 100644 --- a/app/models/matchday.py +++ b/backend/app/models/matchday.py @@ -1,14 +1,14 @@ -from datetime import date, datetime +from datetime import date from typing import List, Optional, TYPE_CHECKING from sqlalchemy import Date from sqlmodel import SQLModel, Relationship, Field, Column, func -from app.db.base_class import Base -from app.models.matchdayplayer import MatchdayPlayerLink +from backend.app.db.base_class import Base +from backend.app.models.matchdayplayer import MatchdayPlayerLink if TYPE_CHECKING: - from app.models.player import Player + from backend.app.models.player import Player class MatchdayBase(SQLModel): diff --git a/app/models/matchdayplayer.py b/backend/app/models/matchdayplayer.py similarity index 100% rename from app/models/matchdayplayer.py rename to backend/app/models/matchdayplayer.py diff --git a/app/models/msg.py b/backend/app/models/msg.py similarity index 100% rename from app/models/msg.py rename to backend/app/models/msg.py diff --git a/app/models/player.py b/backend/app/models/player.py similarity index 72% rename from app/models/player.py rename to backend/app/models/player.py index 8964612..285ae9d 100644 --- a/app/models/player.py +++ b/backend/app/models/player.py @@ -1,13 +1,13 @@ -from typing import Optional, List, TYPE_CHECKING +from typing import List, TYPE_CHECKING from sqlmodel import SQLModel, Field, Relationship -from app.db.base_class import Base +from backend.app.db.base_class import Base -from app.models.matchdayplayer import MatchdayPlayerLink -from app.models.teamplayers import TeamPlayerLink +from backend.app.models.matchdayplayer import MatchdayPlayerLink +from backend.app.models.teamplayers import TeamPlayerLink if TYPE_CHECKING: - from app.models import Team, Matchday + from backend.app.models import Team, Matchday class PlayerBase(SQLModel): firstname: str = Field(nullable=False) lastname: str = Field(nullable=False) diff --git a/app/models/team.py b/backend/app/models/team.py similarity index 76% rename from app/models/team.py rename to backend/app/models/team.py index 14d53cd..73a8c4a 100644 --- a/app/models/team.py +++ b/backend/app/models/team.py @@ -2,12 +2,12 @@ from typing import Optional, List, TYPE_CHECKING from sqlmodel import SQLModel, Field, Relationship -from app.db.base_class import Base +from backend.app.db.base_class import Base -from app.models.teamplayers import TeamPlayerLink +from backend.app.models.teamplayers import TeamPlayerLink if TYPE_CHECKING: - from app.models.player import Player + from backend.app.models.player import Player class TeamBase(SQLModel): teamname: Optional[str] = Field(nullable=False) diff --git a/app/models/teamplayers.py b/backend/app/models/teamplayers.py similarity index 100% rename from app/models/teamplayers.py rename to backend/app/models/teamplayers.py diff --git a/app/models/token.py b/backend/app/models/token.py similarity index 100% rename from app/models/token.py rename to backend/app/models/token.py diff --git a/app/models/user.py b/backend/app/models/user.py similarity index 89% rename from app/models/user.py rename to backend/app/models/user.py index 6f5b089..b748361 100644 --- a/app/models/user.py +++ b/backend/app/models/user.py @@ -2,7 +2,7 @@ from typing import Optional from pydantic import EmailStr from sqlmodel import SQLModel, Field -from app.db.base_class import Base +from backend.app.db.base_class import Base class UserBase(SQLModel): diff --git a/app/schemas/__init__.py b/backend/app/schemas/__init__.py similarity index 100% rename from app/schemas/__init__.py rename to backend/app/schemas/__init__.py diff --git a/app/schemas/match.py b/backend/app/schemas/match.py similarity index 100% rename from app/schemas/match.py rename to backend/app/schemas/match.py diff --git a/app/schemas/matchday.py b/backend/app/schemas/matchday.py similarity index 100% rename from app/schemas/matchday.py rename to backend/app/schemas/matchday.py diff --git a/app/utils.py b/backend/app/utils.py similarity index 95% rename from app/utils.py rename to backend/app/utils.py index 9577423..67dda88 100644 --- a/app/utils.py +++ b/backend/app/utils.py @@ -1,4 +1,3 @@ -import logging from datetime import datetime, timedelta from pathlib import Path from typing import Any, Dict, Optional @@ -7,7 +6,7 @@ import emails from emails.template import JinjaTemplate from jose import jwt -from app.core.config import settings +from backend.app.core.config import settings import sys import logging from loguru import logger diff --git a/debug_run.py b/backend/debug_run.py similarity index 84% rename from debug_run.py rename to backend/debug_run.py index c68ab44..dd8375e 100644 --- a/debug_run.py +++ b/backend/debug_run.py @@ -1,8 +1,6 @@ import uvicorn from loguru import logger -from app.main import app - def main(): uvicorn.run("debug_run:app", host="0.0.0.0", port=1234, reload=True) diff --git a/floorball.db b/backend/floorball.db similarity index 86% rename from floorball.db rename to backend/floorball.db index 66e9dff..83d70e3 100644 Binary files a/floorball.db and b/backend/floorball.db differ diff --git a/poetry.lock b/backend/poetry.lock similarity index 100% rename from poetry.lock rename to backend/poetry.lock diff --git a/pyproject.toml b/backend/pyproject.toml similarity index 100% rename from pyproject.toml rename to backend/pyproject.toml diff --git a/tests/__init__.py b/backend/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to backend/tests/__init__.py diff --git a/tests/test_floorball_stats.py b/backend/tests/test_floorball_stats.py similarity index 57% rename from tests/test_floorball_stats.py rename to backend/tests/test_floorball_stats.py index 81edb8a..955e9fc 100644 --- a/tests/test_floorball_stats.py +++ b/backend/tests/test_floorball_stats.py @@ -1,4 +1,4 @@ -from app import __version__ +from backend.app import __version__ def test_version(): diff --git a/tox.ini b/backend/tox.ini similarity index 100% rename from tox.ini rename to backend/tox.ini