def get(self): open_humans = self.get_secure_cookie('open-humans') # If the user isn't authenticated render the page to allow them to # authenticate if not open_humans: ag_login_id = ag_data.get_user_for_kit(self.current_user) human_participants = ag_data.getHumanParticipants(ag_login_id) survey_ids = {} for participant_name in human_participants: survey_id = ag_data.get_survey_id(ag_login_id, participant_name) if survey_id: survey_ids[participant_name] = survey_id self.render('open-humans.html', skid=self.current_user, survey_ids=survey_ids, access_token=None, origin=self.coerce_origin(), open_humans_home_url=self._HOME_URL, open_humans_research_url=self._RESEARCH_URL, open_humans_api_url=self._API_URL) return open_humans = escape.json_decode(open_humans) self.open_humans_request( '/american-gut/user-data/', self._on_user_data_cb, access_token=open_humans['access_token'])
def get(self): open_humans = self.get_secure_cookie('open-humans') # If the user isn't authenticated render the page to allow them to # authenticate if not open_humans: ag_login_id = ag_data.get_user_for_kit(self.current_user) human_participants = ag_data.getHumanParticipants(ag_login_id) survey_ids = {} for participant_name in human_participants: # Get survey ID 1, the main human survey survey_id = ag_data.get_survey_ids(ag_login_id, participant_name)[1] if survey_id: survey_ids[participant_name] = survey_id self.render('open-humans.html', skid=self.current_user, survey_ids=survey_ids, access_token=None, origin=self.coerce_origin(), open_humans_home_url=self._HOME_URL, open_humans_research_url=self._RESEARCH_URL, open_humans_api_url=self._API_URL) return open_humans = escape.json_decode(open_humans) self.open_humans_request('/american-gut/user-data/', self._on_user_data_cb, access_token=open_humans['access_token'])
def post(self): # Required vars participant_name = self.get_argument('participant_name', 'environmental') form = self.build_form() args = {k: v[0] for k, v in viewitems(self.request.arguments)} form.process(data=args) if not form.validate(): self.render('add_sample.html', skid=self.current_user, participant_name=participant_name, form=self.build_form(), page_type=self.page_type, message='Invalid form submission, please try again') return barcode = form.barcode.data sample_site = form.sample_site.data sample_date = form.sample_date.data sample_time = form.sample_time.data notes = form.notes.data if participant_name == 'environmental': # environmental sample env_sampled = sample_site sample_site = None else: env_sampled = None ag_login_id = ag_data.get_user_for_kit(self.current_user) ag_data.logParticipantSample(ag_login_id, barcode, sample_site, env_sampled, sample_date, sample_time, participant_name, notes) self.redirect(media_locale['SITEBASE'] + '/authed/portal/')
def post(self, participant_name): text = text_locale['participant_overview.html'] participant_name = participant_name.strip('/') # for nginx skid = self.current_user ag_login_id = ag_data.get_user_for_kit(skid) barcodes = ag_data.getParticipantSamples(ag_login_id, participant_name) if barcodes: ebi_submitted = any(ag_data.is_deposited_ebi(b['barcode']) for b in barcodes) else: ebi_submitted = False # Check if we have to remove the participant participant_to_remove = self.get_argument("remove", None) if participant_to_remove and not ebi_submitted: barcodes = ag_data.getParticipantSamples( ag_login_id, participant_to_remove) # Remove all the samples attached to the participant for bc in barcodes: ag_data.deleteSample(bc['barcode'], ag_login_id) # Remove the participant ag_data.deleteAGParticipantSurvey( ag_login_id, participant_to_remove) # Redirect to portal self.redirect(media_locale['SITEBASE'] + "/authed/portal/") return participant_type = self.get_argument('participant_type') internal_surveys = ag_data.get_participants_surveys(ag_login_id, participant_name) vioscreens = [] if internal_surveys is None: raise HTTPError(404, "Could not retrieve survey details for " "participant '%s'" % participant_name) else: for survey_group, survey_id, survey_name in internal_surveys: if survey_group == -1: # Magic number 3 is the vioscreen code for complete survey status = ag_data.get_vioscreen_status(survey_id) url = (("https://vioscreen.com/remotelogin.aspx?Key=%s" "&RegCode=KLUCB") % url_escape(encrypt_key(survey_id))) if status is not None and status != 3: vioscreens.append(text['VIOSCREEN_CONTINUE'] % url) elif status is not None: vioscreens.append(text['VIOSCREEN_COMPLETE']) else: vioscreens.append(text['VIOSCREEN_START'] % url) # Get the list of samples for this participant samples = ag_data.getParticipantSamples(ag_login_id, participant_name) self.render('participant_overview.html', skid=skid, participant_name=participant_name, internal_surveys=internal_surveys, participant_type=participant_type, samples=samples, vioscreens=vioscreens, ebi_submitted=ebi_submitted)
def post(self): bc_to_remove = self.get_argument("remove", None) if bc_to_remove: ag_login_id = ag_data.get_user_for_kit(self.current_user) ag_data.deleteSample(bc_to_remove, ag_login_id) self.redirect(media_locale['SITEBASE'] + "/authed/portal/") return self._sample_overview_renderer()
def build_form(self): kit_id = self.current_user ag_login_id = ag_data.get_user_for_kit(kit_id) kit_barcodes = ag_data.getAvailableBarcodes(ag_login_id) form = LogSample() form.barcode.choices = [(v, v) for v in kit_barcodes] form.sample_site.choices = self._get_sample_sites() return form
def post(self): skid = self.current_user tl = text_locale['handlers'] ag_login_id = ag_data.get_user_for_kit(skid) ag_login_info = ag_data.get_login_info(ag_login_id)[0] animal_survey_id = self.get_argument('survey_id', None) sitebase = media_locale['SITEBASE'] if not animal_survey_id: animal_survey_id = binascii.hexlify(os.urandom(8)) new_survey = True else: new_survey = False form = self.animal_survey() form.process(data=self.request.arguments) data = {'questions': form.data} participant_name = form['Pet_Information_127_0'].data[0] # If the participant already exists, stop them outright if new_survey and \ ag_data.check_if_consent_exists(ag_login_id, participant_name): errmsg = url_escape(tl['PARTICIPANT_EXISTS'] % participant_name) url = sitebase + "/authed/portal/?errmsg=%s" % errmsg self.redirect(url) return consent = { 'login_id': ag_login_id, 'participant_name': participant_name, 'participant_email': ag_login_info['email'], 'assent_obtainer': 'ANIMAL_SURVEY', 'parent_1_name': 'ANIMAL_SURVEY', 'parent_2_name': 'ANIMAL_SURVEY', 'survey_id': animal_survey_id, 'is_juvenile': True, 'deceased_parent': False, 'obtainer_name': 'ANIMAL_SURVEY', 'age_range': 'ANIMAL_SURVEY' } redis.hset(animal_survey_id, 'consent', dumps(consent)) redis.hset(animal_survey_id, 0, dumps(data)) redis.expire(animal_survey_id, 86400) store_survey(primary_animal_survey, animal_survey_id) if not new_survey: message = urlencode([('errmsg', tl['SUCCESSFULLY_EDITED'] % participant_name)]) else: message = urlencode([('errmsg', tl['SUCCESSFULLY_ADDED'] % participant_name)]) url = sitebase + '/authed/portal/?%s' % message self.redirect(url)
def post(self): # Required vars participant_name = self.get_argument('participant_name', 'environmental') form = self.build_form() args = {a: v[0] for a, v in viewitems(self.request.arguments)} form.process(data=args) # Validate input invalid = False if not form.validate(): invalid = True else: try: datetime.strptime(form.sample_date.data, '%m/%d/%Y').date() except ValueError: invalid = True form.sample_date.errors = ['Invalid date format'] try: datetime.strptime(form.sample_time.data, '%I:%M %p').time() except ValueError: invalid = True form.sample_time.errors = ['Invalid time format'] if invalid: self.render('add_sample.html', skid=self.current_user, participant_name=participant_name, form=self.build_form(), page_type=self.page_type, message='Invalid form submission, please try again') return barcode = form.barcode.data sample_site = form.sample_site.data sample_date = form.sample_date.data sample_time = form.sample_time.data notes = form.notes.data if participant_name == 'environmental': # environmental sample env_sampled = sample_site sample_site = None else: env_sampled = None ag_login_id = ag_data.get_user_for_kit(self.current_user) ag_data.logParticipantSample(ag_login_id, barcode, sample_site, env_sampled, sample_date, sample_time, participant_name, notes) self.redirect(media_locale['SITEBASE'] + '/authed/portal/')
def post(self, participant_name): text = text_locale['participant_overview.html'] participant_name = participant_name.strip('/') # for nginx skid = self.current_user ag_login_id = ag_data.get_user_for_kit(skid) # Check if we have to remove the participant participant_to_remove = self.get_argument("remove", None) if participant_to_remove: barcodes = ag_data.getParticipantSamples( ag_login_id, participant_to_remove) # Remove all the samples attached to the participant for bc in barcodes: ag_data.deleteSample(bc['barcode'], ag_login_id) # Remove the participant ag_data.deleteAGParticipantSurvey( ag_login_id, participant_to_remove) # Redirect to portal self.redirect(media_locale['SITEBASE'] + "/authed/portal/") return participant_type = self.get_argument('participant_type') vioscreen_status = None vioscreen_text = '' survey_id = ag_data.get_survey_id(ag_login_id, participant_name) if survey_id is None: raise HTTPError(404, "Could not retrieve survey details for " "participant '%s'" % participant_name) else: vioscreen_status = ag_data.get_vioscreen_status(survey_id) url = ("https://vioscreen.com/remotelogin.aspx?Key=%s" "&RegCode=KLUCB" % url_escape(encrypt_key(survey_id))) # Magic number 3 is the vioscreen code for complete survey if vioscreen_status is not None and vioscreen_status != 3: vioscreen_text = text['VIOSCREEN_CONTINUE'] % url elif vioscreen_status is not None: vioscreen_text = text['VIOSCREEN_COMPLETE'] else: vioscreen_text = text['VIOSCREEN_START'] % url # Get the list of samples for this participant samples = ag_data.getParticipantSamples(ag_login_id, participant_name) self.render('participant_overview.html', skid=skid, participant_name=participant_name, survey_id=survey_id, participant_type=participant_type, samples=samples, vioscreen_text=vioscreen_text)
def get(self): kit_id = self.current_user ag_login_id = ag_data.get_user_for_kit(kit_id) kit_barcodes = ag_data.getAvailableBarcodes(ag_login_id) participant_name = self.get_argument('participant_name', 'environmental') form = LogSample() form.barcode.choices = [(v, v) for v in kit_barcodes] form.sample_site.choices = self._get_sample_sites() self.render('add_sample.html', skid=kit_id, kit_barcodes=kit_barcodes, participant_name=participant_name, form=form)
def test_post(self): # test reaction to invalid kit IDs response = self.post( '/auth/register/', { 'kit_id': 'wrong_kit_id', 'password': '******', 'email': 'e@mail', 'email2': 'e@mail', 'participantname': 'joe', 'address': 'street', 'city': 'metropolis', 'state': 'XX', 'zip': '12345', 'country': 'Afghanistan' }) port = self.get_http_port() self.assertEqual(response.effective_url, 'http://*****:*****@mail', 'email2': 'e@mail', 'participantname': 'joe', 'address': 'street', 'city': 'metropolis', 'state': 'XX', 'zip': '12345', 'country': 'Afghanistan' }) port = self.get_http_port() self.assertEqual(response.code, 200) self.assertEqual( response.effective_url, 'http://localhost:%d/?next=%s' % (port, url_escape('/authed/portal/'))) # Check that registration changed the DB. A proxy to test that no # ValueError is raised. self.assertNotEqual(ag_data.get_user_for_kit(unregistered_kits[0]), 'something')
def on_message(self, msg): tl = text_locale['handlers'] skid = self.current_user participant_name = msg ag_login_id = ag_data.get_user_for_kit(skid) human_participants = ag_data.getHumanParticipants(ag_login_id) animal_participants = ag_data.getAnimalParticipants(ag_login_id) if participant_name in (human_participants + animal_participants): # if the participant already exists in the system, fail nicely output_message = (tl['PARTICIPANT_EXISTS'] % participant_name) else: # otherwise, success! output_message = 'success' self.write_message(output_message)
def test_post(self): # test reaction to invalid kit IDs response = self.post('/auth/register/', {'kit_id': 'wrong_kit_id', 'password': '******', 'email': 'e@mail', 'email2': 'e@mail', 'participantname': 'joe', 'address': 'street', 'city': 'metropolis', 'state': 'XX', 'zip': '12345', 'country': 'Afghanistan'}) port = self.get_http_port() self.assertEqual( response.effective_url, 'http://*****:*****@mail', 'email2': 'e@mail', 'participantname': 'joe', 'address': 'street', 'city': 'metropolis', 'state': 'XX', 'zip': '12345', 'country': 'Afghanistan'}) port = self.get_http_port() self.assertEqual(response.code, 200) self.assertEqual( response.effective_url, 'http://localhost:%d/?next=%s' % (port, url_escape('/authed/portal/'))) # Check that registration changed the DB. A proxy to test that no # ValueError is raised. self.assertNotEqual(ag_data.get_user_for_kit(unregistered_kits[0]), 'something')
def post(self): tl = text_locale['handlers'] participant_name = self.get_argument("participant_name").strip() participant_email = self.get_argument("participant_email").strip() age_range = self.get_argument("age_range") parent_1_name = self.get_argument("parent_1_name", None) parent_2_name = self.get_argument("parent_2_name", None) obtainer_name = self.get_argument("obtainer_name", None) deceased_parent = self.get_argument("deceased_parent", 'No') sitebase = media_locale['SITEBASE'] if not participant_name or not participant_email: self.render("new_participant.html", skid=self.current_user, message=tl['MISSING_NAME_EMAIL']) return ag_login_id = ag_data.get_user_for_kit(self.current_user) # If the participant already exists, stop them outright if ag_data.check_if_consent_exists(ag_login_id, participant_name): errmsg = url_escape(tl['PARTICIPANT_EXISTS'] % participant_name) url = sitebase + "/authed/portal/?errmsg=%s" % errmsg self.redirect(url) return human_survey_id = binascii.hexlify(os.urandom(8)) consent = { 'participant_name': participant_name, 'participant_email': participant_email, 'parent_1_name': parent_1_name, 'parent_2_name': parent_2_name, 'is_juvenile': True if age_range != '18-plus' else False, 'deceased_parent': deceased_parent, 'obtainer_name': obtainer_name, 'age_range': age_range, 'login_id': ag_login_id, 'survey_id': human_survey_id } redis.hset(human_survey_id, 'consent', dumps(consent)) redis.expire(human_survey_id, 86400) self.set_secure_cookie('human_survey_id', human_survey_id) self.redirect(sitebase + "/authed/survey_main/")
def post(self): tl = text_locale['handlers'] participant_name = self.get_argument("participant_name").strip() participant_email = self.get_argument("participant_email").strip() age_range = self.get_argument("age_range") parent_1_name = self.get_argument("parent_1_name", None) parent_2_name = self.get_argument("parent_2_name", None) obtainer_name = self.get_argument("obtainer_name", None) deceased_parent = self.get_argument("deceased_parent", 'No') sitebase = media_locale['SITEBASE'] if not participant_name or not participant_email: self.render("new_participant.html", skid=self.current_user, message=tl['MISSING_NAME_EMAIL']) return ag_login_id = ag_data.get_user_for_kit(self.current_user) # If the participant already exists, stop them outright if ag_data.check_if_consent_exists(ag_login_id, participant_name): errmsg = url_escape(tl['PARTICIPANT_EXISTS'] % participant_name) url = sitebase + "/authed/portal/?errmsg=%s" % errmsg self.redirect(url) return human_survey_id = binascii.hexlify(os.urandom(8)) consent = {'participant_name': participant_name, 'participant_email': participant_email, 'parent_1_name': parent_1_name, 'parent_2_name': parent_2_name, 'is_juvenile': True if age_range != '18-plus' else False, 'deceased_parent': deceased_parent, 'obtainer_name': obtainer_name, 'age_range': age_range, 'login_id': ag_login_id, 'survey_id': human_survey_id} redis.hset(human_survey_id, 'consent', dumps(consent)) redis.expire(human_survey_id, 86400) self.set_secure_cookie('human_survey_id', human_survey_id) self.redirect(sitebase + "/authed/survey_main/")
def post(self): skid = self.current_user tl = text_locale['handlers'] ag_login_id = ag_data.get_user_for_kit(skid) survey_id = self.get_argument('survey_id', None) survey_type = self.get_argument('type') participant_name = url_unescape(self.get_argument('participant_name')) sitebase = media_locale['SITEBASE'] if not survey_id: survey_id = binascii.hexlify(os.urandom(8)) sec_survey = self.sec_surveys[survey_type] survey_class = make_survey_class(sec_survey.groups[0], survey_type='SecondarySurvey') form = survey_class() form.process(data=self.request.arguments) data = {'questions': form.data} consent = { 'login_id': ag_login_id, 'participant_name': participant_name, 'survey_id': survey_id, 'secondary': True } redis.hset(survey_id, 'consent', dumps(consent)) redis.hset(survey_id, 0, dumps(data)) redis.expire(survey_id, 86400) store_survey(sec_survey, survey_id) if survey_id: message = urlencode([ ('errmsg', tl['SUCCESSFULLY_EDITED'] % participant_name) ]) else: message = urlencode([ ('errmsg', tl['SUCCESSFULLY_ADDED'] % participant_name) ]) url = '%s/authed/portal/?%s' % (sitebase, message) self.redirect(url)
def _on_user_data_cb(self, user_data): open_humans = escape.json_decode(self.get_secure_cookie('open-humans')) try: link_survey_id = escape.json_decode( base64.b64decode(self.get_cookie('link-survey-id'))) except (AttributeError, ValueError, TypeError): link_survey_id = None if link_survey_id: self.open_humans_request( '/american-gut/user-data/', self._on_post_user_data_cb, method='PATCH', body={'data': { 'surveyIds': link_survey_id }}, access_token=open_humans['access_token']) return survey_ids = {} ag_login_id = ag_data.get_user_for_kit(self.current_user) human_participants = ag_data.getHumanParticipants(ag_login_id) for participant_name in human_participants: # Get survey ID 1, the main human survey survey_id = ag_data.get_survey_ids(ag_login_id, participant_name)[1] if survey_id: survey_ids[participant_name] = survey_id self.render('open-humans.html', skid=self.current_user, survey_ids=survey_ids, access_token=open_humans['access_token'], origin=self.coerce_origin(), open_humans_home_url=self._HOME_URL, open_humans_research_url=self._RESEARCH_URL, open_humans_api_url=self._API_URL)
def post(self): skid = self.current_user tl = text_locale['handlers'] ag_login_id = ag_data.get_user_for_kit(skid) survey_id = self.get_argument('survey_id', None) survey_type = self.get_argument('type') participant_name = self.get_argument('participant_name') sitebase = media_locale['SITEBASE'] if not survey_id: survey_id = binascii.hexlify(os.urandom(8)) sec_survey = self.sec_surveys[survey_type] survey_class = make_survey_class(sec_survey.groups[0], survey_type='SecondarySurvey') form = survey_class() form.process(data=self.request.arguments) data = {'questions': form.data} consent = { 'login_id': ag_login_id, 'participant_name': participant_name, 'survey_id': survey_id, 'secondary': True } redis.hset(survey_id, 'consent', dumps(consent)) redis.hset(survey_id, 0, dumps(data)) redis.expire(survey_id, 86400) store_survey(sec_survey, survey_id) if survey_id: message = urlencode([('errmsg', tl['SUCCESSFULLY_EDITED'] % participant_name)]) else: message = urlencode([('errmsg', tl['SUCCESSFULLY_ADDED'] % participant_name)]) url = '%s/authed/portal/?%s' % (sitebase, message) self.redirect(url)
def _on_user_data_cb(self, user_data): open_humans = escape.json_decode(self.get_secure_cookie('open-humans')) try: link_survey_id = escape.json_decode( base64.b64decode(self.get_cookie('link-survey-id'))) except (AttributeError, ValueError, TypeError): link_survey_id = None if link_survey_id: self.open_humans_request( '/american-gut/user-data/', self._on_post_user_data_cb, method='PATCH', body={'data': {'surveyIds': link_survey_id}}, access_token=open_humans['access_token']) return survey_ids = {} ag_login_id = ag_data.get_user_for_kit(self.current_user) human_participants = ag_data.getHumanParticipants(ag_login_id) for participant_name in human_participants: # Get survey ID 1, the main human survey survey_id = ag_data.get_survey_ids(ag_login_id, participant_name)[1] if survey_id: survey_ids[participant_name] = survey_id self.render('open-humans.html', skid=self.current_user, survey_ids=survey_ids, access_token=open_humans['access_token'], origin=self.coerce_origin(), open_humans_home_url=self._HOME_URL, open_humans_research_url=self._RESEARCH_URL, open_humans_api_url=self._API_URL)
def post(self): # Required vars barcode = self.get_argument('barcode') sample_date = self.get_argument('sample_date') sample_time = self.get_argument('sample_time') notes = self.get_argument('notes') participant_name = self.get_argument('participant_name') sample_site = self.get_argument('sample_site', '') if participant_name == 'environmental': # environmental sample env_sampled = sample_site sample_site = None else: env_sampled = None ag_login_id = ag_data.get_user_for_kit(self.current_user) ag_data.logParticipantSample(ag_login_id, barcode, sample_site, env_sampled, sample_date, sample_time, participant_name, notes) self.redirect(media_locale['SITEBASE'] + '/authed/portal/')
def post(self): tl = text_locale['handlers'] deceased_parent = self.get_argument("deceased_parent", None) participant_name = self.get_argument("participant_name") participant_email = self.get_argument("participant_email") is_juvenile = self.get_argument("is_juvenile", 'off') parent_1_name = self.get_argument("parent_1_name", None) parent_2_name = self.get_argument("parent_2_name", None) ag_login_id = ag_data.get_user_for_kit(self.current_user) kit_email = ag_data.get_user_info(self.current_user)['email'] # Check if the participant is on the exceptions list is_exception = ( participant_name in ag_data.getParticipantExceptions(ag_login_id)) # If the participant already exists, stop them outright if ag_data.check_if_consent_exists(ag_login_id, participant_name): errmsg = url_escape(tl['PARTICIPANT_EXISTS'] % participant_name) self.redirect(media_locale['SITEBASE'] + "/authed/portal/?errmsg=%s" % errmsg) return if is_juvenile == 'off' and is_exception: errmsg = url_escape(tl["JUVENILE_CONSENT_EXPECTED"] % participant_name) self.redirect(media_locale['SITEBASE'] + "/authed/portal/?errmsg=%s" % errmsg) return if is_juvenile == 'on': # If they aren't already an exception, we need to verify them if not is_exception: alert_message = tl['MINOR_PARENTAL_BODY'] subject = ("AGJUVENILE: %s (ag_login_id: %s) is a child" % (participant_name, ag_login_id)) message = MESSAGE_TEMPLATE % (participant_name, parent_1_name, parent_2_name, deceased_parent, self.current_user, kit_email) try: send_email(message, subject, sender=kit_email) alert_message = tl['MESSAGE_SENT'] except: alert_message = media_locale['EMAIL_ERROR'] self.redirect(media_locale['SITEBASE'] + "/authed/portal/?errmsg=%s" % alert_message) return human_survey_id = binascii.hexlify(os.urandom(8)) consent= {'participant_name': participant_name, 'participant_email': participant_email, 'parent_1_name': parent_1_name, 'parent_2_name': parent_2_name, 'is_juvenile': True if is_juvenile == 'on' else False, 'deceased_parent': deceased_parent, 'login_id': ag_login_id, 'survey_id': human_survey_id} redis.hset(human_survey_id, 'consent', dumps(consent)) redis.expire(human_survey_id, 86400) self.set_secure_cookie('human_survey_id', human_survey_id) self.redirect(media_locale['SITEBASE'] + "/authed/survey_main/")
def post(self, participant_name): text = text_locale['participant_overview.html'] participant_name = participant_name.strip('/') # for nginx skid = self.current_user ag_login_id = ag_data.get_user_for_kit(skid) barcodes = ag_data.getParticipantSamples(ag_login_id, participant_name) if barcodes: ebi_submitted = any( ag_data.is_deposited_ebi(b['barcode']) for b in barcodes) else: ebi_submitted = False # Check if we have to remove the participant participant_to_remove = self.get_argument("remove", None) if participant_to_remove and not ebi_submitted: barcodes = ag_data.getParticipantSamples(ag_login_id, participant_to_remove) # Remove all the samples attached to the participant for bc in barcodes: ag_data.deleteSample(bc['barcode'], ag_login_id) # Remove the participant ag_data.deleteAGParticipantSurvey(ag_login_id, participant_to_remove) # Redirect to portal self.redirect(media_locale['SITEBASE'] + "/authed/portal/") return participant_type = self.get_argument('participant_type') internal_surveys = ag_data.get_participants_surveys( ag_login_id, participant_name) vioscreens = [] if internal_surveys is None: raise HTTPError( 404, "Could not retrieve survey details for " "participant '%s'" % participant_name) else: for survey_group, survey_id, survey_name in internal_surveys: if survey_group == -1: # Magic number 3 is the vioscreen code for complete survey status = ag_data.get_vioscreen_status(survey_id) url = (("https://vioscreen.com/remotelogin.aspx?Key=%s" "&RegCode=KLUCB") % url_escape(encrypt_key(survey_id))) if status is not None and status != 3: vioscreens.append(text['VIOSCREEN_CONTINUE'] % url) elif status is not None: vioscreens.append(text['VIOSCREEN_COMPLETE']) else: vioscreens.append(text['VIOSCREEN_START'] % url) # Get the list of samples for this participant samples = ag_data.getParticipantSamples(ag_login_id, participant_name) self.render('participant_overview.html', skid=skid, participant_name=participant_name, internal_surveys=internal_surveys, participant_type=participant_type, samples=samples, vioscreens=vioscreens, ebi_submitted=ebi_submitted)