Esempio n. 1
0
    def get(self):
        '''Get all questions'''
        if 'user' in request.args:
            question_owner = User.find_by_id(request.args['user'])
            if question_owner:
                questions = Question.get_all_user_questions(user=request.args['user'])
                return {"message": "Success", "data": questions}, 200
            return {"message": "No user found with that id"}, 404

        elif "search" in request.args:
            questions = Question.search_questions(body=request.args['search'], title=request.args['search'])
            if questions:
                return {"message": "Search results", "data": questions}, 200
            return {"message": "No question found!!!"}, 404
        questions = Question.get_all()
        return {"message": "Success", "data": questions}, 200