修复(账号分配): 隐藏停用客服并校验发放目标

分配概览只返回启用中的客服;停用用户不能出现在客服列表或作为定量发放目标。
This commit is contained in:
yml
2026-11-26 20:44:01 +08:00
parent 98aa046c7e
commit 47cc15f8ad
2 changed files with 40 additions and 1 deletions
+39
View File
@@ -337,6 +337,45 @@ class TestAssignmentPools(_Base):
assert skin["commodity_name"] == "选项皮肤"
assert skin["account_count"] == 1
def test_assignment_summary_hides_inactive_support_users(self):
inactive = User(
username="deleted-support",
password_hash="h",
role="support",
is_active=False,
)
self.session.add(inactive)
self.session.commit()
result = assignments_summary(db=self.session, current=self.admin)
support_ids = {user["id"] for user in result["support_users"]}
assert self.support.id in support_ids
assert inactive.id not in support_ids
def test_dispatch_rejects_inactive_support(self):
inactive = User(
username="deleted-dispatch-target",
password_hash="h",
role="support",
is_active=False,
)
self.session.add(inactive)
self.session.commit()
with pytest.raises(HTTPException) as exc_info:
dispatch_assignments(
AssignmentDispatch(
assigned_to=inactive.id,
quantity=1,
),
db=self.session,
current=self.admin,
)
assert exc_info.value.status_code == 400
assert "已停用" in exc_info.value.detail
class TestAllMatchingAssign(_Base):
def test_assigns_every_matching_unassigned(self):
+1 -1
View File
@@ -1459,7 +1459,7 @@ def assignments_summary(
_assignable_account_filter(),
),
)
.filter(User.role == "support")
.filter(User.role == "support", User.is_active.is_(True))
.group_by(User.id, User.username)
.order_by(func.count(Account.id).desc())
.all()