feat: 考试集团一览与商品集团权限边界

This commit is contained in:
XingQue
2026-06-26 05:57:39 +08:00
parent 65c5e6572e
commit 34e79aa753
4 changed files with 85 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
"""集团全局商品目录(商品/类型/专区)须在集团汇总视图操作。"""
from jituan.constants import DATA_SCOPE_ALL
from jituan.services.club_context import resolve_club_scope
GROUP_CATALOG_SCOPE_MSG = (
'商品、类型与专区为集团全局数据,请在顶栏切换为「集团汇总(全部子公司)」后操作;'
'具体小程序仅可在「小程序配置」中做上架/图标等俱乐部侧配置。'
)
def block_non_group_catalog_scope(request):
"""非集团汇总视图时返回错误文案,否则返回 None。"""
if resolve_club_scope(request) != DATA_SCOPE_ALL:
return GROUP_CATALOG_SCOPE_MSG
return None

View File

@@ -8,6 +8,7 @@ from django.utils import timezone
from jituan.constants import DATA_SCOPE_ALL
from jituan.models import (
Club,
ClubDashouExamConfig,
ClubDashouExamPass,
ClubDashouExamQuestion,
@@ -200,6 +201,31 @@ def mark_exam_passed(request, user):
return {'club_id': club_id, 'passed': True}, None
def build_group_exam_overview(request):
"""集团汇总视图:各俱乐部考试配置一览。"""
if not _scope_blocked(request):
return None, '请在集团汇总视图查看各俱乐部概览'
rows = []
for club in Club.query.filter(status=1).order_by('club_id'):
cid = club.club_id
cfg = get_or_create_config(cid)
pool = ClubDashouExamQuestion.query.filter(club_id=cid).count()
enabled_pool = ClubDashouExamQuestion.query.filter(club_id=cid, is_enabled=True).count()
passed_count = ClubDashouExamPass.query.filter(club_id=cid).count()
rows.append({
'club_id': cid,
'club_name': club.name or cid,
'is_enabled': bool(cfg.is_enabled),
'draw_count': int(cfg.draw_count or 10),
'pass_count': int(cfg.pass_count or 10),
'require_member': bool(cfg.require_member),
'pool_count': pool,
'enabled_pool_count': enabled_pool,
'passed_user_count': passed_count,
})
return {'list': rows}, None
def build_admin_config_payload(request):
if _scope_blocked(request):
return {'scope_error': SCOPE_MSG}