remove all unnecessary \

This commit is contained in:
grimhilt 2023-09-12 15:40:25 +02:00
parent f192ba3759
commit 17460f937f
3 changed files with 16 additions and 16 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)