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)
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)
def get_users(): '''Get users.''' serializer = Serializer(UserSchema, request.args) query = User.query page = Pagination(request, query=query) return serializer.dump_page(page)