Skip to content

Commit

Permalink
fix(common): fix 'ACLManager' object has no attribute 'create_app' (#217
Browse files Browse the repository at this point in the history
)
  • Loading branch information
EvanSung authored Oct 21, 2023
1 parent 0fb07c0 commit de53648
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 3 additions & 4 deletions cmdb-api/api/commands/click_common_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,9 @@ def check_app(self, app_name):
)
try:
app = acl.validate_app()
if app:
return acl

acl.create_app(payload)
if not app:
acl.create_app(payload)
return acl
except Exception as e:
current_app.logger.error(e)
if '不存在' in str(e):
Expand Down
12 changes: 9 additions & 3 deletions cmdb-api/api/lib/common_setting/acl.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding:utf-8 -*-
from flask import abort
from flask import current_app

from api.lib.common_setting.resp_format import ErrFormat
from api.lib.perm.acl.app import AppCRUD
from api.lib.perm.acl.cache import RoleCache, AppCache
from api.lib.perm.acl.permission import PermissionCRUD
from api.lib.perm.acl.resource import ResourceTypeCRUD, ResourceCRUD
from api.lib.perm.acl.role import RoleCRUD, RoleRelationCRUD
from api.lib.perm.acl.user import UserCRUD
from api.lib.perm.acl.resource import ResourceTypeCRUD, ResourceCRUD
from api.lib.perm.acl.permission import PermissionCRUD


class ACLManager(object):
Expand Down Expand Up @@ -133,3 +133,9 @@ def get_resource_by_type(self, q, u, rt_id, page=1, page_size=999999):

def grant_resource(self, rid, resource_id, perms):
PermissionCRUD.grant(rid, perms, resource_id=resource_id, group_id=None)

@staticmethod
def create_app(payload):
rt = AppCRUD.add(**payload)

return rt.to_dict()

0 comments on commit de53648

Please sign in to comment.