From 44a7dceafbde475ac360470e747e5f8245cfc473 Mon Sep 17 00:00:00 2001 From: Michael Pisman Date: Fri, 13 Oct 2023 14:45:13 -0600 Subject: [PATCH] style: flake8 styling --- src/unipoll_api/actions/group.py | 4 ++-- src/unipoll_api/actions/workspace.py | 5 +++-- src/unipoll_api/dependencies.py | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/unipoll_api/actions/group.py b/src/unipoll_api/actions/group.py index d4ea340..efb6ce3 100644 --- a/src/unipoll_api/actions/group.py +++ b/src/unipoll_api/actions/group.py @@ -62,7 +62,7 @@ async def create_group(workspace: Workspace, # Add the account to group member list await new_group.add_member(account, Permissions.GROUP_ALL_PERMISSIONS) - # Create a policy for the new group + # Create a policy for the new group await workspace.add_policy(new_group, Permissions.GROUP_BASIC_PERMISSIONS, False) workspace.groups.append(new_group) # type: ignore await Workspace.save(workspace, link_rule=WriteRules.WRITE) @@ -72,7 +72,7 @@ async def create_group(workspace: Workspace, # Get group -async def get_group(group: Group, +async def get_group(group: Group, include_members: bool = False, include_policies: bool = False, check_permissions: bool = True) -> GroupSchemas.Group: diff --git a/src/unipoll_api/actions/workspace.py b/src/unipoll_api/actions/workspace.py index af693ba..c72dbf1 100644 --- a/src/unipoll_api/actions/workspace.py +++ b/src/unipoll_api/actions/workspace.py @@ -68,8 +68,8 @@ async def update_workspace(workspace: Workspace, input_data: WorkspaceSchemas.WorkspaceUpdateRequest, check_permissions: bool = True) -> WorkspaceSchemas.Workspace: await Permissions.check_permissions(workspace, "update_workspace", check_permissions) - save_changes = False + # Check if user suplied a name if input_data.name and input_data.name != workspace.name: # Check if workspace name is unique @@ -91,7 +91,8 @@ async def update_workspace(workspace: Workspace, # Delete a workspace async def delete_workspace(workspace: Workspace, check_permissions: bool = True): await Permissions.check_permissions(workspace, "delete_workspace", check_permissions) - + + # Delete all groups in the workspace for group in workspace.groups: await actions.GroupActions.delete_group(group) # type: ignore diff --git a/src/unipoll_api/dependencies.py b/src/unipoll_api/dependencies.py index 9a616dd..ab42993 100644 --- a/src/unipoll_api/dependencies.py +++ b/src/unipoll_api/dependencies.py @@ -1,11 +1,9 @@ from typing import Annotated from functools import wraps -from fastapi import Cookie, Depends, Query, Request, HTTPException, WebSocket +from fastapi import Cookie, Depends, Query, HTTPException, WebSocket from unipoll_api.account_manager import active_user, get_current_active_user from unipoll_api.documents import ResourceID, Workspace, Group, Account, Poll, Policy -from unipoll_api.utils import permissions as Permissions from unipoll_api import exceptions as Exceptions -from unipoll_api.utils.path_operations import extract_action_from_path, extract_resourceID_from_path # Wrapper to handle exceptions and raise HTTPException