Skip to content

Commit

Permalink
Rename table for sharing strategy changes.
Browse files Browse the repository at this point in the history
Rename the WorkspaceSharedWIthConsortiumTable to reflect the new
sharing structure better - WorkspaceConsortiumAccessTable. Also
rename the is_shared column to consortium_access.
  • Loading branch information
amstilp committed Aug 7, 2023
1 parent cc43c16 commit 1ca1720
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
34 changes: 17 additions & 17 deletions gregor_django/gregor_anvil/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,26 @@ def render_cycle(self, record):
return str(record)


class WorkspaceSharedWithConsortiumTable(tables.Table):
class WorkspaceConsortiumAccessTable(tables.Table):
"""Table including a column to indicate if a workspace is shared with PRIMED_ALL."""

is_shared = tables.columns.Column(
consortium_access = tables.columns.Column(
accessor="pk",
verbose_name="Shared with GREGoR?",
verbose_name="Consortium access?",
orderable=False,
)

def render_is_shared(self, record):
def render_consortium_access(self, record):
try:
group = ManagedGroup.objects.get(name="GREGOR_ALL")
except ManagedGroup.DoesNotExist:
is_shared = False
has_consortium_access = False
else:
is_shared = record.is_in_authorization_domain(group) and record.is_shared(
has_consortium_access = record.is_in_authorization_domain(
group
)
) and record.is_shared(group)

if is_shared:
if has_consortium_access:
icon = "check-circle-fill"
color = "green"
value = format_html(
Expand All @@ -110,7 +110,7 @@ def render_is_shared(self, record):
return value


class DefaultWorkspaceTable(WorkspaceSharedWithConsortiumTable, tables.Table):
class DefaultWorkspaceTable(WorkspaceConsortiumAccessTable, tables.Table):
"""Class to use for default workspace tables in GREGoR."""

name = tables.Column(linkify=True, verbose_name="Workspace")
Expand All @@ -128,12 +128,12 @@ class Meta:
"name",
"billing_project",
"number_groups",
"is_shared",
"consortium_access",
)
order_by = ("name",)


class UploadWorkspaceTable(WorkspaceSharedWithConsortiumTable, tables.Table):
class UploadWorkspaceTable(WorkspaceConsortiumAccessTable, tables.Table):
"""A table for Workspaces that includes fields from UploadWorkspace."""

name = tables.columns.Column(linkify=True)
Expand All @@ -146,11 +146,11 @@ class Meta:
"uploadworkspace__upload_cycle",
"uploadworkspace__research_center",
"uploadworkspace__consent_group",
"is_shared",
"consortium_access",
)


class TemplateWorkspaceTable(WorkspaceSharedWithConsortiumTable, tables.Table):
class TemplateWorkspaceTable(WorkspaceConsortiumAccessTable, tables.Table):
"""A table for Workspaces that includes fields from TemplateWorkspace."""

name = tables.columns.Column(linkify=True)
Expand All @@ -160,7 +160,7 @@ class Meta:
fields = (
"name",
"templateworkspace__intended_use",
"is_shared",
"consortium_access",
)


Expand All @@ -183,7 +183,7 @@ def render_workspace_type(self, value):


class CombinedConsortiumDataWorkspaceTable(
WorkspaceSharedWithConsortiumTable, tables.Table
WorkspaceConsortiumAccessTable, tables.Table
):
"""A table for Workspaces that includes fields from CombinedConsortiumDataWorkspace."""

Expand Down Expand Up @@ -230,7 +230,7 @@ class Meta:
)


class DCCProcessedDataWorkspaceTable(WorkspaceSharedWithConsortiumTable, tables.Table):
class DCCProcessedDataWorkspaceTable(WorkspaceConsortiumAccessTable, tables.Table):
"""A table for Workspaces that includes fields from DCCProcessedDataWorkspace."""

name = tables.columns.Column(linkify=True)
Expand All @@ -242,5 +242,5 @@ class Meta:
"name",
"dccprocesseddataworkspace__upload_cycle",
"dccprocesseddataworkspace__consent_group",
"is_shared",
"consortium_access",
)
46 changes: 23 additions & 23 deletions gregor_django/gregor_anvil/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_row_count_with_two_objects(self):
self.assertEqual(len(table.rows), 2)


