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:
commit
bf3896f2f0
@ -18,6 +18,8 @@ router = APIRouter(prefix="/org-unit", tags=["ssp"])
|
|||||||
async def org_unit_list(
|
async def org_unit_list(
|
||||||
offset: int = 0,
|
offset: int = 0,
|
||||||
limit: int = 100,
|
limit: int = 100,
|
||||||
|
is_active: bool | None = None,
|
||||||
|
is_ssp: bool | None = None,
|
||||||
load_users_count: bool = False,
|
load_users_count: bool = False,
|
||||||
db: AsyncSession = Depends(get_db),
|
db: AsyncSession = Depends(get_db),
|
||||||
current_user: AppUser = Depends(require_admin),
|
current_user: AppUser = Depends(require_admin),
|
||||||
@ -29,6 +31,9 @@ async def org_unit_list(
|
|||||||
offset=offset,
|
offset=offset,
|
||||||
limit=limit,
|
limit=limit,
|
||||||
load_users=load_users_count,
|
load_users=load_users_count,
|
||||||
|
is_active=is_active,
|
||||||
|
is_ssp=is_ssp,
|
||||||
|
|
||||||
)
|
)
|
||||||
return BaseListResponse(
|
return BaseListResponse(
|
||||||
result=[
|
result=[
|
||||||
|
|||||||
@ -155,7 +155,10 @@ class UserAdminListResponse(UserInDB):
|
|||||||
"role_id": data.role_id,
|
"role_id": data.role_id,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
result["org_units"] = data.org_units
|
result["org_units"] = [
|
||||||
|
ou for ou in data.org_units
|
||||||
|
if ou.is_active
|
||||||
|
]
|
||||||
except MissingGreenlet:
|
except MissingGreenlet:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -227,6 +230,7 @@ class OrgUnitBaseSchema(BaseModel):
|
|||||||
class OrgUnitUpdateSchema(OrgUnitBaseSchema):
|
class OrgUnitUpdateSchema(OrgUnitBaseSchema):
|
||||||
title: Optional[str] = None
|
title: Optional[str] = None
|
||||||
is_ssp: Optional[bool] = None
|
is_ssp: Optional[bool] = None
|
||||||
|
is_active: Optional[bool] = None
|
||||||
|
|
||||||
model_config = ConfigDict(from_attributes=True)
|
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:
|
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)
|
await self.user_repo.clear_many_ssp(user_id)
|
||||||
if user_data.load_orgs:
|
if user_data.load_orgs:
|
||||||
updated = self.user_repo.get(
|
updated = await self.user_repo.get(
|
||||||
user_id=user_id,
|
user_id=user_id,
|
||||||
load_orgs=user_data.load_orgs,
|
load_orgs=user_data.load_orgs,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user