mirror of https://github.com/veops/cmdb.git
fix relation tree
This commit is contained in:
parent
2a420225e2
commit
4a744dcad9
|
@ -112,7 +112,7 @@ class CITypeManager(object):
|
||||||
def delete(cls, type_id):
|
def delete(cls, type_id):
|
||||||
ci_type = cls.check_is_existed(type_id)
|
ci_type = cls.check_is_existed(type_id)
|
||||||
|
|
||||||
if CI.get_by(type_id=type_id, first=True, to_dict=False):
|
if CI.get_by(type_id=type_id, first=True, to_dict=False) is not None:
|
||||||
return abort(400, "cannot delete, because CI instance exists")
|
return abort(400, "cannot delete, because CI instance exists")
|
||||||
|
|
||||||
for item in CITypeRelation.get_by(parent_id=type_id, to_dict=False):
|
for item in CITypeRelation.get_by(parent_id=type_id, to_dict=False):
|
||||||
|
|
|
@ -120,12 +120,15 @@ def has_perm(resources, resource_type, perm):
|
||||||
return decorator_has_perm
|
return decorator_has_perm
|
||||||
|
|
||||||
|
|
||||||
def is_app_admin():
|
def is_app_admin(app=None):
|
||||||
if RoleEnum.CONFIG in session.get("acl", {}).get("parentRoles", []):
|
if RoleEnum.CONFIG in session.get("acl", {}).get("parentRoles", []):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
app = app or 'cmdb'
|
||||||
|
app_id = AppCache.get(app).id
|
||||||
|
|
||||||
for role in session.get("acl", {}).get("parentRoles", []):
|
for role in session.get("acl", {}).get("parentRoles", []):
|
||||||
if RoleCache.get(role).is_app_admin:
|
if RoleCache.get_by_name(app_id, role).is_app_admin:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -162,7 +165,7 @@ def role_required(role_name):
|
||||||
return
|
return
|
||||||
|
|
||||||
if current_app.config.get("USE_ACL"):
|
if current_app.config.get("USE_ACL"):
|
||||||
if role_name not in session.get("acl", {}).get("parentRoles", []):
|
if role_name not in session.get("acl", {}).get("parentRoles", []) and not is_app_admin():
|
||||||
return abort(403, "Role {0} is required".format(role_name))
|
return abort(403, "Role {0} is required".format(role_name))
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ def ci_delete(ci_id):
|
||||||
|
|
||||||
@celery.task(name="cmdb.ci_relation_cache", queue=CMDB_QUEUE)
|
@celery.task(name="cmdb.ci_relation_cache", queue=CMDB_QUEUE)
|
||||||
def ci_relation_cache(parent_id, child_id):
|
def ci_relation_cache(parent_id, child_id):
|
||||||
|
db.session.close()
|
||||||
|
|
||||||
children = rd.get([parent_id], REDIS_PREFIX_CI_RELATION)[0]
|
children = rd.get([parent_id], REDIS_PREFIX_CI_RELATION)[0]
|
||||||
children = json.loads(children) if children is not None else {}
|
children = json.loads(children) if children is not None else {}
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,8 @@ export default {
|
||||||
this.setColumnWidth()
|
this.setColumnWidth()
|
||||||
console.log('set column')
|
console.log('set column')
|
||||||
}, 100)
|
}, 100)
|
||||||
this.loadNoRoot(this.treeKeys[this.treeKeys.length - 1], level)
|
|
||||||
}
|
}
|
||||||
|
this.loadNoRoot(this.treeKeys[this.treeKeys.length - 1], level)
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
if (showTypeIds.length && showTypeIds.length !== this.showTypeIds.length) {
|
if (showTypeIds.length && showTypeIds.sort().join(',') !== this.showTypeIds.sort().join(',')) {
|
||||||
const showTypes = []
|
const showTypes = []
|
||||||
_showTypes.forEach(item => {
|
_showTypes.forEach(item => {
|
||||||
if (showTypeIds.includes(item.id)) {
|
if (showTypeIds.includes(item.id)) {
|
||||||
|
|
Loading…
Reference in New Issue