Skip to content

Commit

Permalink
Add collab analysis links to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
amstilp committed Jan 25, 2024
1 parent be3fa7f commit 7cf6745
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
42 changes: 42 additions & 0 deletions primed/collaborative_analysis/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,48 @@
User = get_user_model()


class NavbarTest(TestCase):
"""Tests for the navbar involving Collaborative Analysis links."""

def setUp(self):
"""Set up test class."""
self.factory = RequestFactory()
# Create a user with both view and edit permission.

def get_url(self, *args):
"""Get the url for the view being tested."""
# Use the workspace landing page, since view users can see it.
return reverse("anvil_consortium_manager:workspaces:landing_page", args=args)

def test_links_for_staff_view(self):
"""Returns successful response code."""
user = User.objects.create_user(username="test", password="test")
user.user_permissions.add(
Permission.objects.get(
codename=AnVILProjectManagerAccess.STAFF_VIEW_PERMISSION_CODENAME
)
)
self.client.force_login(user)
response = self.client.get(self.get_url())
self.assertContains(
response, reverse("collaborative_analysis:workspaces:audit_all")
)

def test_links_for_view(self):
"""Returns successful response code."""
user = User.objects.create_user(username="test", password="test")
user.user_permissions.add(
Permission.objects.get(
codename=AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME
)
)
self.client.force_login(user)
response = self.client.get(self.get_url())
self.assertNotContains(
response, reverse("collaborative_analysis:workspaces:audit_all")
)


class CollaborativeAnalysisWorkspaceDetailTest(TestCase):
"""Tests of the WorkspaceDetail view from ACM with this app's CollaborativeAnalysisWorkspace model."""

Expand Down
1 change: 1 addition & 0 deletions primed/templates/anvil_consortium_manager/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

{% include 'cdsa/nav_items.html' %}

{% include 'collaborative_analysis/nav_items.html' %}

{{ block.super }}

Expand Down
13 changes: 13 additions & 0 deletions primed/templates/collaborative_analysis/nav_items.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDarkDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Collaborative Analysis
</a>
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="navbarDarkDropdownMenuLink">
{% if perms.anvil_consortium_manager.anvil_consortium_manager_staff_view %}
<li>
<a class="dropdown-item" href="{% url 'collaborative_analysis:workspaces:audit_all' %}">Audit access</a>
</li>
{% endif %}

</ul>
</li>

0 comments on commit 7cf6745

Please sign in to comment.