generated from Luis/nextjs-python-web-template
Added AP get repository
This commit is contained in:
@@ -72,8 +72,11 @@ class Entity(EntityBase):
|
|||||||
|
|
||||||
# define a custom getter function for roles
|
# define a custom getter function for roles
|
||||||
@validator("roles", pre=True)
|
@validator("roles", pre=True)
|
||||||
def get_roles(cls, v: List[EntityRoles]) -> List[Role]:
|
def get_roles(cls, v: List[EntityRoles | Role]) -> List[Role]:
|
||||||
return [x.role for x in v]
|
if isinstance(v, list) and len(v) > 0 and isinstance(v[0], EntityRoles):
|
||||||
|
return [x.role for x in v] # type: ignore
|
||||||
|
else:
|
||||||
|
return v # type: ignore
|
||||||
|
|
||||||
|
|
||||||
#########################
|
#########################
|
||||||
|
|||||||
Reference in New Issue
Block a user