Exemplo n.º 1
0
    def testGetNumberOfSurveys(self):
        number_of_surveys = get_number_of_surveys(connection, 'test_email')
        self.assertEqual(number_of_surveys, 1)

        connection.execute(create_auth_user(email='TestSurveyEmail'))
        zero_surveys = get_number_of_surveys(connection, 'TestSurveyEmail')
        self.assertEqual(zero_surveys, 0)
Exemplo n.º 2
0
    def get(self):
        email = self.get_email()

        # Shorter variable names
        auth_user = auth_user_table
        survey = survey_table
        submission = submission_table
        submission_id = submission_table.c.submission_id
        submission_time = submission_table.c.submission_time

        result = self._get_records(
            table=auth_user.join(survey).outerjoin(submission),
            email=email,
            selected=[
                survey_table.c.survey_title,
                count(submission_id).label('num_submissions'),
                # survey_table.c.created_on,
                sqlmax(submission_time).label('latest_submission'),
                survey_table.c.survey_id,
            ],
            text_filter_column=survey_table.c.survey_title,
            default_sort_column_name='latest_submission',
            total_records=get_number_of_surveys(self.db, email)
        )

        self.write(result)