def put(requesttype, commentid): if requesttype != "ministryrequest" and requesttype != "rawrequest": return { 'status': False, 'message': EXCEPTION_MESSAGE_BAD_REQUEST }, 400 try: requestjson = request.get_json() if requesttype == "ministryrequest": commentschema = FOIMinistryRequestCommentSchema().load( requestjson) result = commentservice().updateministryrequestcomment( commentid, commentschema, AuthHelper.getuserid()) else: commentschema = EditFOIRawRequestCommentSchema().load( requestjson) result = commentservice().updaterawrequestcomment( commentid, commentschema, AuthHelper.getuserid()) return { 'status': result.success, 'message': result.message, 'id': result.identifier }, 200 except KeyError as err: return {'status': False, 'message': err.messages}, 400 except BusinessException as exception: return { 'status': exception.status_code, 'message': exception.message }, 500
def put(requesttype, commentid): if requesttype != "ministryrequest" and requesttype != "rawrequest": return { 'status': False, 'message': EXCEPTION_MESSAGE_BAD_REQUEST }, 400 try: if requesttype == "ministryrequest": result = commentservice().disableministryrequestcomment( commentid, AuthHelper.getuserid()) else: result = commentservice().disablerawrequestcomment( commentid, AuthHelper.getuserid()) return { 'status': result.success, 'message': result.message, 'id': result.identifier }, 200 except KeyError as err: return {'status': False, 'message': err.messages}, 400 except BusinessException as exception: return { 'status': exception.status_code, 'message': exception.message }, 500
def createcomment(self, ministryrequestid, userid, username, extensionsummary): comment = { "ministryrequestid": ministryrequestid, "comment": self.__preparemessage(username, extensionsummary) } commentservice().createministryrequestcomment(comment, userid, 2)
def __createcomment(self, requestid, state, requesttype, userid, username): comment = self.__preparecomment(requestid, state, requesttype, username) if requesttype == "ministryrequest": return commentservice().createministryrequestcomment( comment, userid, 2) else: return commentservice().createrawrequestcomment(comment, userid, 2)
def get(requesttype, requestid): if requesttype != "ministryrequest" and requesttype != "rawrequest": return { 'status': False, 'message': EXCEPTION_MESSAGE_BAD_REQUEST }, 400 try: if requesttype == "ministryrequest": result = commentservice().getministryrequestcomments(requestid) else: result = commentservice().getrawrequestcomments(requestid) return json.dumps(result), 200 except KeyError as err: return {'status': False, 'message': err.messages}, 400 except BusinessException as exception: return { 'status': exception.status_code, 'message': exception.message }, 500
def post(): try: requestjson = request.get_json() rawrqcommentschema = FOIRawRequestCommentSchema().load(requestjson) result = commentservice().createrawrequestcomment( rawrqcommentschema, AuthHelper.getuserid()) if result.success == True: asyncio.create_task(eventservice().postcommentevent( result.identifier, "rawrequest", AuthHelper.getuserid())) return { 'status': result.success, 'message': result.message, 'id': result.identifier }, 200 except KeyError as err: return {'status': False, 'message': err.messages}, 400 except BusinessException as exception: return { 'status': exception.status_code, 'message': exception.message }, 500
def createcomment(self, requestid, division, stage, event, userid): comment = { "ministryrequestid": requestid, "comment": self.__preparemessage(division, stage, event) } commentservice().createministryrequestcomment(comment, userid, 2)
def copycomments(self, rawrequestid, ministries, userid): comments = commentservice().getrawrequestcomments(int(rawrequestid)) for ministry in ministries: commentservice().copyrequestcomment(ministry["id"], comments, userid)