def put(self, theme_id):
     """Update theme."""
     msg_request, err_msg = flask_request_response.message_request(
         request_pb2.CreateThemeRequest, THEME_API, PUT_REQUEST)
     if err_msg is not None:
         return flask_request_response.error_response(
             err_msg["err_message"], THEME_API, PUT_REQUEST)
     try:
         json_request = json_format.MessageToDict(
             msg_request, preserving_proto_field_name=True)
         query_response = update_theme_query_response(json_request['theme'])
         return query_response
     except Exception as err:
         return flask_request_response.error_response(
             str(err), THEME_API, PUT_REQUEST)
 def post(self):
     """Create new question."""
     msg_request, err_msg = flask_request_response.message_request(
         request_pb2.GetQuestions, GET_QUESTIONS_API, POST_REQUEST)
     if err_msg is not None:
         return flask_request_response.error_response(
             err_msg["err_message"], GET_QUESTIONS_API, POST_REQUEST)
     try:
         json_request = json_format.MessageToDict(
             msg_request, preserving_proto_field_name=True)
         query_response = get_questions_query_response(json_request['ids'])
         return query_response
     except Exception as err:
         return flask_request_response.error_response(
             str(err), GET_QUESTIONS_API, POST_REQUEST)
Пример #3
0
 def post(self, topic_id):
     """Create new topic."""
     msg_request, err_msg = flask_request_response.message_request(
         request_pb2.CreateTopicRequest, TOPIC_API, POST_REQUEST)
     if err_msg is not None:
         return flask_request_response.error_response(
             err_msg["err_message"], TOPIC_API, POST_REQUEST)
     try:
         json_request = json_format.MessageToDict(
             msg_request, preserving_proto_field_name=True)
         query_response = create_topic_query_response(json_request['topic'])
         return query_response
     except Exception as err:
         return flask_request_response.error_response(
             str(err), TOPIC_API, POST_REQUEST)
Пример #4
0
 def put(self, assessment_id):
     """Create new assessment."""
     msg_request, err_msg = flask_request_response.message_request(
         request_pb2.CreateAssessmentRequest, ASSESSMENT_API, PUT_REQUEST)
     if err_msg is not None:
         return flask_request_response.error_response(
             err_msg["err_message"], ASSESSMENT_API, PUT_REQUEST)
     try:
         json_request = json_format.MessageToDict(
             msg_request, preserving_proto_field_name=True)
         query_response = update_assessment_query_response(
             json_request['assessment'])
         return query_response
     except Exception as err:
         return flask_request_response.error_response(
             str(err), ASSESSMENT_API, PUT_REQUEST)
Пример #5
0
 def post(self):
     """Create new assessment."""
     msg_request, err_msg = flask_request_response.message_request(
         request_pb2.UserContentRequest, MY_CONTENT_API, POST_REQUEST)
     if err_msg is not None:
         return flask_request_response.error_response(
             err_msg["err_message"], MY_CONTENT_API, POST_REQUEST)
     try:
         json_request = json_format.MessageToDict(
             msg_request, preserving_proto_field_name=True)
         query_response = get_my_contents_query_response(
             json_request['user_id'])
         return query_response
     except Exception as err:
         return flask_request_response.error_response(
             str(err), MY_CONTENT_API, POST_REQUEST)
Пример #6
0
    def post(self):
        json_req = flask_request_response.json_request(LOGIN_API, POST_REQUEST)

        try:
            query_response = login_query_response(
                json_req['user_id'], json_req['password'])
            return query_response

        except Exception as err:
            return flask_request_response.error_response(
                str(err), LOGIN_API, POST_REQUEST
            )
    def post(self):
        json_req = flask_request_response.json_request(SIGN_UP_API,
                                                       POST_REQUEST)

        # if err is not None:
        #     return flask_request_response.error_response(
        #         err, SIGN_UP_API, POST_REQUEST)

        try:
            does_user_exits = check_user_id_exists_query_response(
                json_req["signup_details"]["user_id"])
            if not does_user_exits:
                sign_up_query_response = signup_query_response(
                    json_req["signup_details"])
            else:
                return {
                    "is_successful_execution": False,
                    "msg": 'User Id exists'
                }
            return sign_up_query_response

        except Exception as err:
            return flask_request_response.error_response(
                str(err), SIGN_UP_API, POST_REQUEST)