@must_have_permission('write')
@must_have_addon(SHORT_NAME, 'user')
@must_have_addon(SHORT_NAME, 'node')
@must_be_addon_authorizer(SHORT_NAME)
def dataverse_set_config(node_addon, auth, **kwargs):
 user_settings = node_addon.user_settings
 user = auth.user
 if (user_settings and (user_settings.owner != user)):
  raise HTTPError(http.FORBIDDEN)
 try:
  assert_clean(request.json)
 except AssertionError:
  raise HTTPError(http.NOT_ACCEPTABLE)
 alias = request.json.get('dataverse', {}).get('alias')
 doi = request.json.get('dataset', {}).get('doi')
 if ((doi is None) or (alias is None)):
  return HTTPError(http.BAD_REQUEST)
 connection = client.connect_from_settings(node_addon)
 dataverse = client.get_dataverse(connection, alias)
 dataset = client.get_dataset(dataverse, doi)
 node_addon.set_folder(dataverse, dataset, auth)
 return ({'dataverse': dataverse.title, 'dataset': dataset.title}, http.OK)

@ must_have_permission ( 'write' ) @ must_have_addon ( SHORT_NAME , 'user' ) @ must_have_addon ( SHORT_NAME , 'node' ) @ must_be_addon_authorizer ( SHORT_NAME ) def dataverse_set_config ( node_addon , auth , ** kwargs ) : user_settings = node_addon . user_settings user = auth . user if ( user_settings and ( user_settings . owner != user ) ) : raise HTTPError ( http . FORBIDDEN ) try : assert_clean ( request . json ) except AssertionError : raise HTTPError ( http . NOT_ACCEPTABLE ) alias = request . json . get ( 'dataverse' , { } ) . get ( 'alias' ) doi = request . json . get ( 'dataset' , { } ) . get ( 'doi' ) if ( ( doi is None ) or ( alias is None ) ) : return HTTPError ( http . BAD_REQUEST ) connection = client . connect_from_settings ( node_addon ) dataverse = client . get_dataverse ( connection , alias ) dataset = client . get_dataset ( dataverse , doi ) node_addon . set_folder ( dataverse , dataset , auth ) return ( { 'dataverse' : dataverse . title , 'dataset' : dataset . title } , http . OK )
saves selected dataverse and dataset to node settings .