diff --git a/src/masonite_permission/mixins/has_permissions.py b/src/masonite_permission/mixins/has_permissions.py index fc3a79f..bbc39e3 100644 --- a/src/masonite_permission/mixins/has_permissions.py +++ b/src/masonite_permission/mixins/has_permissions.py @@ -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 diff --git a/src/masonite_permission/mixins/has_roles.py b/src/masonite_permission/mixins/has_roles.py index 36f89c3..58006e1 100644 --- a/src/masonite_permission/mixins/has_roles.py +++ b/src/masonite_permission/mixins/has_roles.py @@ -1,4 +1,3 @@ -from masoniteorm.relationships import belongs_to_many from masoniteorm.query import QueryBuilder from masoniteorm.collection.Collection import Collection diff --git a/src/masonite_permission/models/permission.py b/src/masonite_permission/models/permission.py index 9083d06..126dbc1 100644 --- a/src/masonite_permission/models/permission.py +++ b/src/masonite_permission/models/permission.py @@ -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 diff --git a/src/masonite_permission/models/role.py b/src/masonite_permission/models/role.py index 40653cb..751cd15 100644 --- a/src/masonite_permission/models/role.py +++ b/src/masonite_permission/models/role.py @@ -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 diff --git a/tests/integrations/app/controllers/WelcomeController.py b/tests/integrations/app/controllers/WelcomeController.py index f412bf9..a3dbf53 100644 --- a/tests/integrations/app/controllers/WelcomeController.py +++ b/tests/integrations/app/controllers/WelcomeController.py @@ -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 @@ -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() @@ -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(), - }