示例#1
0
def get_responses(id):
    '''Get responses.'''
    serializer = Serializer(QuestionnaireResponseSchema, request.args)
    query = QuestionnaireResponse.query.\
        filter(QuestionnaireResponse.user_id == auth.current_user.id).\
        filter(QuestionnaireResponse.questionnaire_id == id).\
        order_by(QuestionnaireResponse.created_at.desc())
    page = Pagination(request, query=query)
    return serializer.dump_page(page)
示例#2
0
def get_questionnaires():
    '''Get questionnaires.'''
    serializer = Serializer(QuestionnaireSchema, request.args)
    query = Questionnaire.query.\
        outerjoin(QuestionnaireResponse, and_(
            QuestionnaireResponse.user_id == auth.current_user.id,
            QuestionnaireResponse.questionnaire_id == Questionnaire.id
        )).\
        options(contains_eager(Questionnaire.responses))

    page = Pagination(request, query=query)
    return serializer.dump_page(page)
示例#3
0
文件: users.py 项目: Kareeeeem/AMC
def get_users():
    '''Get users.'''
    serializer = Serializer(UserSchema, request.args)
    query = User.query
    page = Pagination(request, query=query)
    return serializer.dump_page(page)