Label fixes, Websocket reconnects and more detailed court view cards.
This commit is contained in:
+11
-14
@@ -45,17 +45,14 @@ def create_tournament(db: Session, data: schemas.TournamentCreate):
|
||||
def get_tournaments(db: Session):
|
||||
return db.query(models.Tournament).all()
|
||||
|
||||
|
||||
def get_tournament(db: Session, tournament_id: str):
|
||||
return (
|
||||
db.query(models.Tournament)
|
||||
.filter(models.Tournament.id == tournament_id)
|
||||
.first()
|
||||
)
|
||||
|
||||
def get_tournament(db: Session, tournament_id: str, lock: bool = False):
|
||||
query = db.query(models.Tournament).filter(models.Tournament.id == tournament_id)
|
||||
if lock:
|
||||
query = query.with_for_update()
|
||||
return query.first()
|
||||
|
||||
def delete_tournament(db: Session, tournament_id: str) -> bool:
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return False
|
||||
db.delete(t)
|
||||
@@ -66,7 +63,7 @@ def delete_tournament(db: Session, tournament_id: str) -> bool:
|
||||
def update_tournament_details(
|
||||
db: Session, tournament_id: str, data: schemas.TournamentUpdate
|
||||
):
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return None
|
||||
|
||||
@@ -94,7 +91,7 @@ def get_teams(db: Session, tournament_id: str):
|
||||
|
||||
|
||||
def create_team(db: Session, tournament_id: str, team_data: schemas.TeamCreate):
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return None
|
||||
|
||||
@@ -110,7 +107,7 @@ def create_team(db: Session, tournament_id: str, team_data: schemas.TeamCreate):
|
||||
|
||||
|
||||
def update_tournament_teams(db: Session, tournament_id: str, new_team_names: list[str]):
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return None
|
||||
|
||||
@@ -125,7 +122,7 @@ def update_tournament_teams(db: Session, tournament_id: str, new_team_names: lis
|
||||
|
||||
|
||||
def delete_team(db: Session, tournament_id: str, team_id: int):
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return None
|
||||
team = db.get(models.Team, team_id)
|
||||
@@ -182,7 +179,7 @@ def delete_court(db: Session, court_id: int):
|
||||
|
||||
|
||||
def update_tournament_courts(db: Session, tournament_id: str, new_court_ids: list[int]):
|
||||
t = get_tournament(db, tournament_id)
|
||||
t = get_tournament(db, tournament_id, lock=True)
|
||||
if not t:
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user