diff --git a/client/src/interfaces/Competition.ts b/client/src/interfaces/Competition.ts index 7a9c7032cf036d71cfcafe322f92b9e491966b3b..d36d97da1bc824f996fb7c46e88eaa71aa720995 100644 --- a/client/src/interfaces/Competition.ts +++ b/client/src/interfaces/Competition.ts @@ -1,8 +1,6 @@ -import { City } from './City' - export interface Competition { name: string id: number - city: City + city_id: number year: number } diff --git a/client/src/pages/admin/components/AddCompetition.tsx b/client/src/pages/admin/components/AddCompetition.tsx index d80195e58adec0c8dfd30d1a636481671ab4e7a5..b67714babe4c1d57040684f1bcc1e3cfabd82836 100644 --- a/client/src/pages/admin/components/AddCompetition.tsx +++ b/client/src/pages/admin/components/AddCompetition.tsx @@ -59,7 +59,6 @@ const AddCompetition: React.FC = (props: any) => { name: values.model.name, year: values.model.year, city_id: selectedCity?.id as number, - style_id: 1, } await axios .post<ServerResponse>('/competitions', params) diff --git a/client/src/pages/admin/components/CompetitionManager.tsx b/client/src/pages/admin/components/CompetitionManager.tsx index ff73a9945cb0b45370d0d01c4e8e9dc5daae63eb..2acce64b8b11b33e089f15f8d34b1472de2b8898 100644 --- a/client/src/pages/admin/components/CompetitionManager.tsx +++ b/client/src/pages/admin/components/CompetitionManager.tsx @@ -152,7 +152,7 @@ const CompetitionManager: React.FC = (props: any) => { {row.name} </Button> </TableCell> - <TableCell align="right">{cities.find((city) => city.id === row.city.id)?.name || ''}</TableCell> + <TableCell align="right">{cities.find((city) => city.id === row.city_id)?.name || ''}</TableCell> <TableCell align="right">{row.year}</TableCell> <TableCell align="right"> <Button onClick={(event) => handleClick(event, row.id)}> diff --git a/client/src/pages/admin/components/UserManager.tsx b/client/src/pages/admin/components/UserManager.tsx index bc3d55d480a38cc4d0c92a56d84b3e2d7ae2bb18..7bea8713a8bda1c54ac7259cdd0915fc73bc86d9 100644 --- a/client/src/pages/admin/components/UserManager.tsx +++ b/client/src/pages/admin/components/UserManager.tsx @@ -136,8 +136,8 @@ const UserManager: React.FC = (props: any) => { <MenuItem value={noFilterText} onClick={() => handleFilterChange({ ...filterParams, roleId: undefined })}> {noFilterText} </MenuItem> - {cities && - cities.map((role) => ( + {roles && + roles.map((role) => ( <MenuItem key={role.name} value={role.name} diff --git a/server/app/core/dto.py b/server/app/core/dto.py index 3378a17bcad43e410331fadc31812982fd95563f..5eca79639858beaebfa9ebce9b2da8ebc06427bc 100644 --- a/server/app/core/dto.py +++ b/server/app/core/dto.py @@ -13,13 +13,13 @@ class AuthDTO: class UserDTO: api = Namespace("users") schema = rich_schemas.UserSchemaRich(many=False) - list_schema = rich_schemas.UserSchemaRich(many=True) + list_schema = schemas.UserSchema(many=True) class CompetitionDTO: api = Namespace("competitions") schema = rich_schemas.CompetitionSchemaRich(many=False) - list_schema = rich_schemas.CompetitionSchemaRich(many=True) + list_schema = schemas.CompetitionSchema(many=True) class SlideDTO: diff --git a/server/app/core/rich_schemas.py b/server/app/core/rich_schemas.py index f951048812cc8c190f49eabf5cfbcc75a5ec6827..e4dc4a8472ae63947198ef47c4ecb26465786356 100644 --- a/server/app/core/rich_schemas.py +++ b/server/app/core/rich_schemas.py @@ -1,7 +1,6 @@ import app.core.models as models import app.core.schemas as schemas from app.core import ma -from marshmallow import fields as fields2 from marshmallow_sqlalchemy import fields @@ -34,5 +33,3 @@ class CompetitionSchemaRich(RichSchema): city = fields.Nested(schemas.CitySchema, many=False) -class UserListSchema(ma.Schema): - users = fields2.Nested(UserSchemaRich, many=False) diff --git a/server/app/core/schemas.py b/server/app/core/schemas.py index 0450034ae28edf65f1559ebff7a5962336f1a954..26fba4693aef2e83592c74121b8e58ff49d9ce2a 100644 --- a/server/app/core/schemas.py +++ b/server/app/core/schemas.py @@ -70,3 +70,24 @@ class TeamSchema(BaseSchema): id = ma.auto_field() name = ma.auto_field() competition_id = ma.auto_field() + + +class UserSchema(BaseSchema): + class Meta(BaseSchema.Meta): + model = models.User + + id = ma.auto_field() + name = ma.auto_field() + email = ma.auto_field() + role_id = ma.auto_field() + city_id = ma.auto_field() + + +class CompetitionSchema(BaseSchema): + class Meta(BaseSchema.Meta): + model = models.Competition + + id = ma.auto_field() + name = ma.auto_field() + year = ma.auto_field() + city_id = ma.auto_field()