diff --git a/primed/miscellaneous_workspaces/forms.py b/primed/miscellaneous_workspaces/forms.py index 58946b5b..42856cfc 100644 --- a/primed/miscellaneous_workspaces/forms.py +++ b/primed/miscellaneous_workspaces/forms.py @@ -117,6 +117,7 @@ class Meta: "workspace", "target_workspace", "requested_by", + "is_active", ) # widgets = { # "studies": autocomplete.ModelSelect2Multiple( diff --git a/primed/miscellaneous_workspaces/migrations/0008_dataprepworkspace_historicaldataprepworkspace.py b/primed/miscellaneous_workspaces/migrations/0008_dataprepworkspace_historicaldataprepworkspace.py index 642c6548..eace0215 100644 --- a/primed/miscellaneous_workspaces/migrations/0008_dataprepworkspace_historicaldataprepworkspace.py +++ b/primed/miscellaneous_workspaces/migrations/0008_dataprepworkspace_historicaldataprepworkspace.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.19 on 2023-11-07 18:52 +# Generated by Django 3.2.19 on 2023-11-09 22:11 from django.conf import settings from django.db import migrations, models @@ -10,7 +10,7 @@ class Migration(migrations.Migration): dependencies = [ - ('anvil_consortium_manager', '0013_alter_anvilprojectmanageraccess_options'), + ('anvil_consortium_manager', '0015_add_new_permissions'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('miscellaneous_workspaces', '0007_openaccessworkspace_data_url'), ] @@ -22,6 +22,7 @@ class Migration(migrations.Migration): ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')), ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), + ('is_active', models.BooleanField(default=True, help_text='Indicator of whether this workspace is currently being used for data preparation.')), ('history_id', models.AutoField(primary_key=True, serialize=False)), ('history_date', models.DateTimeField(db_index=True)), ('history_change_reason', models.CharField(max_length=100, null=True)), @@ -45,6 +46,7 @@ class Migration(migrations.Migration): ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('created', django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, verbose_name='created')), ('modified', django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified')), + ('is_active', models.BooleanField(default=True, help_text='Indicator of whether this workspace is currently being used for data preparation.')), ('requested_by', models.ForeignKey(help_text='The user who requested creation.', on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), ('target_workspace', models.ForeignKey(help_text='The workspace for which data is being prepared or updated.', on_delete=django.db.models.deletion.PROTECT, related_name='data_prep_workspaces', to='anvil_consortium_manager.workspace')), ('workspace', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='anvil_consortium_manager.workspace')), diff --git a/primed/miscellaneous_workspaces/models.py b/primed/miscellaneous_workspaces/models.py index 40c8103c..7329551f 100644 --- a/primed/miscellaneous_workspaces/models.py +++ b/primed/miscellaneous_workspaces/models.py @@ -73,6 +73,10 @@ class DataPrepWorkspace(RequesterModel, TimeStampedModel, BaseWorkspaceData): related_name="data_prep_workspaces", help_text="The workspace for which data is being prepared or updated.", ) + is_active = models.BooleanField( + default=True, + help_text="Indicator of whether this workspace is currently being used to prepare data.", + ) def clean(self): if hasattr(self, "target_workspace"): diff --git a/primed/miscellaneous_workspaces/tables.py b/primed/miscellaneous_workspaces/tables.py index 824c871a..f9763621 100644 --- a/primed/miscellaneous_workspaces/tables.py +++ b/primed/miscellaneous_workspaces/tables.py @@ -3,7 +3,10 @@ import django_tables2 as tables from anvil_consortium_manager.models import Workspace -from primed.primed_anvil.tables import WorkspaceSharedWithConsortiumColumn +from primed.primed_anvil.tables import ( + BooleanIconColumn, + WorkspaceSharedWithConsortiumColumn, +) class OpenAccessWorkspaceTable(tables.Table): @@ -50,11 +53,15 @@ class DataPrepWorkspaceTable(tables.Table): dataprepworkspace__target_workspace__name = tables.columns.Column( linkify=True, verbose_name="Target workspace" ) + dataprepworkspace__is_active = BooleanIconColumn( + verbose_name="Active?", show_false_icon=True + ) class Meta: model = Workspace fields = ( "name", "dataprepworkspace__target_workspace__name", + "dataprepworkspace__is_active", ) order_by = ("name",) diff --git a/primed/miscellaneous_workspaces/tests/test_views.py b/primed/miscellaneous_workspaces/tests/test_views.py index a71458a8..5f623bb4 100644 --- a/primed/miscellaneous_workspaces/tests/test_views.py +++ b/primed/miscellaneous_workspaces/tests/test_views.py @@ -1126,6 +1126,22 @@ def test_status_code_with_user_permission(self): # Includes link to target workspace. self.assertContains(response, obj.target_workspace.get_absolute_url()) + def test_template_active(self): + """Returns successful response code.""" + obj = factories.DataPrepWorkspaceFactory.create() + self.client.force_login(self.user) + response = self.client.get(obj.workspace.get_absolute_url()) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "Active") + + def test_template_inactive(self): + """Returns successful response code.""" + obj = factories.DataPrepWorkspaceFactory.create(is_active=False) + self.client.force_login(self.user) + response = self.client.get(obj.workspace.get_absolute_url()) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "Inactive") + class DataPrepWorkspaceCreateTest(AnVILAPIMockTestMixin, TestCase): """Tests of the WorkspaceCreate view from ACM with this app's DataPrepWorkspace model.""" diff --git a/primed/templates/miscellaneous_workspaces/dataprepworkspace_detail.html b/primed/templates/miscellaneous_workspaces/dataprepworkspace_detail.html index f824351c..7ff1c45a 100644 --- a/primed/templates/miscellaneous_workspaces/dataprepworkspace_detail.html +++ b/primed/templates/miscellaneous_workspaces/dataprepworkspace_detail.html @@ -9,5 +9,12 @@
Target type
{{ object.dataprepworkspace.target_workspace.workspace_type }}
+
Status
+ {% if object.dataprepworkspace.is_active %} + Active + {% else %} + Inactive + {% endif %} +
{% endblock workspace_data %}