Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ACM v0.21 and open more views to logged in users #334

Merged
merged 19 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a9bce95
Update ACM version to v0.21 in requirements file
amstilp Dec 1, 2023
74115f6
Update adapters to have staff_view and _view for list_table_class
amstilp Dec 1, 2023
c0b7052
Rename OpenAccess workspace tables to match Staff/user convention
amstilp Dec 1, 2023
731918d
Use the OpenAccessWorkspaceUserTable in the adapter
amstilp Dec 1, 2023
2523142
Add a link to the workspace in the OpenAccessUserTable
amstilp Dec 1, 2023
f3965a6
Rename CDSAWorkspace tables for Staff/User convention
amstilp Dec 2, 2023
0be0a37
Show the CDSAWorkspaceUserTable to users with view permission
amstilp Dec 2, 2023
0e6557e
Add link to workspace in CDSAWorkspaceUserTable
amstilp Dec 2, 2023
0635134
Renmae dbGaPWorkspace tables to match Staff/User convention
amstilp Dec 2, 2023
00e7ebd
Show view users the dbGaPWorkspaceUserTable
amstilp Dec 2, 2023
0e3b4d2
Add link to the workspace in dbGaPWorkspaceUserTable
amstilp Dec 2, 2023
37ac937
Remove commented-out table definition
amstilp Dec 2, 2023
2f1e8ca
Show view users a different DefaultWorkspaceTable
amstilp Dec 2, 2023
c8fd182
Make DUO detail views open to people with View permission
amstilp Dec 4, 2023
5767f7b
Move DUO OLS links to details table
amstilp Dec 4, 2023
f987699
Move account link instruction into an alert
amstilp Dec 4, 2023
0d58b62
Add a link to the WorkspaceLandingPage to the home grid
amstilp Dec 4, 2023
0a0dab6
Run pip-compile to get updated ACM version in requirements.txt
amstilp Dec 4, 2023
9729f29
Rearrange workspace adapters and update descriptions for clarity
amstilp Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,14 @@
ANVIL_API_SERVICE_ACCOUNT_FILE = env("ANVIL_API_SERVICE_ACCOUNT_FILE")
# Specify workspace adapters.
ANVIL_WORKSPACE_ADAPTERS = [
"primed.miscellaneous_workspaces.adapters.TemplateWorkspaceAdapter",
"primed.dbgap.adapters.dbGaPWorkspaceAdapter",
"primed.cdsa.adapters.CDSAWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.OpenAccessWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.SimulatedDataWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.ResourceWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.ConsortiumDevelWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.TemplateWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.DataPrepWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.ResourceWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.SimulatedDataWorkspaceAdapter",
"primed.miscellaneous_workspaces.adapters.OpenAccessWorkspaceAdapter",
]
ANVIL_ACCOUNT_ADAPTER = "primed.primed_anvil.adapters.AccountAdapter"

Expand Down
5 changes: 3 additions & 2 deletions primed/cdsa/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ class CDSAWorkspaceAdapter(BaseWorkspaceAdapter):
type = "cdsa"
name = "CDSA workspace"
description = (
"Workspaces containing data from the Consortium Data Sharing Agreement."
"Workspaces containing data from the Consortium Data Sharing Agreement"
)
list_table_class = tables.CDSAWorkspaceTable
list_table_class_staff_view = tables.CDSAWorkspaceStaffTable
list_table_class_view = tables.CDSAWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.CDSAWorkspace
workspace_data_form_class = forms.CDSAWorkspaceForm
Expand Down
6 changes: 3 additions & 3 deletions primed/cdsa/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def render_date_shared(self, record):
return "—"


class CDSAWorkspaceTable(tables.Table):
class CDSAWorkspaceStaffTable(tables.Table):
"""A table for the CDSAWorkspace model."""

name = tables.Column(linkify=True)
Expand Down Expand Up @@ -324,10 +324,10 @@ class Meta:
order_by = ("name",)


class CDSAWorkspaceLimitedViewTable(tables.Table):
class CDSAWorkspaceUserTable(tables.Table):
"""A table for the CDSAWorkspace model."""

