remove all unnecessary \
This commit is contained in:
parent
f192ba3759
commit
17460f937f
@ -28,19 +28,19 @@ class UserAbl:
|
|||||||
return jsonify(message="You don't have the permission to give permission(s) you don't have"), 403
|
return jsonify(message="You don't have the permission to give permission(s) you don't have"), 403
|
||||||
|
|
||||||
# create the user
|
# create the user
|
||||||
new_user = User( \
|
new_user = User(
|
||||||
login=login, \
|
login=login,
|
||||||
password=generate_password_hash(password, method='sha256') \
|
password=generate_password_hash(password, method='sha256')
|
||||||
)
|
)
|
||||||
|
|
||||||
db.session.add(new_user)
|
db.session.add(new_user)
|
||||||
db.session.flush()
|
db.session.flush()
|
||||||
|
|
||||||
# create the permissions for the user
|
# create the permissions for the user
|
||||||
new_role = Role( \
|
new_role = Role(
|
||||||
name=login, \
|
name=login,
|
||||||
user_id=new_user.as_dict()['id'], \
|
user_id=new_user.as_dict()['id'],
|
||||||
parent_id=current_user.as_dict()['roles'][0]['id'], \
|
parent_id=current_user.as_dict()['roles'][0]['id'],
|
||||||
permissions=permissions)
|
permissions=permissions)
|
||||||
db.session.add(new_role)
|
db.session.add(new_role)
|
||||||
new_user.roles.append(new_role)
|
new_user.roles.append(new_role)
|
||||||
|
@ -21,24 +21,24 @@ class PlaylistDao:
|
|||||||
def has_role_view_d(playlist_id, user_id):
|
def has_role_view_d(playlist_id, user_id):
|
||||||
has_role_to_view = db.session.query(Playlist) \
|
has_role_to_view = db.session.query(Playlist) \
|
||||||
.filter(Playlist.id == playlist_id) \
|
.filter(Playlist.id == playlist_id) \
|
||||||
.filter( \
|
.filter(
|
||||||
Playlist.view.any( \
|
Playlist.view.any(
|
||||||
# check if a role belongs to this user
|
# check if a role belongs to this user
|
||||||
Role.user_id == user_id or \
|
Role.user_id == user_id or
|
||||||
# check if a this user has a role to view
|
# check if a this user has a role to view
|
||||||
Role.users.any(User.id == user_id) \
|
Role.users.any(User.id == user_id)
|
||||||
)) \
|
)) \
|
||||||
.first()
|
.first()
|
||||||
return has_role_to_view
|
return has_role_to_view
|
||||||
|
|
||||||
def has_role_view_d(playlist_id, user_id):
|
def has_role_view_d(playlist_id, user_id):
|
||||||
has_role_to_edit = db.session.query(Playlist) \
|
has_role_to_edit = db.session.query(Playlist) \
|
||||||
.filter( \
|
.filter(
|
||||||
Playlist.edit.any( \
|
Playlist.edit.any(
|
||||||
# check if a role belongs to this user
|
# check if a role belongs to this user
|
||||||
Role.user_id == user_id or \
|
Role.user_id == user_id or
|
||||||
# check if a this user has a role to edit
|
# check if a this user has a role to edit
|
||||||
Role.users.any(User.id == user_id) \
|
Role.users.any(User.id == user_id)
|
||||||
)) \
|
)) \
|
||||||
.first()
|
.first()
|
||||||
return has_role_to_edit
|
return has_role_to_edit
|
||||||
|
@ -29,7 +29,7 @@ class permissions:
|
|||||||
check_perm = CheckPermissionFactory(perm)
|
check_perm = CheckPermissionFactory(perm)
|
||||||
print(args, kwargs)
|
print(args, kwargs)
|
||||||
if not check_perm.is_valid(kwargs):
|
if not check_perm.is_valid(kwargs):
|
||||||
return jsonify( \
|
return jsonify(
|
||||||
message=check_perm.message), \
|
message=check_perm.message), \
|
||||||
check_perm.status_code
|
check_perm.status_code
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user