org-archive: в ручке обновления org доступно in_active, фильтры в get на is_active и is_ssp
This commit is contained in:
parent
1a533f46f1
commit
1db445d63d
@ -18,6 +18,8 @@ router = APIRouter(prefix="/org-unit", tags=["ssp"])
|
||||
async def org_unit_list(
|
||||
offset: int = 0,
|
||||
limit: int = 100,
|
||||
is_active: bool | None = None,
|
||||
is_ssp: bool | None = None,
|
||||
load_users_count: bool = False,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: AppUser = Depends(require_admin),
|
||||
@ -29,6 +31,9 @@ async def org_unit_list(
|
||||
offset=offset,
|
||||
limit=limit,
|
||||
load_users=load_users_count,
|
||||
is_active=is_active,
|
||||
is_ssp=is_ssp,
|
||||
|
||||
)
|
||||
return BaseListResponse(
|
||||
result=[
|
||||
|
||||
@ -155,7 +155,10 @@ class UserAdminListResponse(UserInDB):
|
||||
"role_id": data.role_id,
|
||||
}
|
||||
try:
|
||||
result["org_units"] = data.org_units
|
||||
result["org_units"] = [
|
||||
ou for ou in data.org_units
|
||||
if ou.is_active
|
||||
]
|
||||
except MissingGreenlet:
|
||||
pass
|
||||
|
||||
@ -227,6 +230,7 @@ class OrgUnitBaseSchema(BaseModel):
|
||||
class OrgUnitUpdateSchema(OrgUnitBaseSchema):
|
||||
title: Optional[str] = None
|
||||
is_ssp: Optional[bool] = None
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ class UserService:
|
||||
if (had_many_ssp_role and not has_many_ssp_role_now) or is_executor_to_dfip_transition:
|
||||
await self.user_repo.clear_many_ssp(user_id)
|
||||
if user_data.load_orgs:
|
||||
updated = self.user_repo.get(
|
||||
updated = await self.user_repo.get(
|
||||
user_id=user_id,
|
||||
load_orgs=user_data.load_orgs,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user