Skip to content

Commit

Permalink
Merge pull request #49 from unipoll/front-end
Browse files Browse the repository at this point in the history
Updates for Front End
  • Loading branch information
mike-pisman authored Jul 7, 2023
2 parents a6276b9 + 2436c4d commit d45e8fc
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ build-backend = "setuptools.build_meta"


[tool.semantic_release]
version_source = "tag"
version_source = "tag_only"
branch = "main"
major_on_zero = true
upload_to_pypi = false
upload_to_repository = true
# upload_to_repository = true
upload_to_release = true
commit_version_number = true
tag_commit = true
Expand Down
2 changes: 1 addition & 1 deletion src/actions/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async def remove_workspace_member(workspace: Workspace, account_id: ResourceID):
if not account:
raise AccountExceptions.AccountNotFound(account_id)

if account.id not in [ResourceID(member.ref.id) for member in workspace.members]:
if account.id not in [ResourceID(member.id) for member in workspace.members]:
raise WorkspaceExceptions.UserNotMember(workspace, account)
return await workspace.remove_member(account)

Expand Down
6 changes: 3 additions & 3 deletions src/models/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ async def remove_member(self, account, save: bool = True) -> bool:
# Remove the account from the group
# await self.fetch_link("members")
for i, member in enumerate(self.members):
if account.id == member.ref.id:
if account.id == member.id:
self.members.remove(member)
Debug.info(f"Removed member {member.ref.id} from {self.resource_type} {self.id}") # type: ignore
Debug.info(f"Removed member {member.id} from {self.resource_type} {self.id}") # type: ignore
break

# Remove the policy from the group
await self.fetch_link("policies")
# await self.fetch_link("policies")
for policy in self.policies:
# pc = await policy.policy_holder.fetch() # type: ignore
pc = policy.policy_holder # type: ignore
Expand Down
10 changes: 10 additions & 0 deletions src/routes/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
router = APIRouter()


@router.get("",
response_model=AccountSchemas.AccountList)
async def get_all_accounts():
try:
accounts = [AccountSchemas.AccountShort(**account.dict()) for account in await Account.find_all().to_list()]
return AccountSchemas.AccountList(accounts=accounts)
except APIException as e:
raise HTTPException(status_code=e.code, detail=str(e))


# Delete current user account
@router.delete("/me",
status_code=status.HTTP_204_NO_CONTENT)
Expand Down
4 changes: 4 additions & 0 deletions src/schemas/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class AccountShort(BaseModel):
last_name: str


class AccountList(BaseModel):
accounts: list[AccountShort]


class CreateAccount(schemas.BaseUserCreate):
email: EmailStr = Field(...)
first_name: str = Field(
Expand Down
7 changes: 6 additions & 1 deletion src/utils/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def parse_action_file(resource_type: str) -> Permissions:


WORKSPACE_ALL_PERMISSIONS = WorkspacePermissions(-1) # type: ignore
WORKSPACE_BASIC_PERMISSIONS = (WorkspacePermissions["get_workspace"]) # type: ignore
# WORKSPACE_BASIC_PERMISSIONS = (WorkspacePermissions["get_workspace"]) # type: ignore
WORKSPACE_BASIC_PERMISSIONS = (WorkspacePermissions["get_workspace"] + # type: ignore
WorkspacePermissions["get_workspace_members"] + # type: ignore
WorkspacePermissions["get_workspace_policy"] + # type: ignore
WorkspacePermissions["get_workspace_policies"] + # type: ignore
WorkspacePermissions["get_groups"]) # type: ignore
# Example: (WorkspacePermissions["get_workspace"] + WorkspacePermissions["get_workspace_members"])

GROUP_ALL_PERMISSIONS = GroupPermissions(-1) # type: ignore
Expand Down

0 comments on commit d45e8fc

Please sign in to comment.