Ejemplo n.º 1
0
def _setup_session(portal):
    from euphorie.content.tests.utils import BASIC_SURVEY
    from euphorie.client.tests.utils import addAccount
    from euphorie.client.tests.utils import addSurvey
    from euphorie.client.session import create_survey_session
    from euphorie.client.profile import set_session_profile
    addSurvey(portal, BASIC_SURVEY)
    survey = portal.client['nl']['ict']['software-development']
    account = addAccount(password='******')
    survey_session = create_survey_session(u'Dummy session', survey, account)
    survey_session = set_session_profile(survey, survey_session, {})
    return (account, survey, survey_session)
Ejemplo n.º 2
0
def _setup_session(portal):
    from euphorie.content.tests.utils import BASIC_SURVEY
    from euphorie.client.tests.utils import addAccount
    from euphorie.client.tests.utils import addSurvey
    from euphorie.client.session import create_survey_session
    from euphorie.client.profile import set_session_profile
    addSurvey(portal, BASIC_SURVEY)
    survey = portal.client['nl']['ict']['software-development']
    account = addAccount(password='******')
    survey_session = create_survey_session(u'Dummy session',
            survey, account)
    survey_session = set_session_profile(survey, survey_session, {})
    return (account, survey, survey_session)
Ejemplo n.º 3
0
    def do_PUT(self):
        survey = self.survey()
        questions = survey.ProfileQuestions()
        if set([q.id for q in questions]) != set(self.input):
            return {'type': 'error',
                    'message': 'Provided data does not match profile.'}
        for question in questions:
            input = self.input[question.id]
            if isinstance(input, list) and \
                    all(isinstance(v, unicode) for v in input):
                continue
            return {'type': 'error',
                    'message': 'Invalid profile data.'}

        self.context = set_session_profile(survey, self.context, self.input)
        return self.do_GET()
Ejemplo n.º 4
0
    def do_PUT(self):
        survey = self.survey()
        questions = survey.ProfileQuestions()
        if set([q.id for q in questions]) != set(self.input):
            return {
                'type': 'error',
                'message': 'Provided data does not match profile.'
            }
        for question in questions:
            input = self.input[question.id]
            if isinstance(input, list) and \
                    all(isinstance(v, unicode) for v in input):
                continue
            return {'type': 'error', 'message': 'Invalid profile data.'}

        self.context = set_session_profile(survey, self.context, self.input)
        return self.do_GET()