Exemplo n.º 1
0
 def get(self, msg=""):
     surveys = get_surveys_by_email(self.db, self.current_user, 10)
     recent_submissions = submission_api.get_all(self.db,
                                                 email=self.current_user,
                                                 limit=5, direction='DESC')
     self.render('index.html', message=msg, surveys=surveys,
                 recent_submissions=recent_submissions)
Exemplo n.º 2
0
def get_all(connection: Connection, email: str) -> dict:
    """
    Return a JSON representation of all the surveys for a user.

    :param connection: a SQLAlchemy Connection
    :param email: the user's e-mail address.
    :return: the JSON string representation
    """
    surveys = get_surveys_by_email(connection, email)
    return json_response([_to_json(connection, survey) for survey in surveys])
Exemplo n.º 3
0
 def testGetSurveysForUserByEmail(self):
     user = connection.execute(auth_user_table.select().where(
         auth_user_table.c.email == 'test_email')).first()
     condition = survey_table.c.auth_user_id == user.auth_user_id
     surveys = connection.execute(survey_table.select().where(
         condition)).fetchall()
     surveys_by_email = get_surveys_by_email(connection, user.email)
     self.assertEqual(len(surveys), len(surveys_by_email))
     self.assertEqual(surveys[0].survey_id,
                      surveys_by_email[0].survey_id)