diff --git a/dataworkspace/dataworkspace/apps/dw_admin/forms.py b/dataworkspace/dataworkspace/apps/dw_admin/forms.py index 8abcbdbb88..036adc5c5c 100644 --- a/dataworkspace/dataworkspace/apps/dw_admin/forms.py +++ b/dataworkspace/dataworkspace/apps/dw_admin/forms.py @@ -61,6 +61,8 @@ def __init__(self, *args, **kwargs): self.fields["information_asset_owner"].required = True if "information_asset_manager" in self.fields: self.fields["information_asset_manager"].required = True + if "enquiries_contact" in self.fields: + self.fields["enquiries_contact"].required = True if "sort_field" in self.fields: self.fields["sort_field"].queryset = self.instance.fields.all() @@ -531,6 +533,7 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["information_asset_owner"].required = True self.fields["information_asset_manager"].required = True + self.fields["enquiries_contact"].required = True class Meta: model = MasterDataset @@ -545,6 +548,7 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["information_asset_owner"].required = True self.fields["information_asset_manager"].required = True + self.fields["enquiries_contact"].required = True class Meta: model = MasterDataset @@ -718,6 +722,7 @@ def __init__(self, *args, **kwargs): self.fields["information_asset_owner"].required = True self.fields["information_asset_manager"].required = True + self.fields["enquiries_contact"].required = True class VisualisationLinkForm(forms.ModelForm): diff --git a/dataworkspace/dataworkspace/tests/datasets/test_views.py b/dataworkspace/dataworkspace/tests/datasets/test_views.py index 7b6fab070c..ff33f4a8de 100644 --- a/dataworkspace/dataworkspace/tests/datasets/test_views.py +++ b/dataworkspace/dataworkspace/tests/datasets/test_views.py @@ -4795,6 +4795,7 @@ def test_csv_upload( published=True, user_access_type=UserAccessType.REQUIRES_AUTHENTICATION, information_asset_manager=user, + enquiries_contact=user, ), schema="test", table="table1", diff --git a/dataworkspace/dataworkspace/tests/factories.py b/dataworkspace/dataworkspace/tests/factories.py index 3fee3302b1..0f8c707d0a 100644 --- a/dataworkspace/dataworkspace/tests/factories.py +++ b/dataworkspace/dataworkspace/tests/factories.py @@ -86,6 +86,7 @@ class DataSetFactory(factory.django.DjangoModelFactory): type = DataSetType.DATACUT information_asset_owner = factory.SubFactory(UserFactory) information_asset_manager = factory.SubFactory(UserFactory) + enquiries_contact = factory.SubFactory(UserFactory) class Meta: model = "datasets.DataSet" diff --git a/dataworkspace/dataworkspace/tests/test_admin.py b/dataworkspace/dataworkspace/tests/test_admin.py index d6b9383991..afccc4377a 100644 --- a/dataworkspace/dataworkspace/tests/test_admin.py +++ b/dataworkspace/dataworkspace/tests/test_admin.py @@ -564,7 +564,7 @@ def test_create_reference_dataset_valid(self): "description": "test description", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": sel.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": "", @@ -872,7 +872,7 @@ def test_edit_reference_dataset_update_column_names(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "sort_direction": ReferenceDataset.SORT_DIR_DESC, "restrictions_on_usage": "", @@ -930,7 +930,7 @@ def test_edit_reference_dataset_change_table_name(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": field1.id, @@ -987,7 +987,7 @@ def test_edit_reference_dataset_valid(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": "", @@ -1143,7 +1143,7 @@ def test_delete_reference_dataset_identifier_valid(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": field2.id, @@ -1878,7 +1878,7 @@ def test_change_linked_reference_dataset(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": "", @@ -1990,7 +1990,7 @@ def test_link_to_external_dataset(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": "", @@ -2337,7 +2337,7 @@ def test_delete_sort_field(self): "description": "", "valid_from": "", "valid_to": "", - "enquiries_contact": "", + "enquiries_contact": self.user.id, "licence": "", "restrictions_on_usage": "", "sort_field": field1.id, @@ -2474,6 +2474,7 @@ def test_edit_dataset_authorized_users(self): "description": "test description", "information_asset_owner": str(user1.id), "information_asset_manager": str(user1.id), + "enquiries_contact": str(user1.id), "type": 2, "user_access_type": UserAccessType.REQUIRES_AUTHORIZATION, "sourcelink_set-TOTAL_FORMS": "0", @@ -2516,6 +2517,7 @@ def test_edit_dataset_authorized_email_domains(self): "description": "test description", "information_asset_owner": str(user1.id), "information_asset_manager": str(user1.id), + "enquiries_contact": str(user1.id), "type": 2, "user_access_type": UserAccessType.REQUIRES_AUTHORIZATION, "sourcelink_set-TOTAL_FORMS": "0", @@ -2559,6 +2561,7 @@ def test_delete_external_source_link(self): "description": "test description", "information_asset_owner": str(user1.id), "information_asset_manager": str(user1.id), + "enquiries_contact": str(user1.id), "type": 2, "user_access_type": UserAccessType.OPEN, "sourcelink_set-TOTAL_FORMS": "1", @@ -2616,6 +2619,7 @@ def test_delete_local_source_link_aws_failure(self, mock_client): "description": "test description", "information_asset_owner": str(user1.id), "information_asset_manager": str(user1.id), + "enquiries_contact": str(user1.id), "type": 2, "user_access_type": UserAccessType.OPEN, "sourcelink_set-TOTAL_FORMS": "1", @@ -2670,6 +2674,7 @@ def test_delete_local_source_link(self, mock_client): "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": 2, "sourcelink_set-TOTAL_FORMS": "1", "sourcelink_set-INITIAL_FORMS": "1", @@ -2801,6 +2806,7 @@ def test_sql_query_tables_extracted_correctly( "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": 2, "user_access_type": dataset.user_access_type, "sourcelink_set-TOTAL_FORMS": "0", @@ -2864,6 +2870,7 @@ def test_sql_queries_can_only_be_reviewed_by_superusers( "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": 2, "user_access_type": dataset.user_access_type, "sourcelink_set-TOTAL_FORMS": "0", @@ -2924,6 +2931,7 @@ def test_datacut_can_only_be_published_by_superuser( "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": 2, "user_access_type": dataset.user_access_type, "sourcelink_set-TOTAL_FORMS": "0", @@ -3022,6 +3030,7 @@ def test_manage_master_dataset_permission_allows_editing_unpublished_datasets(se "description": "some description", "information_asset_owner": user.id, "information_asset_manager": user.id, + "enquiries_contact": str(user.id), "type": 1, "sourcetable_set-TOTAL_FORMS": "0", "sourcetable_set-INITIAL_FORMS": "0", @@ -3064,6 +3073,7 @@ def test_manage_datacut_dataset_permission_allows_editing_unpublished_datasets(s "description": "some description", "information_asset_owner": user.id, "information_asset_manager": user.id, + "enquiries_contact": user.id, "type": 2, "user_access_type": dataset.user_access_type, "sourcelink_set-TOTAL_FORMS": "0", @@ -3169,6 +3179,7 @@ def test_unpublished_datacut_query_review_flag_is_toggled_off_if_query_changed_w "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": 2, "user_access_type": dataset.user_access_type, "sourcelink_set-TOTAL_FORMS": "0", @@ -3229,6 +3240,7 @@ def test_master_dataset_permission_changes_calls_sync_job(self, mock_sync, staff "description": "test description", "information_asset_owner": user.id, "information_asset_manager": user.id, + "enquiries_contact": user.id, "type": dataset.type, "user_access_type": UserAccessType.REQUIRES_AUTHORIZATION, "sourcetable_set-TOTAL_FORMS": "1", @@ -3286,6 +3298,7 @@ def test_master_dataset_authorized_user_changes_calls_sync_job_and_clears_explor "description": "test description", "information_asset_owner": str(user_1.id), "information_asset_manager": str(user_1.id), + "enquiries_contact": str(user_1.id), "type": dataset.type, "user_access_type": dataset.user_access_type, "authorized_users": [str(user_1.id), str(user_2.id)], @@ -3354,6 +3367,7 @@ def test_dataset_access_type_change_invalidates_all_user_cached_credentials( "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": dataset.type, "user_access_type": UserAccessType.REQUIRES_AUTHENTICATION, "sourcetable_set-TOTAL_FORMS": "1", @@ -3415,6 +3429,7 @@ def test_master_dataset_permission_changes_clears_authorized_users_cached_creden "description": "test description", "information_asset_owner": str(user.id), "information_asset_manager": str(user.id), + "enquiries_contact": str(user.id), "type": dataset.type, "user_access_type": UserAccessType.REQUIRES_AUTHORIZATION, "authorized_users": str(user.id), @@ -3516,6 +3531,7 @@ def test_source_table_data_grid_enabled(self, staff_client): "description": "test description", "information_asset_owner": user.id, "information_asset_manager": user.id, + "enquiries_contact": user.id, "type": dataset.type, "user_access_type": dataset.user_access_type, "sourcetable_set-TOTAL_FORMS": "1", @@ -3565,6 +3581,7 @@ def test_source_table_reporting_disabled(self, staff_client): "description": "test description", "information_asset_owner": user.id, "information_asset_manager": user.id, + "enquiries_contact": user.id, "type": dataset.type, "user_access_type": dataset.user_access_type, "sourcetable_set-TOTAL_FORMS": "1",