Skip to content

Commit

Permalink
Include checkboxes showing access in collab workspace audit
Browse files Browse the repository at this point in the history
In the audit results, show a checkbox to indicate if an account
has current access to the workspace or not.
  • Loading branch information
amstilp committed Jan 25, 2024
1 parent 5f021a2 commit be3fa7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions primed/collaborative_analysis/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from django.urls import reverse
from django.utils.safestring import mark_safe

from primed.primed_anvil.tables import BooleanIconColumn

from . import models


Expand All @@ -21,6 +23,7 @@ class AccessAuditResult:
collaborative_analysis_workspace: models.CollaborativeAnalysisWorkspace
member: Union[Account, ManagedGroup]
note: str
has_access: bool

def get_action_url(self):
"""The URL that handles the action needed."""
Expand All @@ -35,6 +38,7 @@ def get_table_dictionary(self):
row = {
"workspace": self.collaborative_analysis_workspace,
"member": self.member,
"has_access": self.has_access,
"note": self.note,
"action": self.get_action(),
"action_url": self.get_action_url(),
Expand All @@ -46,16 +50,22 @@ def get_table_dictionary(self):
class VerifiedAccess(AccessAuditResult):
"""Audit results class for when an account has verified access."""

has_access: bool = True


@dataclass
class VerifiedNoAccess(AccessAuditResult):
"""Audit results class for when an account has verified no access."""

has_access: bool = False


@dataclass
class GrantAccess(AccessAuditResult):
"""Audit results class for when an account should be granted access."""

has_access: bool = False

def get_action(self):
return "Grant access"

Expand All @@ -82,6 +92,8 @@ def get_action_url(self):
class RemoveAccess(AccessAuditResult):
"""Audit results class for when access for an account should be removed."""

has_access: bool = True

def get_action(self):
return "Remove access"

Expand Down Expand Up @@ -109,6 +121,7 @@ class AccessAuditResultsTable(tables.Table):

workspace = tables.Column(linkify=True)
member = tables.Column(linkify=True)
has_access = BooleanIconColumn(show_false_icon=True)
note = tables.Column()
action = tables.Column()

Expand All @@ -135,6 +148,7 @@ class CollaborativeAnalysisWorkspaceAccessAudit:
"Account is not in all source auth domains for this workspace."
)
NOT_IN_ANALYST_GROUP = "Account is not in the analyst group for this workspace."
INACTIVE_ACCOUNT = "Account is inactive."

# Errors.
UNEXPECTED_GROUP_ACCESS = "Unexpected group added to the auth domain."
Expand Down
2 changes: 2 additions & 0 deletions primed/collaborative_analysis/tests/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,13 +1095,15 @@ def test_two_rows(self):
{
"workspace": workspace,
"member": member_account,
"has_access": True,
"note": "a note",
"action": "",
"action_url": "",
},
{
"workspace": workspace,
"member": member_group,
"has_access": False,
"note": "a note",
"action": "",
"action_url": "",
Expand Down

0 comments on commit be3fa7f

Please sign in to comment.