mirror of https://github.com/veops/cmdb.git
fix acl api
This commit is contained in:
parent
a822503b67
commit
39aaa916dc
|
@ -69,7 +69,7 @@ class CRUDMixin(FormatMixin):
|
|||
@classmethod
|
||||
def get_by_id(cls, _id):
|
||||
if any((isinstance(_id, six.string_types) and _id.isdigit(),
|
||||
isinstance(_id, (int, long, float))), ):
|
||||
isinstance(_id, (six.integer_types, float))), ):
|
||||
return getattr(cls, "query").get(int(_id)) or None
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -53,11 +53,11 @@ class ResourceTypeCRUD(object):
|
|||
rt = ResourceType.get_by_id(rt_id) or abort(404, "ResourceType <{0}> is not found".format(rt_id))
|
||||
if 'name' in kwargs:
|
||||
other = ResourceType.get_by(name=kwargs['name'], app_id=rt.app_id, to_dict=False, first=True)
|
||||
if other.id != rt_id:
|
||||
if other and other.id != rt_id:
|
||||
return abort(400, "ResourceType <{0}> is duplicated".format(kwargs['name']))
|
||||
|
||||
if 'perms' in kwargs:
|
||||
cls.update_perms(rt_id, kwargs['perms'], rt.app_id)
|
||||
cls.update_perms(rt_id, kwargs.pop('perms'), rt.app_id)
|
||||
|
||||
return rt.update(**kwargs)
|
||||
|
||||
|
@ -160,7 +160,7 @@ class ResourceCRUD(object):
|
|||
resource = Resource.get_by_id(_id) or abort(404, "Resource <{0}> is not found".format(_id))
|
||||
|
||||
other = Resource.get_by(name=name, resource_type_id=resource.resource_type_id, to_dict=False, first=True)
|
||||
if other.id != _id:
|
||||
if other and other.id != _id:
|
||||
return abort(400, "Resource <{0}> is duplicated".format(name))
|
||||
|
||||
return resource.update(name=name)
|
||||
|
|
|
@ -46,7 +46,7 @@ class UserCRUD(object):
|
|||
def update(uid, **kwargs):
|
||||
user = User.get_by(uid=uid, to_dict=False, first=True) or abort(404, "User <{0}> does not exist".format(uid))
|
||||
|
||||
UserCache.clean(uid)
|
||||
UserCache.clean(user)
|
||||
|
||||
return user.update(**kwargs)
|
||||
|
||||
|
|
Loading…
Reference in New Issue