diff --git a/src/unipoll_api/actions/policy.py b/src/unipoll_api/actions/policy.py index 6d8e505..bf5feaa 100644 --- a/src/unipoll_api/actions/policy.py +++ b/src/unipoll_api/actions/policy.py @@ -53,7 +53,7 @@ async def get_policies(policy_holder: Account | Group | None = None, async def get_policy(policy: Policy, permission_check: bool = True) -> PolicySchemas.PolicyShort: # Get the parent resource of the policy - parent_resource = await policy.get_parent_recource(fetch_links=True) + parent_resource = await policy.get_parent_resource(fetch_links=True) await check_permissions(parent_resource, "get_policies", permission_check) # Get the policy holder @@ -75,7 +75,7 @@ async def update_policy(policy: Policy, new_permissions: list[str], check_permissions: bool = True) -> PolicySchemas.PolicyOutput: - parent_resource = await policy.get_parent_recource(fetch_links=True) + parent_resource = await policy.get_parent_resource(fetch_links=True) # Check if the user has the required permissions to update the policy await Permissions.check_permissions(parent_resource, "update_policies", check_permissions) diff --git a/src/unipoll_api/documents.py b/src/unipoll_api/documents.py index b6d6e00..1722043 100644 --- a/src/unipoll_api/documents.py +++ b/src/unipoll_api/documents.py @@ -33,7 +33,8 @@ class AccessToken(BeanieBaseAccessToken, Document): # type: ignore class Resource(Document): id: ResourceID = Field(default_factory=ResourceID, alias="_id") resource_type: Literal["workspace", "group", "poll"] - name: str = Field(title="Name", description="Name of the resource", min_length=3, max_length=50) + name: str = Field( + title="Name", description="Name of the resource", min_length=3, max_length=50) description: str = Field(default="", title="Description", max_length=1000) policies: list[Link["Policy"]] = [] @@ -101,7 +102,9 @@ async def remove_member(self, account, save: bool = True) -> bool: for i, member in enumerate(self.members): if account.id == member.id: # type: ignore self.members.remove(member) - Debug.info(f"Removed member {member.id} from {self.resource_type} {self.id}") # type: ignore + # type: ignore + Debug.info( + f"Removed member {member.id} from {self.resource_type} {self.id}") break # Remove the policy from the workspace @@ -128,7 +131,8 @@ class Group(Resource): async def add_member(self, account: "Account", permissions, save: bool = True) -> "Account": if account not in self.workspace.members: # type: ignore from unipoll_api.exceptions import WorkspaceExceptions - raise WorkspaceExceptions.UserNotMember(self.workspace, account) # type: ignore + raise WorkspaceExceptions.UserNotMember( + self.workspace, account) # type: ignore # Add the account to the group self.members.append(account) # type: ignore @@ -143,7 +147,9 @@ async def remove_member(self, account, save: bool = True) -> bool: for i, member in enumerate(self.members): if account.id == member.id: # type: ignore self.members.remove(member) - Debug.info(f"Removed member {member.id} from {self.resource_type} {self.id}") # type: ignore + # type: ignore + Debug.info( + f"Removed member {member.id} from {self.resource_type} {self.id}") break # Remove the policy from the group @@ -171,12 +177,13 @@ class Policy(Document): policy_holder: Link["Group"] | Link["Account"] permissions: int - async def get_parent_recource(self, fetch_links: bool = False) -> Workspace | Group | Poll: + async def get_parent_resource(self, fetch_links: bool = False) -> Workspace | Group | Poll: from unipoll_api.exceptions.resource import ResourceNotFound parent = await eval(self.parent_resource.ref.collection).get(self.parent_resource.ref.id, fetch_links=fetch_links) if not parent: - ResourceNotFound(self.parent_resource.ref.collection, self.parent_resource.ref.id) + ResourceNotFound(self.parent_resource.ref.collection, + self.parent_resource.ref.id) return parent async def get_policy_holder(self, fetch_links: bool = False) -> Group | Account: