esturdivant-usgs / science-base-automation

Automating large USGS ScienceBase data releases
4 stars 2 forks source link

ScienceBase page does not update to reflect the updates to the XML. #17

Closed esturdivant-usgs closed 6 years ago

esturdivant-usgs commented 7 years ago

Also, links in Related External Resources (webLinks) were not updated.

esturdivant-usgs commented 7 years ago

Tried to address in commit "Add publication date..."

if update_data: # Upload data files (FIXME: currently only shapefile)
    #if metadata.findall(formname_tagpath)[0].text == 'Shapefile':
    try: #FIXME: add this to a function in a more generalized way?
        data_item["dates"][0]["dateString"]= new_values['pubdate']
esturdivant-usgs commented 7 years ago

To do this for all fields, we need to wipe the sb item before uploading the new xml. This can be done by creating a new JSON item with only the page ID and then using that in the call to sb.replace_file(), sb.upload_files_and_upsert_item()... Can use sb.updateSbItem(item) or function get_fields_from_xml() (probably too complicated).

# This deletes Related External Resources from item page
item = sb.get_item(item_id)
item['webLinks'] = None
item = sb.updateSbItem(item)