def post(self):
        """Add flagged concept to database."""
        request, error_message = flask_request_response.message_request(
            _api_intput_pb2.FlagDependentConcept, FLAGED_CONCEPT_API,
            POST_REQUEST)

        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message']], FLAGED_CONCEPT_API,
                POST_REQUEST
            )
        try:
            app.logger.error("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Entered Flagged API%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
            flagged_concept_response =\
                flagged_dependent_concept_query_response(
                    request.concept_key, request.nested_concept_key,
                    request.flagged_by
                )
            response = _api_output_pb2.Acknowledgement()
            flagged_concept_result = _json_format.ParseDict(
                flagged_concept_response, response)
            return flask_request_response.message_response(
                flagged_concept_result,
                FLAGED_CONCEPT_API, POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response(
                [str(err)], FLAGED_CONCEPT_API, POST_REQUEST
            )
    def post(self):
        """Get all the assigned task data."""
        request, error_message = flask_request_response.message_request(
            _api_intput_pb2.GetSubTasks, ALL_ASSIGNED_TASK_API, POST_REQUEST)

        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message']], ALL_ASSIGNED_TASK_API,
                POST_REQUEST
            )
        try:
            all_assigned_task_response = get_all_assign_task_query_response(
                request.username
            )
            response = _api_output_pb2.GetAllAssignedTasks()
            ass_assign_task_result = _json_format.ParseDict(
                all_assigned_task_response, response
            )
            return flask_request_response.message_response(
                ass_assign_task_result,
                ALL_ASSIGNED_TASK_API, POST_REQUEST, 200
            )
        except Exception as err:
            return flask_request_response.error_response(
                [str(err)], ALL_ASSIGNED_TASK_API, POST_REQUEST
            )
Esempio n. 3
0
 def post(self):
     """Update new password to database."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.ChangePassword, CHANGE_PASSWORD_API, POST_REQUEST
     )
     if error_message is not None:
         return flask_request_response.error_response(
             [error_message['err_message']], CHANGE_PASSWORD_API,
             POST_REQUEST
         )
     try:
         change_password_response = change_password_query_response(
             request.current_password, request.new_password,
             request.user_key
         )
         response = _api_output_pb2.Acknowledgement()
         change_password_result = _json_format.ParseDict(
             change_password_response, response
         )
         return flask_request_response.message_response(
             change_password_result,
             CHANGE_PASSWORD_API, POST_REQUEST, 200
         )
     except Exception as err:
         return flask_request_response.error_response(
             [str(err)], CHANGE_PASSWORD_API, POST_REQUEST
         )
Esempio n. 4
0
 def post(self):
     """Add dependent concepts."""
     msg_request, error_message = \
         flask_request_response.message_request(
             _api_input_pb2.AddEdge, ADD_EDGE_API,
             POST_REQUEST
         )
     if error_message is not None:
         return flask_request_response.error_response(
             [error_message['err_message'], "msg response"],
             ADD_EDGE_API,
             POST_REQUEST
         )
     try:
         json_message = \
             flask_request_response.json_request(ADD_EDGE_API, POST_REQUEST)
         print(json.dumps(json_message, indent=2))
         add_dependent_concepts_response = add_edge_query_response(
             json_message["edges"]
         )
         response = _api_output_pb2.AddEdge()
         print("==========>", response, type(response))
         add_dependent_concepts_result = _json_format.ParseDict(
             add_dependent_concepts_response, response
         )
         return flask_request_response.message_response(
             add_dependent_concepts_result,
             ADD_EDGE_API, POST_REQUEST, 200
         )
     except Exception as err:
         return flask_request_response.error_response(
             [str(err), "try response"], ADD_EDGE_API,
             POST_REQUEST
         )
 def get(self):
     """Get all the tasks for super admin dashboard."""
     try:
         users_task_data = get_superadmin_dashboard_query_response()
         response = _api_output_pb2.GetSuperAdminDashboard()
         result = _json_format.ParseDict(users_task_data, response)
         return flask_request_response.message_response(
             result, SUPER_ADMIN_DASHBOARD_API, GET_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response(
             [str(err)], SUPER_ADMIN_DASHBOARD_API, GET_REQUEST)
Esempio n. 6
0
 def post(self):
     """Get all sub task data for user from database."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.GetSubTasks, SUB_TASK_API, POST_REQUEST)
     print(request)
     print(error_message)
     if error_message is not None:
         return flask_request_response.message_response(
             [error_message['err_message']], SUB_TASK_API, POST_REQUEST)
     try:
         message_response = get_sub_tasks_query_response(request.username)
         print(message_response)
         response = _api_output_pb2.GetSubTasks()
         result = _json_format.ParseDict(message_response, response)
         return flask_request_response.message_response(
             result, SUB_TASK_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response([str(err)],
                                                      SUB_TASK_API,
                                                      POST_REQUEST)
 def post(self):
     """Add new user to database."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.CreateUser, CREATE_USER_API, POST_REQUEST)
     if error_message is not None:
         return flask_request_response.message_response(
             [error_message['err_message']], CREATE_USER_API, POST_REQUEST)
     try:
         create_user_response = create_user_query_response(
             request.username, request.password, request.first_name,
             request.last_name, request.email, request.role)
         response = _api_output_pb2.CreateUser()
         create_user_result = _json_format.ParseDict(
             create_user_response, response)
         return flask_request_response.message_response(
             create_user_result, CREATE_USER_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response([str(err)],
                                                      CREATE_USER_API,
                                                      POST_REQUEST)
 def get(self):
     """Get data for assignment."""
     try:
         assignment_data = get_assignment_data_response()
         response = _api_output_pb2.GetAssignmentData()
         assignment_result = \
             _json_format.ParseDict(assignment_data, response)
         return flask_request_response.message_response(
             assignment_result, ASSIGNMENT_DATA_API, GET_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response([str(err)],
                                                      ASSIGNMENT_DATA_API,
                                                      GET_REQUEST)
 def post(self):
     """Delete user from database."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.DeleteUser, DELETE_USER_API, POST_REQUEST)
     if error_message is not None:
         return flask_request_response.message_response(
             [error_message['err_message']], DELETE_USER_API, POST_REQUEST)
     try:
         delete_user_response = delete_user_query_response(request.username)
         return flask_request_response.json_response(
             delete_user_response, DELETE_USER_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response([str(err)],
                                                      DELETE_USER_API,
                                                      POST_REQUEST)
Esempio n. 10
0
    def post(self):
        """Request for tasks."""

        request, error_message = flask_request_response.message_request(
            _api_input_pb2.TaskData, TASK_DATA_API, POST_REQUEST)
        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message'], "msg response"], TASK_DATA_API,
                POST_REQUEST)
        try:
            task_data_response = task_data_query_response(request.username)
            response = _api_output_pb2.TaskData()
            task_data_result = _json_format.ParseDict(task_data_response,
                                                      response)
            return flask_request_response.message_response(
                task_data_result, TASK_DATA_API, POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response(
                [str(err), "try response"], TASK_DATA_API, POST_REQUEST)
 def post(self):
     """Get data for assignment."""
     try:
         json_message = \
             flask_request_response.json_request(
                 GET_TASKS_BY_CHAPTER_API,
                 POST_REQUEST
             )
         assignment_data = \
             get_tasks_by_chapter_response(json_message["chapter_key"])
         response = _api_output_pb2.GetTasksByChapter()
         assignment_result = \
             _json_format.ParseDict(assignment_data, response)
         return flask_request_response.message_response(
             assignment_result,
             GET_TASKS_BY_CHAPTER_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response(
             [str(err)], GET_TASKS_BY_CHAPTER_API, POST_REQUEST
         )
Esempio n. 12
0
 def post(self):
     """Add dependent concepts."""
     request, error_message = flask_request_response.message_request(
         _api_input_pb2.DeleteEdge, DELETE_EDGE_API, POST_REQUEST)
     if error_message is not None:
         return flask_request_response.error_response(
             [error_message['err_message'], "msg response"],
             DELETE_EDGE_API, POST_REQUEST)
     try:
         delete_edge_response = delete_edge_query_response(
             request.edge_id, request.username)
         response = _api_output_pb2.DeleteEge()
         print("==========>", response, type(response))
         delete_edge_result = _json_format.ParseDict(
             delete_edge_response, response)
         return flask_request_response.message_response(
             delete_edge_result, DELETE_EDGE_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response(
             [str(err), "try response"], DELETE_EDGE_API, POST_REQUEST)
Esempio n. 13
0
    def post(self):
        """Abort a task."""
        request, error_message = flask_request_response.message_request(
            _api_intput_pb2.AbortTask, ABORT_TASK_API, POST_REQUEST)

        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message']], ABORT_TASK_API, POST_REQUEST)
        try:
            flagged_concept_response =\
                abort_task_query_response(
                    request.chapter_key, request.username
                )
            response = _api_output_pb2.Acknowledgement()
            flagged_concept_result = _json_format.ParseDict(
                flagged_concept_response, response)
            return flask_request_response.message_response(
                flagged_concept_result, ABORT_TASK_API, POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response([str(err)],
                                                         ABORT_TASK_API,
                                                         POST_REQUEST)
 def post(self):
     """Add delete concept value and add user to database."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.DeleteDependentConcept, DELEETE_CONCEPT_API,
         POST_REQUEST)
     if error_message is not None:
         return flask_request_response.error_response(
             [error_message['err_message']], DELEETE_CONCEPT_API,
             POST_REQUEST)
     try:
         delete_concept_response = delete_dependent_concept_query_response(
             request.concept_key, request.nested_concept_key,
             request.deleted_by)
         response = _api_output_pb2.Acknowledgement()
         delete_concept_result = _json_format.ParseDict(
             delete_concept_response, response)
         return flask_request_response.message_response(
             delete_concept_result, DELEETE_CONCEPT_API, POST_REQUEST, 200)
     except Exception as err:
         return flask_request_response.error_response([str(err)],
                                                      DELEETE_CONCEPT_API,
                                                      POST_REQUEST)
Esempio n. 15
0
    def post(self):
        """Request for sub tasks."""

        request, error_message = flask_request_response.message_request(
            _api_input_pb2.SubTaskData, SUB_TASK_DATA_API, POST_REQUEST)
        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message'], "msg response"],
                SUB_TASK_DATA_API, POST_REQUEST)
        try:
            print("==========>")

            sub_task_data_response = sub_task_data_query_response(
                request.chapter_id)
            response = _api_output_pb2.SubTaskData()
            sub_task_data_result = _json_format.ParseDict(
                sub_task_data_response, response)
            return flask_request_response.message_response(
                sub_task_data_result, SUB_TASK_DATA_API, POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response(
                [str(err), "try response"], SUB_TASK_DATA_API, POST_REQUEST)
    def post(self):
        """Request for dependent concepts."""

        request, error_message = flask_request_response.message_request(
            _api_input_pb2.GetDependentConcepts, DEPENDENT_CONCEPTS_API,
            POST_REQUEST)
        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message'], "msg response"],
                DEPENDENT_CONCEPTS_API, POST_REQUEST)
        try:
            dependent_concepts_response = dependent_concepts_query_response(
                request.concept_id, request.mcq_id)
            response = _api_output_pb2.GetDependentConcepts()
            dependent_concepts_result = _json_format.ParseDict(
                dependent_concepts_response, response)
            return flask_request_response.message_response(
                dependent_concepts_result, DEPENDENT_CONCEPTS_API,
                POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response(
                [str(err), "try response"], DEPENDENT_CONCEPTS_API,
                POST_REQUEST)
Esempio n. 17
0
 def post(self):
     """Get all the task assigned for the user dashboard."""
     request, error_message = flask_request_response.message_request(
         _api_intput_pb2.GetUserDashboard, USER_DASHBOARD_API, POST_REQUEST
     )
     if error_message is not None:
         return flask_request_response.error_response(
             [error_message['err_message']], USER_DASHBOARD_API,
             POST_REQUEST
         )
     try:
         user_dashboard_response = get_user_dashboard_query_response(
             request.username)
         response = _api_output_pb2.GetUserDashboard()
         result = _json_format.ParseDict(user_dashboard_response, response)
         return flask_request_response.message_response(
             result,
             USER_DASHBOARD_API, POST_REQUEST, 200
         )
     except Exception as err:
         return flask_request_response.error_response(
             [str(err)], USER_DASHBOARD_API, POST_REQUEST
         )
    def post(self):
        """Add dependent concept to database."""
        request, error_message = flask_request_response.message_request(
            _api_intput_pb2.AddDependentConcept, ADD_DEPENDENT_CONCEPT_API,
            POST_REQUEST)

        if error_message is not None:
            return flask_request_response.error_response(
                [error_message['err_message']], ADD_DEPENDENT_CONCEPT_API,
                POST_REQUEST)

        try:
            dependent_concept_response = add_dependent_concept_query_response(
                request.concept_key, request.dependent_concept_name,
                request.dependent_concept_key, request.created_by)
            response = _api_output_pb2.AddDependentConcept()
            dependent_concept_result = _json_format.ParseDict(
                dependent_concept_response, response)
            return flask_request_response.message_response(
                dependent_concept_result, ADD_DEPENDENT_CONCEPT_API,
                POST_REQUEST, 200)
        except Exception as err:
            return flask_request_response.error_response(
                [str(err)], ADD_DEPENDENT_CONCEPT_API, POST_REQUEST)