refactor: P3b 表单层迁入 src/modules/ → schema.py(23 表单)
- 20 个模块 schema.py(auth/system/association/cms 等) - 合并 2 组:dict+dict_item、config+config_item - 重写 import:base_form/fields→src.common.forms、模型引用→src.modules - application/forms/ 全部替换为 shim 【教训】codemod 首次运行崩溃后重跑,读到了已替换的 shim 导致 9 个 schema.py 自引用损坏;已从 git(P3a 提交)恢复原版重跑修复 【验收】32 表单类;应用启动;pytest 5 passed Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
6de4f3bef2
commit
2586c0aace
@@ -1,51 +1,8 @@
|
||||
"""
|
||||
用户角色表单验证模块
|
||||
兼容 shim(绞杀者迁移期间保留)
|
||||
=============================================================
|
||||
|
||||
提供用户角色相关的表单验证功能,包括:
|
||||
- 用户角色分配表单验证
|
||||
表单已迁移至 src.modules.association.user_role.schema。
|
||||
本文件仅作兼容转发,最终在 P7(切尾)阶段删除。
|
||||
"""
|
||||
|
||||
from wtforms import IntegerField
|
||||
from wtforms.fields.choices import SelectMultipleField
|
||||
from wtforms.validators import DataRequired, NumberRange, Optional
|
||||
|
||||
from application.forms.base_form import BaseForm
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 用户角色表单验证
|
||||
# ============================================================
|
||||
|
||||
class UserRoleForm(BaseForm):
|
||||
"""
|
||||
用户角色表单验证类
|
||||
|
||||
用于用户分配角色权限时的数据验证。
|
||||
|
||||
Attributes:
|
||||
userId: 用户ID(必填,必须大于0)
|
||||
roleIds: 角色ID列表(可选,多个角色ID)
|
||||
"""
|
||||
|
||||
# 用户ID
|
||||
userId = IntegerField(
|
||||
label='用户ID',
|
||||
validators=[
|
||||
DataRequired(message='用户ID不能为空'),
|
||||
NumberRange(min=1, message='用户ID必须大于0')
|
||||
],
|
||||
description='要分配角色的用户ID'
|
||||
)
|
||||
|
||||
# 角色ID列表
|
||||
roleIds = SelectMultipleField(
|
||||
label='角色ID列表',
|
||||
validators=[
|
||||
Optional(),
|
||||
],
|
||||
coerce=int,
|
||||
choices=[],
|
||||
validate_choice=False,
|
||||
description='分配的角色ID列表'
|
||||
)
|
||||
from src.modules.association.user_role.schema import * # noqa: F401,F403
|
||||
|
||||
Reference in New Issue
Block a user