Example #1
0
 def post():
     """ POST Method for capturing RAW FOI requests before processing"""
     try:
         request_json = request.get_json()
         requestdatajson = request_json['requestData']
         #get attachments
         attachments = requestdatajson[
             'Attachments'] if 'Attachments' in requestdatajson else None
         notes = 'Request submission from FOI WebForm'
         #save request
         if attachments is not None:
             requestdatajson.pop('Attachments')
         result = rawrequestservice().saverawrequest(
             requestdatajson=requestdatajson,
             sourceofsubmission="onlineform",
             userid=None,
             notes=notes)
         if result.success:
             documentservice().uploadpersonaldocuments(
                 result.identifier, attachments)
         return {
             'status': result.success,
             'message': result.message,
             'id': result.identifier
         }, 200
     except TypeError:
         return {
             'status': "TypeError",
             'message': "Error while parsing JSON in request"
         }, 500
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
Example #2
0
 def saverawrequestversion(self, _requestdatajson, _requestid, _assigneegroup, _assignee, status, userid, username, isministryuser, assigneefirstname, assigneemiddlename, assigneelastname):
     ispiiredacted = _requestdatajson["ispiiredacted"] if 'ispiiredacted' in _requestdatajson  else False
     #Get documents
     result = FOIRawRequest.saverawrequestversion(_requestdatajson, _requestid, _assigneegroup, _assignee, status,ispiiredacted, userid, assigneefirstname, assigneemiddlename, assigneelastname)
     documentservice().createrawrequestdocumentversion(_requestid)
     asyncio.create_task(eventservice().postevent(_requestid,"rawrequest",userid, username, isministryuser))
     return result
Example #3
0
 def deletedocuments(self, extensionid, extensionversion, ministryrequestid,
                     userid):
     documents = self.__getextensiondocuments(extensionid, extensionversion)
     for document in documents:
         documentservice().deleterequestdocument(
             ministryrequestid, document["foiministrydocumentid"], userid,
             "ministryrequest")
Example #4
0
 def post(requestid, documentid, requesttype):      
     try:
         result = documentservice().deleterequestdocument(requestid, documentid, AuthHelper.getuserid(), requesttype)
         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 
Example #5
0
 def get(requestid, requesttype): 
     if requesttype != "ministryrequest" and requesttype != "rawrequest":
         return {'status': False, 'message':'Bad Request'}, 400          
     try:
         result = documentservice().getrequestdocumentsbyrole(requestid, requesttype, AuthHelper.isministrymember())
         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   
Example #6
0
 def __savedocumentversion(self, ministryrequestid, extensiondocumentschema,
                           userid):
     documentids = []
     for document in extensiondocumentschema:
         if 'foiministrydocumentid' in document:
             documentid = document['foiministrydocumentid']
         else:
             documentid = 0
         documentresult = documentservice().createministrydocumentversion(
             ministryrequestid, documentid, document, userid)
         documentids.append(documentresult.identifier)
     return documentids
Example #7
0
 def post(requestid, documentid, requesttype):      
     try:
         requestjson = request.get_json() 
         documentschema = RenameDocumentSchema().load(requestjson)
         result = documentservice().createrequestdocumentversion(requestid, documentid, documentschema, AuthHelper.getuserid(), requesttype)
         return {'status': result.success, 'message':result.message,'id':result.identifier} , 200 
     except ValidationError as err:
                 return {'status': False, 'message':err.messages}, 400
     except KeyError as err:
         return {'status': False, 'message':err.messages}, 400        
     except BusinessException as exception:            
         return {'status': exception.status_code, 'message':exception.message}, 500 
Example #8
0
 def post(requestid, requesttype):      
     try:
         if requesttype != "ministryrequest" and requesttype != "rawrequest":
             return {'status': False, 'message':'Bad Request'}, 400
         requestjson = request.get_json() 
         documentschema = CreateDocumentSchema().load(requestjson)
         result = documentservice().createrequestdocument(requestid, documentschema, AuthHelper.getuserid(), requesttype)
         return {'status': result.success, 'message':result.message} , 200 
     except ValidationError as err:
                 return {'status': False, 'message':err.messages}, 400
     except KeyError as err:
         return {'status': False, 'message':err.messages}, 400        
     except BusinessException as exception:            
         return {'status': exception.status_code, 'message':exception.message}, 500 
Example #9
0
 def copydocuments(self, rawrequestid,ministries,userid):
     attachments = documentservice().getrequestdocuments(int(rawrequestid),"rawrequest")
     for ministry in ministries:
         documentservice().copyrequestdocuments(ministry["id"], attachments, userid)