def get_seamless_doc_pdf(response_id): response = queries.get_response_model(response_id) base_url = 'https://cleanslate.seamlessdocs.com/api/' if not response.seamless_id: form_id = os.environ.get('DEFAULT_SEAMLESS_FORM_ID') else: form_id = queries.get_seamless_doc_key_for_response(response) submit_url = base_url + 'form/{}/submit'.format(form_id) submit_result = requests.post( submit_url, auth=seamless_auth.build_seamless_auth(), data=response.answers).json() if 'application_id' in submit_result: response.seamless_submission_id = submit_result['application_id'] db.session.commit() else: # these abort errors should be more specific abort(404) app_url = base_url + 'application/{}'.format( response.seamless_submission_id) # wait for the pdf to be generated time.sleep(10) app_result = requests.get( app_url, auth=seamless_auth.build_seamless_auth()).json() response.pdf_url = app_result.get('submission_pdf_url', '') if response.pdf_url: db.session.commit() else: abort(404) form = queries.get_typeform(id=response.typeform_id) response_data = queries.response_serializer.dump(response).data return form, response_data
def response_detail(typeform_key, response_id): """Show the details of a particular typeform response """ response = queries.get_response_detail(current_user, response_id) form = queries.get_typeform(form_key=typeform_key) return render_template( "response_detail.html", response=response, form=form )
def responses(typeform_key): """get the responses of a particular typeform """ form = queries.get_typeform(user_id=current_user.id) responses = queries.get_responses_for_typeform(typeform_id=form['id']) return render_template( 'responses.html', form=form, responses=responses, )
def remote_responses(typeform_key): # make an api call to Typeform # this can be done as a background task form = queries.get_typeform( form_key=typeform_key, user_id=current_user.id, model=True) tasks.get_typeform_responses(form) responses = queries.get_responses_for_typeform(typeform_id=form.id) return render_template( "response_list.html", form=form, responses=responses)