From 37d47e9259e862b45ebb0e8b1346fa8627c9b4d9 Mon Sep 17 00:00:00 2001 From: Adrienne Stilp Date: Thu, 21 Mar 2024 10:31:40 -0700 Subject: [PATCH] Show primary cdsa link on CDSAWorkspace detail page --- primed/cdsa/tests/test_views.py | 24 +++++++++++++++++++ .../templates/cdsa/cdsaworkspace_detail.html | 19 ++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/primed/cdsa/tests/test_views.py b/primed/cdsa/tests/test_views.py index 1cdfa57a..beb8e4e8 100644 --- a/primed/cdsa/tests/test_views.py +++ b/primed/cdsa/tests/test_views.py @@ -7620,6 +7620,30 @@ def test_response_requires_study_review_false(self): response = self.client.get(instance.get_absolute_url()) self.assertNotContains(response, "Study review required") + def test_response_primary_cdsa(self): + """Response includes note about missing primary cdsa about study review required if true.""" + agreement = factories.DataAffiliateAgreementFactory.create( + is_primary=True, + ) + instance = factories.CDSAWorkspaceFactory.create( + study=agreement.study, + ) + self.client.force_login(self.user) + response = self.client.get(instance.get_absolute_url()) + self.assertContains(response, agreement.get_absolute_url()) + + def test_response_no_primary_cdsa(self): + """Response includes note about missing primary cdsa about study review required if true.""" + instance = factories.CDSAWorkspaceFactory.create() + self.client.force_login(self.user) + response = self.client.get(instance.get_absolute_url()) + self.assertContains( + response, + # """
Associated CDSA
mdash;
""" + """No primary CDSA""" + # """
Associated CDSA
""", # noqa: E501 + ) + class CDSAWorkspaceCreateTest(AnVILAPIMockTestMixin, TestCase): """Tests of the WorkspaceCreate view from ACM with this app's CDSAWorkspace model.""" diff --git a/primed/templates/cdsa/cdsaworkspace_detail.html b/primed/templates/cdsa/cdsaworkspace_detail.html index d8ea0341..3a192665 100644 --- a/primed/templates/cdsa/cdsaworkspace_detail.html +++ b/primed/templates/cdsa/cdsaworkspace_detail.html @@ -6,7 +6,17 @@ {% include "snippets/gsr_restricted_badge.html" %} {% endif %} - {% if primary_cdsa.requires_study_review %} + {% if not primary_cdsa %} + + + No primary CDSA + + + {% elif primary_cdsa.requires_study_review %} Study review required @@ -24,6 +34,13 @@ {% block workspace_data %}

+
Associated CDSA
+ {% if primary_cdsa %} + {{ primary_cdsa }} + {% else %} + — + {% endif %} +
Study
{{ object.cdsaworkspace.study }}