Skip to content

Commit

Permalink
bug(metadata): conforms contract # to have at least the default
Browse files Browse the repository at this point in the history
Updates the contract number logic and instructions on dataset editor to
- add logic which prepends the LBNL contract number to the field if it does
  not exist already
- Adds explicit intruction to the contract number field that LBNL # will
  be added by default and to only enter other contract numbers

Closes #427
  • Loading branch information
vchendrix committed May 30, 2024
1 parent 6290e35 commit 36201cb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.2 on 2024-05-30 15:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('archive_api', '0029_alter_dataset_funding_organizations_and_more'),
]

def update_null_fields(apps, schema_editor):
Dataset = apps.get_model('archive_api', 'dataset')
for dataset in Dataset.objects.filter(doe_funding_contract_numbers=None):
dataset.doe_funding_contract_numbers = 'DE-AC02-05CH11231'
dataset.save()

def reverse_update_null_fields(apps, schema_editor):
# It is ok not to reverse
pass

operations = [
migrations.RunPython(update_null_fields, reverse_update_null_fields),

]
9 changes: 9 additions & 0 deletions archive_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,15 @@ def save(self, *args, **kwargs):
self.modified_date = kwargs["modified_date"]
del kwargs['modified_date']

# prepend the default contract number if not set
if self.doe_funding_contract_numbers is not None and self.doe_funding_contract_numbers.strip() != "":
if "AC02-05CH11231" not in self.doe_funding_contract_numbers and \
"AC0205CH11231" not in self.doe_funding_contract_numbers:
self.doe_funding_contract_numbers = \
"DE-AC02-05CH11231, " + self.doe_funding_contract_numbers
else:
self.doe_funding_contract_numbers = "DE-AC02-05CH11231"

super(DataSet, self).save(*args, **kwargs)

def __str__(self):
Expand Down
4 changes: 2 additions & 2 deletions archive_api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_client_post(self):
self.assertEqual(value['sites'], [])
self.assertEqual(value['managed_by'], 'auser')
self.assertEqual(value['end_date'], None)
self.assertEqual(value['doe_funding_contract_numbers'], None)
self.assertEqual(value['doe_funding_contract_numbers'], 'DE-AC02-05CH11231')
self.assertEqual(value['funding_organizations'], None)
self.assertEqual(value['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['additional_access_information'], None)
Expand Down Expand Up @@ -463,7 +463,7 @@ def test_admin_approve_workflow(self):
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"], "")
self.assertEqual(value["doe_funding_contract_numbers"], "DE-AC02-05CH11231")
self.assertEqual(value["acknowledgement"], "")
self.assertEqual(value["reference"], "")
self.assertEqual(value["access_level"], "0")
Expand Down
2 changes: 1 addition & 1 deletion ui/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ $(document).ready(function () {
}
});

$.getJSON("static/js/metadata/dataset.json?v=20240329", function (data) {
$.getJSON("static/js/metadata/dataset.json?v=202405301", function (data) {
templates.datasets = data;
createEditForm('datasets');
});
Expand Down
12 changes: 7 additions & 5 deletions ui/static/js/metadata/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"label": "Dataset Description",
"sequence": 4,
"multiple": false,
"tooltip": "<p>Dataset tooltip and overview. This should read as an abstract for the dataset, and provide users with adequate information about what the dataset contains, and how to use it. Include details on what data what, when and where data was collected, and if any data processing was done.</p> <p><i>E.g.: Raw output from the data logger connected to 9 sapflow and 5 soil moisture sensors are provided in xxx.dat. The metadata file (BR-Ma2 E-field log_20160501.xls) has information on locations where the sensors were installed, and other installation/maintenance details. No data processing or QA/QC was done on the raw datasets. Processed datasets will be uploaded separately. Contact janedoe@lbl.gov if you need to use this dataset for additional information.</i> <b>This field has a limit of 4,000 characters and must have at least 100 words.</b></p>"
"tooltip": "<p>Dataset description and overview. This should read as an abstract for the dataset, and provide users with adequate information about what the dataset contains, and how to use it. Include details on what data what, when and where data was collected, and if any data processing was done.</p> <p><i>E.g.: Raw output from the data logger connected to 9 sapflow and 5 soil moisture sensors are provided in xxx.dat. The metadata file (BR-Ma2 E-field log_20160501.xls) has information on locations where the sensors were installed, and other installation/maintenance details. No data processing or QA/QC was done on the raw datasets. Processed datasets will be uploaded separately. Contact janedoe@lbl.gov if you need to use this dataset for additional information.</i> <b>This field has a limit of 4,000 characters and must have at least 100 words.</b></p>"
},
"sites": {
"type": "reference_list",
Expand Down Expand Up @@ -136,14 +136,14 @@
"multiple": false,
"tooltip": "<p>Indicate if any QA/QC has been performed on the dataset. Choices are None, Provisional QA-QC, Final QA-QC.</p>"
},
"qaqc_method_tooltip": {
"qaqc_method_description": {
"type": "string",
"required": true,
"read_only": false,
"label": "Method Description",
"sequence": 14,
"multiple": false,
"tooltip": "<p>Information about the methods employed in collecting or generating a data set or other resource. These include tooltips of sampling or experimental procedures, data QA/QC, processing and synthesis.</p>"
"tooltip": "<p>Information about the methods employed in collecting or generating a data set or other resource. These include descriptions of sampling or experimental procedures, data QA/QC, processing and synthesis.</p>"
},
"ngee_tropics_resources": {
"type": "boolean",
Expand All @@ -170,9 +170,11 @@
"required": false,
"read_only": false,
"label": "Dataset Funding Contract Number(s)",
"description": "<p style='font-size: small;'>(NGEE-Tropics is assumed by default through LBNL contract)</p><p>DE-AC02-05CH11231 will be automatically prepended</p>",
"sequence": 17,
"multiple": false,
"tooltip": "<p>List the numbers of any DOE contract under which the work was funded. If no DOE funding for this dataset or field is empty set as 'NONE'. If the dataset is a result of a joint effort between two or more DOE Site/Facility Management Contractors, etc., additional DOE contract numbers may be entered. The 'DE' should not be included as a part of the number. <b>This field has a limit of 100 characters.</b></p>"
"tooltip": "<p>List the numbers of any DOE contract under which the work was funded. If no DOE funding for this dataset or field is empty set as 'DE-AC02-05CH11231'. If the dataset is a result of a joint effort between two or more DOE Site/Facility Management Contractors, etc., additional DOE contract numbers may be entered. <b>This field has a limit of 100 characters.</b></p>",
"placeholder": "Add additional contract numbers other than the default."
},
"acknowledgement": {
"type": "string",
Expand All @@ -199,7 +201,7 @@
"label": "Additional Information about Dataset Reference(s)",
"sequence": 20,
"multiple": false,
"tooltip": "<p>Brief tooltip of dataset reference (e,g, paper) relevance, relationship with this dataset or other comments. <b>This field has a limit of 2,255 characters.</b></p>"
"tooltip": "<p>Brief description of dataset reference (e,g, paper) relevance, relationship with this dataset or other comments. <b>This field has a limit of 2,255 characters.</b></p>"
},
"access_level": {
"type": "choice",
Expand Down

0 comments on commit 36201cb

Please sign in to comment.