Skip to content

Commit

Permalink
Tried with schemas
Browse files Browse the repository at this point in the history
Tried to fix the schemas. Will need to revisit all changes on this branch.
  • Loading branch information
KingPhilip14 committed Sep 16, 2023
1 parent c637243 commit 89b0c02
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion server/models/university.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sqlalchemy import Integer, CheckConstraint, String
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.orm import relationship, Mapped, mapped_column
import team

from .base import Base

Expand All @@ -8,3 +9,4 @@ class University(Base):
__tablename__: str = 'university'
uni_id: Mapped[int] = mapped_column(Integer(), primary_key=True, autoincrement=True)
uni_name: Mapped[str] = mapped_column(String(100), CheckConstraint("uni_name != ''"), nullable=False, unique=True)
teams: Mapped[list[team.Team]] = relationship(back_populates='teams')
4 changes: 2 additions & 2 deletions server/schemas/run_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class Config:


class RunSchema(RunBase):
group_runs: list[group_run_schema.GroupRunBase] = []
errors: list[errors_schema.ErrorsBase] = []
group_run: group_run_schema.GroupRunBase
errors: errors_schema.ErrorsBase
turn_tables: list[turn_table_schema.TurnTableBase] = []
5 changes: 3 additions & 2 deletions server/schemas/team_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class Config:
from_attributes = True


# University <-> Team: Many to One
class TeamSchema(TeamBase):
uni_id: list[university_schema.UniversityBase] = []
team_type_id: list[team_type_schema.TeamTypeBase] = []
uni_id: int = university_schema.UniversityBase
team_type_id: int = team_type_schema.TeamTypeBase
submissions: list[submission_schema.SubmissionBase] = []
2 changes: 1 addition & 1 deletion server/schemas/turn_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class Config:


class TurnTableSchema(TurnTableBase):
runs: list[run_schema.RunBase] = []
run: run_schema.RunBase
5 changes: 3 additions & 2 deletions server/schemas/university_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations
from pydantic import BaseModel
import team_type_schema
import team_schema


class UniversityBase(BaseModel):
Expand All @@ -11,5 +11,6 @@ class Config:
from_attributes = True


# University <-> Team: Many to One
class UniversitySchema(UniversityBase):
team_types: list[team_type_schema.TeamTypeBase] = []
teams: list[team_schema.TeamBase] = []

0 comments on commit 89b0c02

Please sign in to comment.