diff --git a/src/api/abl/UserAbl.py b/src/api/abl/UserAbl.py index 6a6b049..959febd 100644 --- a/src/api/abl/UserAbl.py +++ b/src/api/abl/UserAbl.py @@ -28,19 +28,19 @@ class UserAbl: return jsonify(message="You don't have the permission to give permission(s) you don't have"), 403 # create the user - new_user = User( \ - login=login, \ - password=generate_password_hash(password, method='sha256') \ + new_user = User( + login=login, + password=generate_password_hash(password, method='sha256') ) db.session.add(new_user) db.session.flush() # create the permissions for the user - new_role = Role( \ - name=login, \ - user_id=new_user.as_dict()['id'], \ - parent_id=current_user.as_dict()['roles'][0]['id'], \ + new_role = Role( + name=login, + user_id=new_user.as_dict()['id'], + parent_id=current_user.as_dict()['roles'][0]['id'], permissions=permissions) db.session.add(new_role) new_user.roles.append(new_role) diff --git a/src/api/dao/Playlist.py b/src/api/dao/Playlist.py index 169037d..c4a9e6e 100644 --- a/src/api/dao/Playlist.py +++ b/src/api/dao/Playlist.py @@ -21,24 +21,24 @@ class PlaylistDao: def has_role_view_d(playlist_id, user_id): has_role_to_view = db.session.query(Playlist) \ .filter(Playlist.id == playlist_id) \ - .filter( \ - Playlist.view.any( \ + .filter( + Playlist.view.any( # 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 - Role.users.any(User.id == user_id) \ + Role.users.any(User.id == user_id) )) \ .first() return has_role_to_view def has_role_view_d(playlist_id, user_id): has_role_to_edit = db.session.query(Playlist) \ - .filter( \ - Playlist.edit.any( \ + .filter( + Playlist.edit.any( # 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 - Role.users.any(User.id == user_id) \ + Role.users.any(User.id == user_id) )) \ .first() return has_role_to_edit diff --git a/src/api/permissions.py b/src/api/permissions.py index 0f2fb07..34215a1 100644 --- a/src/api/permissions.py +++ b/src/api/permissions.py @@ -29,7 +29,7 @@ class permissions: check_perm = CheckPermissionFactory(perm) print(args, kwargs) if not check_perm.is_valid(kwargs): - return jsonify( \ + return jsonify( message=check_perm.message), \ check_perm.status_code return func(*args, **kwargs)