name = tables.Column()
name = tables.Column(linkify=True)
billing_project = tables.Column()
cdsaworkspace__data_use_permission__abbreviation = tables.Column(
verbose_name="DUO permission",
Expand Down
12 changes: 6 additions & 6 deletions primed/cdsa/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ def test_ordering(self):
self.assertEqual(table.data[1], instance_1)


class CDSAWorkspaceTableTest(TestCase):
"""Tests for the CDSAWorkspaceTable class."""
class CDSAWorkspaceStaffTableTest(TestCase):
"""Tests for the CDSAWorkspaceStaffTable class."""

model = Workspace
model_factory = factories.CDSAWorkspaceFactory
table_class = tables.CDSAWorkspaceTable
table_class = tables.CDSAWorkspaceStaffTable

def test_row_count_with_no_objects(self):
table = self.table_class(self.model.objects.all())
Expand All @@ -477,12 +477,12 @@ def test_ordering(self):
self.assertEqual(table.data[1], instance_1.workspace)


class CDSAWorkspaceLimitedViewTableTest(TestCase):
"""Tests for the CDSAWorkspaceLimitedViewTable class."""
class CDSAWorkspaceUserTableTest(TestCase):
"""Tests for the CDSAWorkspaceUserTable class."""

model = Workspace
model_factory = factories.CDSAWorkspaceFactory
table_class = tables.CDSAWorkspaceLimitedViewTable
table_class = tables.CDSAWorkspaceUserTable

def test_row_count_with_no_objects(self):
table = self.table_class(self.model.objects.all())
Expand Down
3 changes: 2 additions & 1 deletion primed/dbgap/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class dbGaPWorkspaceAdapter(BaseWorkspaceAdapter):
type = "dbgap"
name = "dbGaP workspace"
description = "Workspaces containing data from released dbGaP accessions"
list_table_class = tables.dbGaPWorkspaceTable
list_table_class_staff_view = tables.dbGaPWorkspaceStaffTable
list_table_class_view = tables.dbGaPWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.dbGaPWorkspace
workspace_data_form_class = forms.dbGaPWorkspaceForm
Expand Down
6 changes: 3 additions & 3 deletions primed/dbgap/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def render_dbgap_phs(self, value):
return "phs{0:06d}".format(value)


class dbGaPWorkspaceTable(tables.Table):
class dbGaPWorkspaceStaffTable(tables.Table):
"""Class to render a table of Workspace objects with dbGaPWorkspace workspace data."""

name = tables.columns.Column(linkify=True)
Expand Down Expand Up @@ -116,10 +116,10 @@ def render_number_approved_dars(self, record):
return n


class dbGaPWorkspaceLimitedViewTable(tables.Table):
class dbGaPWorkspaceUserTable(tables.Table):
"""Class to render a table of Workspace objects with dbGaPWorkspace workspace data."""

name = tables.columns.Column()
name = tables.columns.Column(linkify=True)
billing_project = tables.Column()
dbgap_accession = dbGaPAccessionColumn(
accessor="dbgapworkspace__get_dbgap_accession",
Expand Down
8 changes: 4 additions & 4 deletions primed/dbgap/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ def test_ordering(self):
self.assertEqual(table.data[1], instance_1)


class dbGaPWorkspaceTableTest(TestCase):
class dbGaPWorkspaceStaffTableTest(TestCase):
model = acm_models.Workspace
model_factory = factories.dbGaPWorkspaceFactory
table_class = tables.dbGaPWorkspaceTable
table_class = tables.dbGaPWorkspaceStaffTable

def test_row_count_with_no_objects(self):
table = self.table_class(self.model.objects.all())
Expand Down Expand Up @@ -206,10 +206,10 @@ def test_render_number_approved_dars_only_most_recent(self):
# self.assertEqual("", table.rows[0].get_cell_value("is_shared"))


class dbGaPWorkspaceLimitedViewTableTest(TestCase):
class dbGaPWorkspaceUserTableTest(TestCase):
model = acm_models.Workspace
model_factory = factories.dbGaPWorkspaceFactory
table_class = tables.dbGaPWorkspaceTable
table_class = tables.dbGaPWorkspaceStaffTable

def test_row_count_with_no_objects(self):
table = self.table_class(self.model.objects.all())
Expand Down
4 changes: 2 additions & 2 deletions primed/dbgap/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_workspace_table(self):
response = self.get_view()(request, dbgap_phs=self.obj.dbgap_phs)
self.assertIn("workspace_table", response.context_data)
self.assertIsInstance(
response.context_data["workspace_table"], tables.dbGaPWorkspaceTable
response.context_data["workspace_table"], tables.dbGaPWorkspaceStaffTable
)

def test_workspace_table_none(self):
Expand Down Expand Up @@ -856,7 +856,7 @@ def test_view_has_correct_table_class(self):
response = self.get_view()(request, workspace_type=self.workspace_type)
self.assertIn("table", response.context_data)
self.assertIsInstance(
response.context_data["table"], tables.dbGaPWorkspaceTable
response.context_data["table"], tables.dbGaPWorkspaceStaffTable
)


Expand Down
2 changes: 1 addition & 1 deletion primed/dbgap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_object(self, queryset=None):
return obj

def get_table(self):
return tables.dbGaPWorkspaceTable(
return tables.dbGaPWorkspaceStaffTable(
Workspace.objects.filter(dbgapworkspace__dbgap_study_accession=self.object),
exclude=(
"dbgapworkspace__dbgap_study_accession__study",
Expand Down
8 changes: 4 additions & 4 deletions primed/duo/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DataUsePermissionListTest(TestCase):
def setUp(self):
"""Set up test class."""
self.factory = RequestFactory()
# Create a user with both view and edit permission.
# Create a user with staff view permission.
self.user = UserFactory.create(username="test", password="test")
self.user.user_permissions.add(
Permission.objects.get(
Expand Down Expand Up @@ -122,11 +122,11 @@ class DataUsePermissionDetailTest(TestCase):
def setUp(self):
"""Set up test class."""
self.factory = RequestFactory()
# Create a user with both view and edit permission.
# Create a user with view permission.
self.user = UserFactory.create(username="test", password="test")
self.user.user_permissions.add(
Permission.objects.get(
codename=AnVILProjectManagerAccess.STAFF_VIEW_PERMISSION_CODENAME
codename=AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME
)
)

Expand Down Expand Up @@ -282,7 +282,7 @@ def setUp(self):
self.user = UserFactory.create(username="test", password="test")
self.user.user_permissions.add(
Permission.objects.get(
codename=AnVILProjectManagerAccess.STAFF_VIEW_PERMISSION_CODENAME
codename=AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME
)
)

Expand Down
9 changes: 6 additions & 3 deletions primed/duo/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from anvil_consortium_manager.auth import AnVILConsortiumManagerStaffViewRequired
from anvil_consortium_manager.auth import (
AnVILConsortiumManagerStaffViewRequired,
AnVILConsortiumManagerViewRequired,
)
from django.http import Http404
from django.views.generic import DetailView, ListView

Expand All @@ -18,7 +21,7 @@ def get_context_data(self, **kwargs):
return context


class DataUsePermissionDetail(AnVILConsortiumManagerStaffViewRequired, DetailView):
class DataUsePermissionDetail(AnVILConsortiumManagerViewRequired, DetailView):

model = models.DataUsePermission

Expand Down Expand Up @@ -51,7 +54,7 @@ def get_context_data(self, **kwargs):
return context


class DataUseModifierDetail(AnVILConsortiumManagerStaffViewRequired, DetailView):
class DataUseModifierDetail(AnVILConsortiumManagerViewRequired, DetailView):

model = models.DataUseModifier

Expand Down
29 changes: 20 additions & 9 deletions primed/miscellaneous_workspaces/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from anvil_consortium_manager.adapters.workspace import BaseWorkspaceAdapter
from anvil_consortium_manager.forms import WorkspaceForm

from primed.primed_anvil.tables import DefaultWorkspaceTable
from primed.primed_anvil.tables import (
DefaultWorkspaceStaffTable,
DefaultWorkspaceUserTable,
)

from . import forms, models, tables

Expand All @@ -14,7 +17,8 @@ class SimulatedDataWorkspaceAdapter(BaseWorkspaceAdapter):
type = "simulated_data"
name = "Simulated Data workspace"
description = "Workspaces containing simulated data"
list_table_class = DefaultWorkspaceTable
list_table_class_staff_view = DefaultWorkspaceStaffTable
list_table_class_view = DefaultWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.SimulatedDataWorkspace
workspace_data_form_class = forms.SimulatedDataWorkspaceForm
Expand All @@ -29,7 +33,8 @@ class ConsortiumDevelWorkspaceAdapter(BaseWorkspaceAdapter):
type = "devel"
name = "Consortium development workspace"
description = "Workspaces intended for consortium development of methods"
list_table_class = DefaultWorkspaceTable
list_table_class_staff_view = DefaultWorkspaceStaffTable
list_table_class_view = DefaultWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.ConsortiumDevelWorkspace
workspace_data_form_class = forms.ConsortiumDevelWorkspaceForm
Expand All @@ -42,7 +47,8 @@ class ResourceWorkspaceAdapter(BaseWorkspaceAdapter):
type = "resource"
name = "Resource workspace"
description = "Workspaces containing consortium resources (e.g., examples of using AnVIL, data inventories)"
list_table_class = DefaultWorkspaceTable
list_table_class_staff_view = DefaultWorkspaceStaffTable
list_table_class_view = DefaultWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.ResourceWorkspace
workspace_data_form_class = forms.ResourceWorkspaceForm
Expand All @@ -54,8 +60,11 @@ class TemplateWorkspaceAdapter(BaseWorkspaceAdapter):

type = "template"
name = "Template workspace"
description = "Template workspaces that can be cloned to create other workspaces"
list_table_class = DefaultWorkspaceTable
description = (
"Template workspaces that will be cloned by the CC to create other workspaces"
)
list_table_class_staff_view = DefaultWorkspaceStaffTable
list_table_class_view = DefaultWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.TemplateWorkspace
workspace_data_form_class = forms.TemplateWorkspaceForm
Expand All @@ -68,7 +77,8 @@ class OpenAccessWorkspaceAdapter(BaseWorkspaceAdapter):
type = "open_access"
name = "Open access workspace"
description = "Workspaces containing open access data"
list_table_class = tables.OpenAccessWorkspaceTable
list_table_class_staff_view = tables.OpenAccessWorkspaceStaffTable
list_table_class_view = tables.OpenAccessWorkspaceUserTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.OpenAccessWorkspace
workspace_data_form_class = forms.OpenAccessWorkspaceForm
Expand All @@ -82,8 +92,9 @@ class DataPrepWorkspaceAdapter(BaseWorkspaceAdapter):

type = "data_prep"
name = "Data prep workspace"
description = "Workspaces used to prepare data."
list_table_class = tables.DataPrepWorkspaceTable
description = "Workspaces used to prepare data for sharing or update data that is already shared"
list_table_class_staff_view = tables.DataPrepWorkspaceTable
list_table_class_view = tables.DataPrepWorkspaceTable
workspace_form_class = WorkspaceForm
workspace_data_model = models.DataPrepWorkspace
workspace_data_form_class = forms.DataPrepWorkspaceForm
Expand Down
6 changes: 3 additions & 3 deletions primed/miscellaneous_workspaces/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)


class OpenAccessWorkspaceTable(tables.Table):
class OpenAccessWorkspaceStaffTable(tables.Table):
"""Class to render a table of Workspace objects with OpenAccessWorkspace workspace data."""

name = tables.columns.Column(linkify=True)
Expand All @@ -27,10 +27,10 @@ class Meta:
order_by = ("name",)


class OpenAccessWorkspaceLimitedViewTable(tables.Table):
class OpenAccessWorkspaceUserTable(tables.Table):
"""Class to render a table of Workspace objects with OpenAccessWorkspace workspace data."""

name = tables.columns.Column()
name = tables.columns.Column(linkify=True)
billing_project = tables.Column()
is_shared = WorkspaceSharedWithConsortiumColumn()

Expand Down
12 changes: 6 additions & 6 deletions primed/miscellaneous_workspaces/tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from . import factories


class OpenAccessWorkspaceTableTest(TestCase):
"""Tests for the OpenAccessWorkspaceTable table."""
class OpenAccessWorkspaceStaffTableTest(TestCase):
"""Tests for the OpenAccessWorkspaceStaffTable table."""

model_factory = factories.OpenAccessWorkspaceFactory
table_class = tables.OpenAccessWorkspaceTable
table_class = tables.OpenAccessWorkspaceStaffTable

def test_row_count_with_no_objects(self):
table = self.table_class(Workspace.objects.all())
Expand All @@ -28,11 +28,11 @@ def test_row_count_with_two_objects(self):
self.assertEqual(len(table.rows), 2)


class OpenAccessWorkspaceLimitedViewTableTest(TestCase):
"""Tests for the OpenAccessWorkspaceTable table."""
class OpenAccessWorkspaceUserTableTest(TestCase):
"""Tests for the OpenAccessWorkspaceStaffTable table."""

model_factory = factories.OpenAccessWorkspaceFactory
table_class = tables.OpenAccessWorkspaceLimitedViewTable
table_class = tables.OpenAccessWorkspaceUserTable

def test_row_count_with_no_objects(self):
table = self.table_class(Workspace.objects.all())
Expand Down
Loading