Skip to content

Commit

Permalink
Merge pull request #283 from UW-GAC/feature/share-with-auth-domain-bu…
Browse files Browse the repository at this point in the history
…tton

Add a "Share with auth domain" button to workspace detail pages
  • Loading branch information
amstilp authored Aug 7, 2023
2 parents 7b7cbf7 + 950a287 commit 8a6f7d6
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
50 changes: 50 additions & 0 deletions gregor_django/gregor_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,11 @@ def setUp(self):
codename=acm_models.AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME
)
)
self.user.user_permissions.add(
Permission.objects.get(
codename=acm_models.AnVILProjectManagerAccess.EDIT_PERMISSION_CODENAME
)
)
self.object = factories.UploadWorkspaceFactory.create()

def get_url(self, *args):
Expand All @@ -977,6 +982,26 @@ def test_status_code(self):
)
self.assertEqual(response.status_code, 200)

def test_contains_share_with_auth_domain_button(self):
acm_factories.WorkspaceAuthorizationDomainFactory.create(
workspace=self.object.workspace, group__name="test_auth"
)
self.client.force_login(self.user)
response = self.client.get(
self.get_url(
self.object.workspace.billing_project.name, self.object.workspace.name
)
)
url = reverse(
"anvil_consortium_manager:workspaces:sharing:new_by_group",
args=[
self.object.workspace.billing_project.name,
self.object.workspace.name,
"test_auth",
],
)
self.assertContains(response, url)


class UploadWorkspaceListTest(TestCase):
"""Tests of the anvil_consortium_manager WorkspaceList view using this app's adapter."""
Expand Down Expand Up @@ -1472,6 +1497,11 @@ def setUp(self):
codename=acm_models.AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME
)
)
self.user.user_permissions.add(
Permission.objects.get(
codename=acm_models.AnVILProjectManagerAccess.EDIT_PERMISSION_CODENAME
)
)
self.object = factories.CombinedConsortiumDataWorkspaceFactory.create()

def get_url(self, *args):
Expand Down Expand Up @@ -1540,6 +1570,26 @@ def test_contains_upload_workspaces_from_previous_cycles(self):
upload_workspace_2, response.context_data["upload_workspace_table"].data
)

def test_contains_share_with_auth_domain_button(self):
acm_factories.WorkspaceAuthorizationDomainFactory.create(
workspace=self.object.workspace, group__name="test_auth"
)
self.client.force_login(self.user)
response = self.client.get(
self.get_url(
self.object.workspace.billing_project.name, self.object.workspace.name
)
)
url = reverse(
"anvil_consortium_manager:workspaces:sharing:new_by_group",
args=[
self.object.workspace.billing_project.name,
self.object.workspace.name,
"test_auth",
],
)
self.assertContains(response, url)


class ReleaseWorkspaceDetailTest(TestCase):
"""Tests of the anvil_consortium_manager WorkspaceDetail view using the ReleaseWorkspaceAdapter."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,19 @@
<dt class="col-sm-2">Upload cycle</dt> <dd class="col-sm-10"><a href="{{ object.combinedconsortiumdataworkspace.upload_cycle.get_absolute_url }}">{{ object.combinedconsortiumdataworkspace.upload_cycle }}</a></dd>
</dl>
{% endblock workspace_data %}


{% block action_buttons %}

{% if show_edit_links %}
{% if object.authorization_domains.first %}
<p>
<a href="{% url 'anvil_consortium_manager:workspaces:sharing:new_by_group' billing_project_slug=object.billing_project.name workspace_slug=object.name group_slug=object.authorization_domains.first.name %}" class="btn btn-primary" role="button">Share with auth domain</a>
</p>
{% else %}
<p>no auth domain</p>
{% endif %}
{% endif %}

{{ block.super }}
{% endblock action_buttons %}
14 changes: 14 additions & 0 deletions gregor_django/templates/gregor_anvil/uploadworkspace_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,17 @@ <h2 class="accordion-header" id="headingDUL">

{{ block.super }}
{% endblock after_panel %}

{% block action_buttons %}
{% if show_edit_links %}
{% if object.authorization_domains.first %}
<p>
<a href="{% url 'anvil_consortium_manager:workspaces:sharing:new_by_group' billing_project_slug=object.billing_project.name workspace_slug=object.name group_slug=object.authorization_domains.first.name %}" class="btn btn-primary" role="button">Share with auth domain</a>
</p>
{% else %}
<p>no auth domain</p>
{% endif %}
{% endif %}

{{ block.super }}
{% endblock action_buttons %}

0 comments on commit 8a6f7d6

Please sign in to comment.