# Path: amgut/lib/util.py
# class PartitionResponse(object):
#     def __init__(self, question_types):
#     def __setitem__(self, qid, value):
#     def _store(self, d, qid, value):
# def make_survey_class(group, survey_type):
# def store_survey(survey, survey_id):
#     def get_survey_question_id(key):
# def survey_vioscreen(survey_id, consent_info, internal_surveys=[]):
# def survey_asd(survey_id, consent_info, internal_surveys=[]):
# def survey_fermented(survey_id, consent_info, internal_surveys=[]):
# def survey_surf(survey_id, consent_info, internal_surveys=[]):
# def rollback(f):
#     def test_inner(*args, **kwargs):
# def basejoin(base, url):


from tornado.web import authenticated
from amgut.lib.util import external_surveys
from amgut.handlers.base_handlers import BaseHandler
from amgut import media_locale
from amgut.connections import ag_data



class HumanSurveyCompletedHandler(BaseHandler):
    @authenticated
    def get(self):
        human_survey_id = self.get_secure_cookie('completed_survey_id')

        if human_survey_id is None:
            self.clear_cookie('completed_survey_id')
            self.redirect(media_locale['SITEBASE'] + '/authed/portal/')

        else:
            consent_info = ag_data.getConsent(human_survey_id)
            internal_surveys = ag_data.get_participants_surveys(
                consent_info['ag_login_id'], consent_info['participant_name'])
            surveys = [f(human_survey_id, consent_info, internal_surveys)

# Path: amgut/lib/util.py
# class PartitionResponse(object):
#     def __init__(self, question_types):
#     def __setitem__(self, qid, value):
#     def _store(self, d, qid, value):
# def make_survey_class(group, survey_type):
# def store_survey(survey, survey_id):
#     def get_survey_question_id(key):
# def survey_vioscreen(survey_id, consent_info, internal_surveys=[]):
# def survey_asd(survey_id, consent_info, internal_surveys=[]):
# def survey_fermented(survey_id, consent_info, internal_surveys=[]):
# def survey_surf(survey_id, consent_info, internal_surveys=[]):
# def rollback(f):
#     def test_inner(*args, **kwargs):
# def basejoin(base, url):


# Path: amgut/handlers/human_survey_completed.py
from tornado.web import authenticated
from amgut.lib.util import external_surveys
from amgut.handlers.base_handlers import BaseHandler
from amgut import media_locale
from amgut.connections import ag_data




class HumanSurveyCompletedHandler(BaseHandler):
    @authenticated
    def get(self):
        human_survey_id = self.get_secure_cookie('completed_survey_id')

        if human_survey_id is None:
            self.clear_cookie('completed_survey_id')
            self.redirect(media_locale['SITEBASE'] + '/authed/portal/')

        else:
            consent_info = ag_data.getConsent(human_survey_id)
            internal_surveys = ag_data.get_participants_surveys(
                consent_info['ag_login_id'], consent_info['participant_name'])
            surveys = [f(human_survey_id, consent_info, internal_surveys)

                       for f in external_surveys]