(self, request)
return {
            'name': WeChatApp._meta.verbose_name_plural,
            'app_label': app_label,
            'app_url': "#",
            'has_module_perms': bool(app_perms),
            'models': app_perms,
        }
构建wechat apps列表
构建wechat apps列表
构建wechat apps列表
def _build_wechat_app_dict(self, request):
        """构建wechat apps列表"""
        app_label = WeChatApp._meta.app_label

        # 过滤有权限的app
        query = self.wechat_site.get_app_queryset()
        if not request.user.is_superuser:
            perms = get_user_permissions(request.user)
            allowed_apps = {
                k for k, ps in perms.items() if ps != {"manage"}
            }
            query = query.filter(name__in=allowed_apps)
        apps = query.all()

        # 构建app_dict
        app_perms = [
            dict(
                name=str(app),
                object_name=app.name,
                perms=dict(
                    change=True,
                ),
                admin_url=reverse(
                    "admin:wechat_funcs_list",
                    current_app=self.name,
                    kwargs=dict(
                        wechat_app_id=app.id,
                        app_label=app_label
                    )
                )
            )
            for app in apps
        ]
        return {
            'name': WeChatApp._meta.verbose_name_plural,
            'app_label': app_label,
            'app_url': "#",
            'has_module_perms': bool(app_perms),
            'models': app_perms,
        }
def _build_wechat_app_dict ( self , request ) : app_label = WeChatApp . _meta . app_label # 过滤有权限的app query = self . wechat_site . get_app_queryset ( ) if not request . user . is_superuser : perms = get_user_permissions ( request . user ) allowed_apps = { k for k , ps in perms . items ( ) if ps != { "manage" } } query = query . filter ( name__in = allowed_apps ) apps = query . all ( ) # 构建app_dict app_perms = [ dict ( name = str ( app ) , object_name = app . name , perms = dict ( change = True , ) , admin_url = reverse ( "admin:wechat_funcs_list" , current_app = self . name , kwargs = dict ( wechat_app_id = app . id , app_label = app_label ) ) ) for app in apps ] return { 'name' : WeChatApp . _meta . verbose_name_plural , 'app_label' : app_label , 'app_url' : "#" , 'has_module_perms' : bool ( app_perms ) , 'models' : app_perms , }