Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): marks methods descr as required #414

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion archive_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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', [])
Expand Down
30 changes: 22 additions & 8 deletions archive_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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/',
Expand All @@ -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": "",'
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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": "",'
Expand Down Expand Up @@ -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"], "")
Expand Down Expand Up @@ -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": "",'
Expand Down Expand Up @@ -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,'
Expand Down
2 changes: 1 addition & 1 deletion ui/static/js/metadata/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
},
"qaqc_method_description": {
"type": "string",
"required": false,
"required": true,
"read_only": false,
"label": "Method Description",
"sequence": 14,
Expand Down