From 47cb1375a74de9fa43bfe8c50b41cfff9ec53226 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 08:20:46 +0000 Subject: [PATCH 1/3] =?UTF-8?q?remove=EF=BC=9A=E5=85=BC=E5=AE=B9=E8=BF=98?= =?UTF-8?q?=E6=B2=A1=E9=83=A8=E7=BD=B2=E9=99=84=E4=BB=B6=E5=AD=90=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧结构的环境里没有 brightrule_policy_attachment,统计附件数时 404 直接退出,一份都没删。 改为查不到就查旧的版本文档表(两者都随版本级联删除,删除顺序不变); 单份制度查询出错不再中断整批。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RKKVniLvsfBswNHAfKKTVi --- tools/redact/remove.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/redact/remove.py b/tools/redact/remove.py index 83f0f9c..d0f9986 100644 --- a/tools/redact/remove.py +++ b/tools/redact/remove.py @@ -55,11 +55,23 @@ def package_targets(api: Api, package: Path, apply: bool) -> List[Dict]: return list(found.values()) +def count_attachments(api: Api, version_id: str) -> int: + """版本下的附件数,只用于显示。附件子表(brightrule_policy_attachment)是后来的结构;还没部署它的环境里 + 同样的记录在旧的版本文档表(brightrule_policy_document)。两种都随版本级联删除,删除顺序不受影响。""" + for obj in ('brightrule_policy_attachment', 'brightrule_policy_document'): + try: + return len(api.find(obj, {'policy_version': version_id}, 'id')) + except ApiError as e: + if isinstance(e, AuthError) or 'not registered' not in str(e): + raise + return 0 + + def plan(api: Api, policy: Dict) -> List[tuple]: """删除顺序:条款(挂在制度上,限制删除)→ 版本(附件、以它为来源的关系随之删除)→ 制度。""" clauses = api.find('brightrule_clause', {'policy': policy['id']}, 'id') versions = api.find('brightrule_policy_version', {'policy': policy['id']}, 'id,version_no,version_status') - atts = sum(len(api.find('brightrule_policy_attachment', {'policy_version': v['id']}, 'id')) for v in versions) + atts = sum(count_attachments(api, v['id']) for v in versions) print(f' {policy.get("title")}({policy.get("policy_no") or "无编号"}):版本 {len(versions)} 个、附件 {atts} 个、条款 {len(clauses)} 条') return ([('brightrule_clause', c['id']) for c in clauses] + [('brightrule_policy_version', v['id']) for v in versions] @@ -91,10 +103,10 @@ def main(argv: Optional[Sequence[str]] = None) -> int: progress = Progress(len(policies)) for p in policies: print(progress.next(), end='') - steps = plan(api, p) - if not args.apply: - continue try: + steps = plan(api, p) + if not args.apply: + continue for obj, rid in steps: api.delete(obj, rid) print(' 已删除') From f9d1a3cacba6fa465de601d7b562a34c3d8f5045 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 09:24:31 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=B6=E5=BA=A6=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E3=80=81=E9=99=84=E4=BB=B6=EF=BC=9A=E6=95=B4=E7=90=86=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=20/=20=E7=BC=96=E8=BE=91=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 表单只放人填的字段:版本信息、正文(整行);原件保留给后期用,放在最后、默认折叠。 条号索引、字数、token、内容哈希由导入工具维护,不在表单里。字段下的提示改为给填表人 看的短句(对象字段的 description 写给 AI,不变)。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RKKVniLvsfBswNHAfKKTVi --- src/views/policy-attachment.view.ts | 33 +++++++++++++++++++++++++++ src/views/policy-version.view.ts | 35 +++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/src/views/policy-attachment.view.ts b/src/views/policy-attachment.view.ts index bc2d7fd..bed1fd7 100644 --- a/src/views/policy-attachment.view.ts +++ b/src/views/policy-attachment.view.ts @@ -5,6 +5,39 @@ import { PolicyAttachment } from '../objects/policy-attachment.object.js'; // and loading it for every row costs the page. const policyAttachmentViews: UI.View = { object: PolicyAttachment.name, + // 表单只放人填的字段:所属制度、现行由所属版本自动带出;字数、token、哈希由导入工具维护。 + // 原件现阶段不上传,字段保留给后期用,放在最后、默认折叠。helpText 是给填表的人看的短提示。 + form: { + type: 'simple', + sections: [ + { + name: 'attachment_info', + label: '附件', + columns: 2, + fields: [ + 'policy_version', + { field: 'label', helpText: '原文里的编号,如「附件1」' }, + { field: 'title', helpText: '附件自己的名称,不带制度名' }, + { field: 'attachment_class', helpText: '规范性附件和正文一起作为答复依据' }, + { field: 'sort_no', helpText: '先后顺序:1、2、3…' }, + ], + }, + { + name: 'attachment_body', + label: '附件正文', + columns: 1, + fields: [{ field: 'body_md', span: 'full', helpText: '规范性附件的全文(Markdown,已脱敏);表单类可以不填' }], + }, + { + name: 'attachment_original', + label: '原件', + columns: 1, + collapsible: true, + collapsed: true, + fields: [{ field: 'original_file', helpText: '现阶段不上传' }], + }, + ], + }, list: { label: '全部附件', type: 'grid', diff --git a/src/views/policy-version.view.ts b/src/views/policy-version.view.ts index 83194a7..32d4787 100644 --- a/src/views/policy-version.view.ts +++ b/src/views/policy-version.view.ts @@ -3,6 +3,41 @@ import { PolicyVersion } from '../objects/policy-version.object.js'; const policyVersionViews: UI.View = { object: PolicyVersion.name, + // 新建 / 编辑表单只放人填的字段。条号索引、字数、token 估算、内容哈希由导入工具(tools/redact)维护,不在表单里。 + // 正文原件现阶段不上传(系统里只存脱敏后的文字),字段保留给后期用,放在最后、默认折叠。 + // helpText 是给填表的人看的短提示;对象字段的 description 写给 AI,表单里不重复显示。 + form: { + type: 'simple', + sections: [ + { + name: 'version_info', + label: '版本信息', + columns: 2, + fields: [ + 'policy', + 'title', + { field: 'version_no', helpText: '通常用发文文号' }, + 'effective_date', + { field: 'version_status', helpText: '核对后在「待发布版本」里设为现行' }, + { field: 'change_note', span: 'full' }, + ], + }, + { + name: 'version_body', + label: '正文', + columns: 1, + fields: [{ field: 'body_md', span: 'full', helpText: '脱敏后的正文(Markdown):条文以 **第X条** 开头,章节用 ## 标题' }], + }, + { + name: 'version_original', + label: '原件', + columns: 1, + collapsible: true, + collapsed: true, + fields: [{ field: 'original_file', helpText: '现阶段不上传' }], + }, + ], + }, list: { label: '全部版本', type: 'grid', From 8355e32bbff1a348f702a3a9e8719b20f69a8621 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 09:27:46 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E5=86=8D=E6=95=B4?= =?UTF-8?q?=E7=90=86=EF=BC=9A=E5=AD=97=E6=AE=B5=E4=B8=A4=E4=B8=A4=E6=88=90?= =?UTF-8?q?=E5=AF=B9=E3=80=81=E6=AD=A3=E6=96=87=E7=B4=A7=E6=8E=A5=E5=85=B6?= =?UTF-8?q?=E5=90=8E=E3=80=81=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 去掉顶部重复的分组导航来源:主字段合成一组「版本信息」/「附件信息」,原件单独一组、默认折叠; - 版本号、版本状态等不再显示写给 AI 的说明(helpText 置空),只在正文下留一句怎么写; - 弹窗用 xl。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RKKVniLvsfBswNHAfKKTVi --- src/views/policy-attachment.view.ts | 28 ++++++++++++--------------- src/views/policy-version.view.ts | 30 +++++++++++++---------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/views/policy-attachment.view.ts b/src/views/policy-attachment.view.ts index bed1fd7..09c47e9 100644 --- a/src/views/policy-attachment.view.ts +++ b/src/views/policy-attachment.view.ts @@ -5,36 +5,32 @@ import { PolicyAttachment } from '../objects/policy-attachment.object.js'; // and loading it for every row costs the page. const policyAttachmentViews: UI.View = { object: PolicyAttachment.name, - // 表单只放人填的字段:所属制度、现行由所属版本自动带出;字数、token、哈希由导入工具维护。 - // 原件现阶段不上传,字段保留给后期用,放在最后、默认折叠。helpText 是给填表的人看的短提示。 + // 表单只放人填的字段,两两成对排齐,附件正文紧接在后面;所属制度、现行由所属版本自动带出,字数、token、 + // 哈希由导入工具维护。原件现阶段不上传,字段留给后期,单独一组、默认折叠。helpText 覆盖写给 AI 的说明。 form: { type: 'simple', + modalSize: 'xl', sections: [ { - name: 'attachment_info', - label: '附件', + name: 'attachment_main', + label: '附件信息', columns: 2, fields: [ - 'policy_version', + { field: 'policy_version', span: 'full', helpText: '' }, { field: 'label', helpText: '原文里的编号,如「附件1」' }, - { field: 'title', helpText: '附件自己的名称,不带制度名' }, - { field: 'attachment_class', helpText: '规范性附件和正文一起作为答复依据' }, - { field: 'sort_no', helpText: '先后顺序:1、2、3…' }, + { field: 'sort_no', helpText: '' }, + { field: 'title', helpText: '' }, + { field: 'attachment_class', helpText: '' }, + { field: 'body_md', span: 'full', helpText: '规范性附件的全文(Markdown,已脱敏);表单类可以不填' }, ], }, - { - name: 'attachment_body', - label: '附件正文', - columns: 1, - fields: [{ field: 'body_md', span: 'full', helpText: '规范性附件的全文(Markdown,已脱敏);表单类可以不填' }], - }, { name: 'attachment_original', - label: '原件', + label: '原件(后期使用)', columns: 1, collapsible: true, collapsed: true, - fields: [{ field: 'original_file', helpText: '现阶段不上传' }], + fields: [{ field: 'original_file', helpText: '' }], }, ], }, diff --git a/src/views/policy-version.view.ts b/src/views/policy-version.view.ts index 32d4787..e976bdd 100644 --- a/src/views/policy-version.view.ts +++ b/src/views/policy-version.view.ts @@ -3,38 +3,34 @@ import { PolicyVersion } from '../objects/policy-version.object.js'; const policyVersionViews: UI.View = { object: PolicyVersion.name, - // 新建 / 编辑表单只放人填的字段。条号索引、字数、token 估算、内容哈希由导入工具(tools/redact)维护,不在表单里。 - // 正文原件现阶段不上传(系统里只存脱敏后的文字),字段保留给后期用,放在最后、默认折叠。 - // helpText 是给填表的人看的短提示;对象字段的 description 写给 AI,表单里不重复显示。 + // 新建 / 编辑表单只放人填的字段,两两成对排齐,正文紧接在后面。条号索引、字数、token 估算、内容哈希由 + // 导入工具(tools/redact)维护,不在表单里。正文原件现阶段不上传,字段留给后期,单独一组、默认折叠。 + // 对象字段的 description 写给 AI,表单里用 helpText 覆盖成给人看的短句(不需要提示的字段给空串)。 form: { type: 'simple', + modalSize: 'xl', sections: [ { - name: 'version_info', + name: 'version_main', label: '版本信息', columns: 2, fields: [ 'policy', - 'title', - { field: 'version_no', helpText: '通常用发文文号' }, - 'effective_date', - { field: 'version_status', helpText: '核对后在「待发布版本」里设为现行' }, - { field: 'change_note', span: 'full' }, + { field: 'version_no', helpText: '' }, + { field: 'title', span: 'full', helpText: '' }, + { field: 'effective_date', helpText: '' }, + { field: 'version_status', helpText: '' }, + { field: 'change_note', span: 'full', helpText: '' }, + { field: 'body_md', span: 'full', helpText: '脱敏后的正文(Markdown):条文以 **第X条** 开头,章节用 ## 标题' }, ], }, - { - name: 'version_body', - label: '正文', - columns: 1, - fields: [{ field: 'body_md', span: 'full', helpText: '脱敏后的正文(Markdown):条文以 **第X条** 开头,章节用 ## 标题' }], - }, { name: 'version_original', - label: '原件', + label: '原件(后期使用)', columns: 1, collapsible: true, collapsed: true, - fields: [{ field: 'original_file', helpText: '现阶段不上传' }], + fields: [{ field: 'original_file', helpText: '' }], }, ], },