diff --git a/jituan/services/club_kaohe_chenghao.py b/jituan/services/club_kaohe_chenghao.py index d1c9741..42c1dec 100644 --- a/jituan/services/club_kaohe_chenghao.py +++ b/jituan/services/club_kaohe_chenghao.py @@ -1,15 +1,20 @@ """俱乐部抢单池标签筛选区配置(全局考核称号由集团定义)。""" -from jituan.constants import CLUB_ID_DEFAULT +from jituan.constants import DATA_SCOPE_ALL from jituan.models import ClubKaoheChenghaoConfig from jituan.services.club_context import ( club_id_for_write, resolve_club_id_from_request, resolve_club_scope, ) -from jituan.constants import DATA_SCOPE_ALL +from jituan.constants import CLUB_ID_DEFAULT from rank.models import Chenghao CLUB_WRITE_SCOPE_MSG = '当前为集团汇总视图,请先在顶栏切换到具体俱乐部后再操作' +CLUB_READ_SCOPE_MSG = '请先在顶栏切换到具体小程序/俱乐部后再操作' + + +def club_read_blocked(request): + return resolve_club_scope(request) == DATA_SCOPE_ALL def club_write_blocked(request): @@ -43,6 +48,13 @@ def filter_chenghao_ids_for_pool(club_id, chenghao_ids): def build_club_kaohe_admin_list(request, bankuai_id=None): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'list': [], + 'scope': resolve_club_scope(request), + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) qs = Chenghao.objects.filter(leixing='dashou') @@ -68,6 +80,12 @@ def build_club_kaohe_admin_list(request, bankuai_id=None): def build_club_kaohe_catalog(request, bankuai_id=None): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'catalog': [], + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) qs = Chenghao.objects.filter(leixing='dashou') diff --git a/jituan/services/club_shangpin_leixing.py b/jituan/services/club_shangpin_leixing.py index 721d2bb..80b8a8f 100644 --- a/jituan/services/club_shangpin_leixing.py +++ b/jituan/services/club_shangpin_leixing.py @@ -5,20 +5,24 @@ import uuid from django.db import transaction -from jituan.constants import CLUB_ID_DEFAULT +from jituan.constants import CLUB_ID_DEFAULT, DATA_SCOPE_ALL from jituan.models import ClubShangpinLeixingConfig from jituan.services.club_context import ( club_id_for_write, resolve_club_id_from_request, resolve_club_scope, ) -from jituan.constants import DATA_SCOPE_ALL from products.models import ShangpinLeixing from utils.oss_utils import delete_from_oss, upload_to_oss, validate_image logger = logging.getLogger(__name__) CLUB_WRITE_SCOPE_MSG = '当前为集团汇总视图,请先在顶栏切换到具体俱乐部后再操作' +CLUB_READ_SCOPE_MSG = '请先在顶栏切换到具体小程序/俱乐部后再操作' + + +def club_read_blocked(request): + return resolve_club_scope(request) == DATA_SCOPE_ALL def club_write_blocked(request): @@ -76,6 +80,13 @@ def build_club_leixing_list_for_api(club_id): def build_club_leixing_admin_list(request): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'list': [], + 'scope': resolve_club_scope(request), + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) enabled = [] @@ -95,6 +106,12 @@ def build_club_leixing_admin_list(request): def build_club_leixing_catalog(request): + if club_read_blocked(request): + return { + 'club_id': resolve_club_id_from_request(request), + 'catalog': [], + 'scope_error': CLUB_READ_SCOPE_MSG, + } club_id = resolve_club_id_from_request(request) cfg_map = _config_map(club_id) catalog = []