class WorkspaceSharedWithConsortiumTableTest(TestCase):
class WorkspaceConsortiumAccessTableTest(TestCase):
"""Tests for the is_shared column."""

def setUp(self):
Expand All @@ -126,29 +126,29 @@ def setUp(self):
def test_is_shared_no_auth_domain_not_shared(self):
"""Workspace has no auth domain and is not shared with GREGOR_ALL."""
workspace = WorkspaceFactory.create()
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_no_auth_domain_shared(self):
"""Workspace has no auth domain and is shared with GREGOR_ALL."""
workspace = WorkspaceFactory.create()
WorkspaceGroupSharingFactory.create(workspace=workspace, group=self.gregor_all)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_no_auth_domain_shared_other_group(self):
"""Workspace has no auth domain and is shared with a different group."""
workspace = WorkspaceFactory.create()
WorkspaceGroupSharingFactory.create(workspace=workspace)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_not_shared_not_in_auth_domain(self):
"""GREGOR_ALL is not in auth domain and workspace is not shared."""
workspace = WorkspaceFactory.create()
WorkspaceAuthorizationDomainFactory.create(workspace=workspace)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_not_shared_in_auth_domain(self):
"""GREGOR_ALL is in auth domain and workspace is not shared."""
Expand All @@ -157,8 +157,8 @@ def test_is_shared_one_auth_domain_not_shared_in_auth_domain(self):
GroupGroupMembershipFactory.create(
parent_group=auth_domain.group, child_group=self.gregor_all
)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_different_group_in_auth_domain(self):
"""GREGOR_ALL is in auth domain and workspace is shared with a different group."""
Expand All @@ -168,16 +168,16 @@ def test_is_shared_one_auth_domain_shared_different_group_in_auth_domain(self):
parent_group=auth_domain.group, child_group=self.gregor_all
)
WorkspaceGroupSharingFactory.create(workspace=workspace)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_with_gregor_all_not_in_auth_domain(self):
"""GREGOR_ALL is not in auth domain and workspace is shared with GREGOR_ALL."""
workspace = WorkspaceFactory.create()
WorkspaceAuthorizationDomainFactory.create(workspace=workspace)
WorkspaceGroupSharingFactory.create(workspace=workspace, group=self.gregor_all)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_with_auth_domain_not_in_auth_domain(self):
"""GREGOR_ALL is not in auth domain and workspace is shared with its auth domain."""
Expand All @@ -186,8 +186,8 @@ def test_is_shared_one_auth_domain_shared_with_auth_domain_not_in_auth_domain(se
WorkspaceGroupSharingFactory.create(
workspace=workspace, group=auth_domain.group
)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_with_gregor_all_in_auth_domain(self):
"""GREGOR_ALL is in auth domain and workspace is shared with GREGOR_ALL."""
Expand All @@ -197,8 +197,8 @@ def test_is_shared_one_auth_domain_shared_with_gregor_all_in_auth_domain(self):
parent_group=auth_domain.group, child_group=self.gregor_all
)
WorkspaceGroupSharingFactory.create(workspace=workspace, group=self.gregor_all)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_with_auth_domain_in_auth_domain(self):
"""GREGOR_ALL is in auth domain and workspace is shared with its auth domain."""
Expand All @@ -210,8 +210,8 @@ def test_is_shared_one_auth_domain_shared_with_auth_domain_in_auth_domain(self):
WorkspaceGroupSharingFactory.create(
workspace=workspace, group=auth_domain.group
)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertIn("check-circle-fill", table.render_consortium_access(workspace))

def test_is_shared_one_auth_domain_shared_with_different_group_in_auth_domain(self):
"""GREGOR_ALL is in auth domain and workspace is shared with a different group."""
Expand All @@ -221,8 +221,8 @@ def test_is_shared_one_auth_domain_shared_with_different_group_in_auth_domain(se
parent_group=auth_domain.group, child_group=self.gregor_all
)
WorkspaceGroupSharingFactory.create(workspace=workspace)
table = tables.WorkspaceSharedWithConsortiumTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_is_shared(workspace))
table = tables.WorkspaceConsortiumAccessTable(Workspace.objects.all())
self.assertNotIn("check-circle-fill", table.render_consortium_access(workspace))


class UploadWorkspaceTableTest(TestCase):
Expand Down

0 comments on commit 1ca1720

Please sign in to comment.