Skip to content

Commit

Permalink
Add PartnerUploadWorkspaces to the UploadCycle detail page
Browse files Browse the repository at this point in the history
This table should show the set of PartnerUploadWorkspaces that are
contributing to a given upload cycle. The logic is not quite right
in the view yet, but it's enough to show adding the table.
  • Loading branch information
amstilp committed Dec 16, 2023
1 parent 02fefa7 commit 91ecf1e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
23 changes: 22 additions & 1 deletion gregor_django/gregor_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def test_table_classes(self):
self.client.force_login(self.user)
response = self.client.get(self.get_url(obj.cycle))
self.assertIn("tables", response.context_data)
self.assertEqual(len(response.context_data["tables"]), 5)
self.assertEqual(len(response.context_data["tables"]), 6)
self.assertIsInstance(
response.context_data["tables"][0], tables.UploadWorkspaceTable
)
Expand All @@ -803,6 +803,9 @@ def test_table_classes(self):
self.assertIsInstance(
response.context_data["tables"][4], tables.DCCProcessedDataWorkspaceTable
)
self.assertIsInstance(
response.context_data["tables"][5], tables.PartnerUploadWorkspaceTable
)

def test_upload_workspace_table(self):
"""Contains a table of UploadWorkspaces from this upload cycle."""
Expand Down Expand Up @@ -866,6 +869,24 @@ def test_dcc_processed_data_workspace_table(self):
self.assertIn(workspace.workspace, table.data)
self.assertNotIn(other_workspace.workspace, table.data)

def test_partner_upload_workspace_table(self):
"""Contains a table of PartnerUploadWorkspaces for this upload cycle."""
obj = self.model_factory.create()
obj.end_date
# Make sure the partner upload workspace has an end date before the end of this upload cycle.
workspace = factories.PartnerUploadWorkspaceFactory.create(
date_completed=obj.end_date - timedelta(days=1)
)
other_workspace = factories.PartnerUploadWorkspaceFactory.create(
date_completed=obj.end_date + timedelta(days=1)
)
self.client.force_login(self.user)
response = self.client.get(self.get_url(obj.cycle))
table = response.context_data["tables"][5]
self.assertEqual(len(table.rows), 1)
self.assertIn(workspace.workspace, table.data)
self.assertNotIn(other_workspace.workspace, table.data)


class UploadCycleListTest(TestCase):
"""Tests for the UploadCycleList view."""
Expand Down
5 changes: 5 additions & 0 deletions gregor_django/gregor_anvil/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class UploadCycleDetail(
tables.ReleaseWorkspaceTable,
tables.DCCProcessingWorkspaceTable,
tables.DCCProcessedDataWorkspaceTable,
tables.PartnerUploadWorkspaceTable,
]

def get_tables_data(self):
Expand All @@ -108,12 +109,16 @@ def get_tables_data(self):
dcc_processed_data_workspace_qs = Workspace.objects.filter(
dccprocesseddataworkspace__upload_cycle=self.object,
)
partner_workspace_qs = Workspace.objects.filter(
partneruploadworkspace__date_completed__lte=self.object.end_date,
)
return [
upload_workspace_qs,
combined_workspace_qs,
release_workspace_qs,
dcc_processing_workspace_qs,
dcc_processed_data_workspace_qs,
partner_workspace_qs,
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<dl class="row">
<dt class="col-sm-2">Partner Group</dt> <dd class="col-sm-10"><a href="{{ workspace_data_object.partner_group.get_absolute_url }}">{{ workspace_data_object.partner_group }}</a></dd>
<dt class="col-sm-2">Consent group</dt> <dd class="col-sm-10"><a href="{{ workspace_data_object.consent_group.get_absolute_url }}">{{ workspace_data_object.consent_group }}</a></dd>
<dt class="col-sm-2">Version</dt> <dd class="col-sm-10">{{ workspace_data_object.version }}"</dd>
<dt class="col-sm-2">Date completed</dt> <dd class="col-sm-10">{{ workspace_data_object.date_completed }}"</dd>
<dt class="col-sm-2">Version</dt> <dd class="col-sm-10">{{ workspace_data_object.version }}</dd>
<dt class="col-sm-2">Date completed</dt> <dd class="col-sm-10">{{ workspace_data_object.date_completed }}</dd>
</dl>
{% endblock workspace_data %}

Expand Down
5 changes: 5 additions & 0 deletions gregor_django/templates/gregor_anvil/uploadcycle_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ <h2>DCC processed data workspaces</h2>
{% render_table tables.4 %}
</div>

<h2>Partner upload workspaces</h2>
<div class="container">
{% render_table tables.5 %}
</div>

{% endblock after_panel %}

0 comments on commit 91ecf1e

Please sign in to comment.