Skip to content
Snippets Groups Projects
Commit f3019db1 authored by robban64's avatar robban64
Browse files

fix: server response and small changes in client

parent 23f648da
No related branches found
No related tags found
1 merge request!48fix: server response and small changes in client
Pipeline #39223 passed
import { City } from './City'
export interface Competition {
name: string
id: number
city: City
city_id: number
year: number
}
......@@ -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)
......
......@@ -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)}>
......
......@@ -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}
......
......@@ -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:
......
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)
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment