def stagingManifest(): if request.method == 'GET': return redirect("/tasks/createManifest", code=302) if request.method == 'POST': # objMeta initial model form_data = { 'id' : request.form['objID'], 'label' : request.form['objLabel'], 'policy' : str(json.loads(request.form['lockDown'])['object']), 'content_type' : "WSUDOR_"+str(json.loads(request.form['contentModel'])['object']).replace('info:fedora/CM:',''), 'object_relationships' : [ json.loads(request.form['isDiscoverable']), json.loads(request.form['lockDown']), json.loads(request.form['contentModel']) ], 'datastreams' : [] } # extract datastreams f = request.form counter = 1 while True: temp_dictionary = {} flag = True for key in f.keys(): # look for number and append each one that matches current number to a dictionary if key.endswith(str(counter)): flag = False # key_temp = re.sub('\_'+str(counter)+'$', '', key) key_temp = key temp_dictionary[key_temp] = f[key] if key.startswith('isRepresentedBy'): form_data['isRepresentedBy'] = temp_dictionary['dsID_'+str(counter)] temp_dictionary.pop(key, None) if flag: break form_data['datastreams'].append(temp_dictionary) objMeta = ObjMeta(**form_data) session['objMetaManifestData'] = form_data objMeta.downloadFile(form_data) counter = counter + 1 return render_template("stagingManifest.html", form_data=form_data)
def downloadManifest(): if request.method == 'POST': form_data = session['objMetaManifestData'] objMeta = ObjMeta(**form_data) return objMeta.downloadFile(form_data)