Files
ucvl-zonghengjia-open-source/backend/control/management/commands/audit_plan_approvals.py
T

24 lines
1.0 KiB
Python
Raw Normal View History

import json
from django.core.management.base import BaseCommand, CommandError
from control.approval_audit import audit_plan_approvals
class Command(BaseCommand):
help = "只读检查套餐申请/订阅冲突及 0008 回退风险,不审批、不回填、不修改数据"
def add_arguments(self, parser):
parser.add_argument("--sample-limit", type=int, default=50)
parser.add_argument("--fail-on-review", action="store_true",
help="先输出 JSON;存在待人工复核项时返回非零状态")
def handle(self, *args, **options):
limit = options["sample_limit"]
if not 1 <= limit <= 1000:
raise CommandError("sample-limit 必须为 1 至 1000。")
report = audit_plan_approvals(sample_limit=limit)
self.stdout.write(json.dumps(report, ensure_ascii=False, indent=2))
if options["fail_on_review"] and report["review_required"]:
raise CommandError("只读检查发现待人工复核项;未修改任何申请或订阅。")