From ebb821140f657a0c6687d7f7af24b8c16157b40e Mon Sep 17 00:00:00 2001 From: Val Hendrix Date: Tue, 3 Oct 2023 10:31:04 -0700 Subject: [PATCH] feat(ui): marks methods descr as required + Adds check to confirm that the methods description is at least 100 words Closes #397 --- archive_api/serializers.py | 5 ++++- archive_api/tests/test_api.py | 30 ++++++++++++++++++++++-------- ui/static/js/metadata/dataset.json | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/archive_api/serializers.py b/archive_api/serializers.py index a2f895c3..be930c8d 100644 --- a/archive_api/serializers.py +++ b/archive_api/serializers.py @@ -146,6 +146,9 @@ def validate(self, data): 'start_date'] > data['end_date']: errors["end_date"]="Start date must come before end date" + if 'qaqc_method_description' in data.keys() and data['qaqc_method_description'] and len(data['qaqc_method_description'].split()) < 100: + errors["qaqc_method_description"] = "Methods Description must be at least 100 words." + # Validate the selected plots if 'plots' in data.keys(): if 'sites' not in data.keys(): @@ -166,7 +169,7 @@ def validate(self, data): for field in ['sites', 'authors', 'name', 'description', 'contact', 'variables', 'ngee_tropics_resources', 'funding_organizations', 'originating_institution', - 'access_level']: # Check for required fields + 'access_level', 'qaqc_method_description']: # Check for required fields if field in data.keys(): if data[field] is None or (isinstance(data[field], (list, tuple, str)) and not data[field]): errors.setdefault('missingRequiredFields', []) diff --git a/archive_api/tests/test_api.py b/archive_api/tests/test_api.py index dde43533..bd288090 100644 --- a/archive_api/tests/test_api.py +++ b/archive_api/tests/test_api.py @@ -227,7 +227,8 @@ def test_client_post(self): 'variables', 'ngee_tropics_resources', 'funding_organizations', - 'originating_institution']}, value) + 'originating_institution', + 'qaqc_method_description']}, value) def test_client_put(self): self.login_user("auser") @@ -329,7 +330,8 @@ def test_user_workflow(self): value = json.loads(response.content.decode('utf-8')) self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) self.assertEqual( - {'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution']}, + {'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution', + 'qaqc_method_description']}, value) response = self.client.put('/api/v1/datasets/1/', @@ -340,7 +342,7 @@ def test_user_workflow(self): '"start_date": "2016-10-28",' '"end_date": null,' '"qaqc_status": null,' - '"qaqc_method_description": "",' + '"qaqc_method_description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",' '"ngee_tropics_resources": true,' '"funding_organizations": "The funding organizations for my dataset",' '"doe_funding_contract_numbers": "",' @@ -384,7 +386,8 @@ def test_admin_approve_workflow(self): response = self.client.get("/api/v1/datasets/1/submit/") # In draft mode, owned by auser value = json.loads(response.content.decode('utf-8')) self.assertEqual( - {'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution']}, + {'missingRequiredFields': ['archive', 'authors', 'funding_organizations', 'originating_institution', + 'qaqc_method_description']}, value) self.assertEqual(status.HTTP_400_BAD_REQUEST, response.status_code) @@ -414,7 +417,18 @@ def test_admin_approve_workflow(self): '"start_date": "2016-10-28",' '"end_date": null,' '"qaqc_status": null,' - '"qaqc_method_description": "",' + '"qaqc_method_description": "Sed ut perspiciatis unde omnis iste natus error ' + 'sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ' + 'ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta ' + 'sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut ' + 'odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem ' + 'sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, ' + 'consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ' + 'ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima ' + 'veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, ' + 'nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure ' + 'reprehenderit qui in ea voluptate velit esse quam nihil molestiae ' + 'consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",' '"ngee_tropics_resources": true,' '"funding_organizations": "The funding organizations for my dataset",' '"doe_funding_contract_numbers": "",' @@ -444,7 +458,7 @@ def test_admin_approve_workflow(self): self.assertEqual(value["start_date"], "2016-10-28") self.assertEqual(value["end_date"], None) self.assertEqual(value["qaqc_status"], None) - self.assertEqual(value["qaqc_method_description"], "") + self.assertEqual(value["qaqc_method_description"], "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?") self.assertEqual(value["ngee_tropics_resources"], True) self.assertEqual(value["funding_organizations"], "The funding organizations for my dataset") self.assertEqual(value["doe_funding_contract_numbers"], "") @@ -622,7 +636,7 @@ def test_upload(self): '"start_date": "2016-10-28",' '"end_date": null,' '"qaqc_status": null,' - '"qaqc_method_description": "",' + '"qaqc_method_description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",' '"ngee_tropics_resources": true,' '"funding_organizations": "The funding organizations for my dataset",' '"doe_funding_contract_numbers": "",' @@ -748,7 +762,7 @@ def test_issue_118(self): '"start_date": "2016-10-28",' '"end_date": null,' '"qaqc_status": null,' - '"qaqc_method_description": "",' + '"qaqc_method_description": "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",' '"ngee_tropics_resources": false,' '"funding_organizations": "The funding organizations for my dataset",' '"doe_funding_contract_numbers": null,' diff --git a/ui/static/js/metadata/dataset.json b/ui/static/js/metadata/dataset.json index 8de4a928..d382ce8a 100644 --- a/ui/static/js/metadata/dataset.json +++ b/ui/static/js/metadata/dataset.json @@ -138,7 +138,7 @@ }, "qaqc_method_description": { "type": "string", - "required": false, + "required": true, "read_only": false, "label": "Method Description", "sequence": 14,