Skip to content

Commit

Permalink
changing forms.py to make enquiries_contact as required and resolving…
Browse files Browse the repository at this point in the history
… test_admin fails
  • Loading branch information
tayyib-saddique committed Aug 15, 2023
1 parent 3e8bec3 commit 5236aa3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
5 changes: 5 additions & 0 deletions dataworkspace/dataworkspace/apps/dw_admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions dataworkspace/dataworkspace/tests/datasets/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions dataworkspace/dataworkspace/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
33 changes: 25 additions & 8 deletions dataworkspace/dataworkspace/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)],
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 5236aa3

Please sign in to comment.