Skip to content

Commit

Permalink
Fixed Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yubarajshrestha committed Mar 27, 2022
1 parent 2b59e5a commit 37d5c14
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 54 deletions.
1 change: 0 additions & 1 deletion src/masonite_permission/mixins/has_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from masoniteorm.query import QueryBuilder
from masoniteorm.relationships import belongs_to_many
from masoniteorm.collection.Collection import Collection
from ..exceptions import PermissionException

Expand Down
1 change: 0 additions & 1 deletion src/masonite_permission/mixins/has_roles.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from masoniteorm.relationships import belongs_to_many
from masoniteorm.query import QueryBuilder
from masoniteorm.collection.Collection import Collection

Expand Down
2 changes: 0 additions & 2 deletions src/masonite_permission/models/permission.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Permission Model."""
from masoniteorm.models import Model
from masoniteorm.relationships import belongs_to_many
from masoniteorm.query import QueryBuilder
from masoniteorm.collection.Collection import Collection
from ..exceptions import PermissionException


Expand Down
2 changes: 0 additions & 2 deletions src/masonite_permission/models/role.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Role Model."""
from masoniteorm.models import Model
from masoniteorm.relationships import belongs_to_many
from masoniteorm.query import QueryBuilder
from masoniteorm.collection.Collection import Collection

from ..exceptions import PermissionException

Expand Down
48 changes: 0 additions & 48 deletions tests/integrations/app/controllers/WelcomeController.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from masonite.views import View
from masonite.controllers import Controller

from masoniteorm.query import QueryBuilder
from src.masonite_permission.models.permission import Permission
from src.masonite_permission.models import Role
from tests.integrations.app.models.User import User


Expand All @@ -17,27 +15,6 @@ def show(self, view: View):
return view.render("welcome", {"user": user})

def test(self):
user = User.first()

# user.give_permission_to("create-post", "edit-post")
# user.give_permission_to("delete-post")
# user.revoke_permission_to(["delete-post", 'create-post'])

""" role = Role.first()
role.sync_permissions(['create-post', 'edit-post', 'delete-post'])
role.attach_permission("create-user")
role.detach_permission("create-post") """

# user.assign_role(role)
# user.revoke_role(role)

""" return {
"roles": user.roles().serialize(),
"permissions": role.permissions().serialize(),
"has_role": user.has_role_of("admin"),
"user_permissions": user.permissions().serialize(),
} """

permission = Permission.where("slug", "create-user").first()

Expand All @@ -49,28 +26,3 @@ def test(self):
return {
"roles": permission.roles().serialize(),
}

# user.give_permission_to("create-post", "edit-post")

# QueryBuilder().table("model_has_permissions").create({
# "permission_id": 3,
# "permissionable_id": role.id,
# "permissionable_type": "roles"
# })

# select p.* from permissions as p,
# model_has_permissions as mhp,
# users as u,
# role_user as ru
# where ((mhp.permissionable_id = u.id and mhp.permissionable_type = 'users' and mhp.permission_id = p.id) or
# (mhp.permissionable_id = ru.role_id and mhp.permissionable_type = 'roles' and ru.user_id = u.id and mhp.permission_id = p.id)) and
# u.id = '1'

return {
"data": user.has_permission_to("create-posts"),
"has_any": user.has_any_permission(["create-post", "edit-post"]),
"has_all": user.has_all_permissions(["create-post", "edit-post", "delete-post"]),
"can_any": user.can_("create-post|edit-post|delete-post"),
"can_all": user.can_("create-post,edit-post,delete-post"),
"permissions": user.permissions().serialize(),
}

0 comments on commit 37d5c14

Please sign in to comment.