def test_get_rawrequests(session):
    response = rawrequestservice().getrawrequests()
    assert response
    requestid =''   
    for item in response:
        requestid = item['id']        
        assert item['id'] and item['requestType']
    getresponse = rawrequestservice().getrawrequest(requestid)
    assert getresponse['requestType']        
Exemple #2
0
    def post(requestid=None):
        try:
            updaterequest = request.get_json()
            if int(requestid) and str(requestid) != "-1":
                status = rawrequestservice().getstatus(updaterequest)
                rawrequest = rawrequestservice().getrawrequest(requestid)
                requestdata = getparams(updaterequest)

                assigneegroup = requestdata['assigneegroup']
                assignee = requestdata['assignee']
                assigneefirstname = requestdata['assigneefirstname']
                assigneemiddlename = requestdata['assigneemiddlename']
                assigneelastname = requestdata['assigneelastname']
                result = rawrequestservice().saverawrequestversion(
                    updaterequest, requestid, assigneegroup, assignee, status,
                    AuthHelper.getuserid(), AuthHelper.getusername(),
                    AuthHelper.isministrymember(), assigneefirstname,
                    assigneemiddlename, assigneelastname)
                if result.success == True:
                    asyncio.create_task(
                        rawrequestservice().posteventtoworkflow(
                            result.identifier, rawrequest['wfinstanceid'],
                            updaterequest, status))
                    return {
                        'status': result.success,
                        'message': result.message
                    }, 200
            elif int(requestid) and str(requestid) == "-1":
                result = rawrequestservice().saverawrequest(
                    updaterequest,
                    "intake",
                    AuthHelper.getuserid(),
                    notes="Request submitted from FOI Flow")
                asyncio.create_task(eventservice().postevent(
                    result.identifier, "rawrequest", AuthHelper.getuserid(),
                    AuthHelper.getusername(), AuthHelper.isministrymember()))
                return {
                    'status': result.success,
                    'message': result.message,
                    'id': result.identifier
                }, 200
        except ValueError:
            return {'status': 500, 'message': INVALID_REQUEST_ID}, 500
        except BusinessException as exception:
            return {
                'status': exception.status_code,
                'message': exception.message
            }, 500
Exemple #3
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
Exemple #4
0
    def put(_requestid=None):
        request_json = request.get_json()
        try:

            _wfinstanceid = request_json['wfinstanceid']
            notes = request_json['notes'] if request_json.get(
                'notes') is not None else 'Workflow Update'
            requestid = int(_requestid)
            result = rawrequestservice().updateworkflowinstancewithstatus(
                _wfinstanceid, requestid, notes, AuthHelper.getuserid())
            if result.identifier != -1:
                return {
                    'status': result.success,
                    'message': result.message
                }, 200
            else:
                return {
                    'status': result.success,
                    'message': result.message
                }, 404
        except KeyError:
            return {
                'status':
                "Invalid PUT request",
                'message':
                "Key Error on JSON input, please confirm requestid and wfinstanceid"
            }, 500
        except ValueError as valuexception:
            return {
                'status': "BAD Request",
                'message': str(valuexception)
            }, 500
Exemple #5
0
 def post(requestid=None):
     try:
         updaterequest = request.get_json()
         userid = updaterequest['assignedTo']
         username = '******'
         if int(requestid) and str(requestid) == "-1":
             result = rawrequestservice().saverawrequest(
                 updaterequest,
                 "intake",
                 userid,
                 notes="Request submitted from FOI Flow")
             asyncio.create_task(eventservice().postevent(
                 result.identifier, "rawrequest", userid, username, False))
             return {
                 'status': result.success,
                 'message': result.message,
                 'id': result.identifier
             }, 200
     except ValueError:
         return {'status': 500, 'message': INVALID_REQUEST_ID}, 500
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
Exemple #6
0
 def post():
     """ POST Method for capturing FOI requests before processing"""
     try:
         request_json = request.get_json()
         foirequestschema = FOIRequestWrapperSchema().load(request_json)
         assignedgroup = request_json[
             'assignedGroup'] if 'assignedGroup' in foirequestschema else None
         assignedto = request_json[
             'assignedTo'] if 'assignedTo' in foirequestschema else None
         assignedtofirstname = request_json[
             "assignedToFirstName"] if request_json.get(
                 "assignedToFirstName") != None else None
         assignedtomiddlename = request_json[
             "assignedToMiddleName"] if request_json.get(
                 "assignedToMiddleName") != None else None
         assignedtolastname = request_json[
             "assignedToLastName"] if request_json.get(
                 "assignedToLastName") != None else None
         rawresult = rawrequestservice().saverawrequestversion(
             request_json, request_json['id'], assignedgroup, assignedto,
             "Archived", AuthHelper.getuserid(), AuthHelper.getusername(),
             AuthHelper.isministrymember(), assignedtofirstname,
             assignedtomiddlename, assignedtolastname)
         if rawresult.success == True:
             result = requestservice().saverequest(foirequestschema,
                                                   AuthHelper.getuserid())
             if result.success == True:
                 requestservice().copywatchers(request_json['id'],
                                               result.args[0],
                                               AuthHelper.getuserid())
                 requestservice().copycomments(request_json['id'],
                                               result.args[0],
                                               AuthHelper.getuserid())
                 requestservice().copydocuments(request_json['id'],
                                                result.args[0],
                                                AuthHelper.getuserid())
                 requestservice().postopeneventtoworkflow(
                     result.identifier, rawresult.args[0], request_json,
                     result.args[0])
         return {
             'status': result.success,
             'message': result.message,
             'id': result.identifier,
             'ministryRequests': result.args[0]
         }, 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
Exemple #7
0
 def get(requestid):
     try:
         # here we want to get the value of names (i.e. ?names=ministries)
         if request.args['names'] == "ministries":
             baserequestinfo = rawrequestservice().getrawrequestfields(
                 requestid, ["ministries"])
             return json.dumps(baserequestinfo), 200
     except ValueError:
         return {'status': 500, 'message': "Invalid Request"}, 400
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
Exemple #8
0
 def get(requestid=None):
     try:
         jsondata = {}
         requestidisinteger = int(requestid)
         if requestidisinteger:
             baserequestinfo = rawrequestservice().getrawrequest(requestid)
             jsondata = json.dumps(baserequestinfo)
         return jsondata, 200
     except ValueError:
         return {'status': 500, 'message': INVALID_REQUEST_ID}, 500
     except BusinessException as exception:
         return {
             'status': exception.status_code,
             'message': exception.message
         }, 500
def test_save_rawrequest(session):
    response = rawrequestservice().saverawrequest(requestjson,'onlineform',None,None)
    requestid = response.identifier
    pytest.approxrequestidtoupdate = requestid
    wfupdateresponse = rawrequestservice().updateworkflowinstance(str(uuid.uuid4()),requestid,'service-account-forms-flow-bpm')
    assert response.success == True and wfupdateresponse.success == True