Merge pull request 'org-archive: в ручке обновления org доступно in_active, фильтры в get на is_active и is_ssp' (#28) from org-archive into test

Reviewed-on: #28
This commit is contained in:
tsygankoviva 2026-06-03 17:40:23 +03:00
commit bf3896f2f0
3 changed files with 11 additions and 2 deletions

View File

@ -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=[

View File

@ -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)

View File

@ -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,
)