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)
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, 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)
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)
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)