Пример #1
0
 def saveministryrequestversion(self, ministryrequestschema, foirequestid,
                                ministryid, userid):
     _foirequest = FOIRequest().getrequest(foirequestid)
     _foiministryrequest = FOIMinistryRequest(
     ).getrequestbyministryrequestid(ministryid)
     _foirequestapplicant = FOIRequestApplicantMapping(
     ).getrequestapplicants(foirequestid, _foirequest["version"])
     _foirequestcontact = FOIRequestContactInformation(
     ).getrequestcontactinformation(foirequestid, _foirequest["version"])
     _foirequestpersonalattrbs = FOIRequestPersonalAttribute(
     ).getrequestpersonalattributes(foirequestid, _foirequest["version"])
     foiministryrequestarr = []
     foirequest = requestserviceministrybuilder(
     ).createfoirequestfromobject(_foirequest, userid)
     foiministryrequest = requestserviceministrybuilder(
     ).createfoiministryrequestfromobject(_foiministryrequest,
                                          ministryrequestschema, userid)
     foiministryrequestarr.append(foiministryrequest)
     foirequest.ministryRequests = foiministryrequestarr
     foirequest.requestApplicants = requestserviceministrybuilder(
     ).createfoirequestappplicantfromobject(_foirequestapplicant,
                                            foirequestid,
                                            _foirequest['version'] + 1,
                                            userid)
     foirequest.contactInformations = requestserviceministrybuilder(
     ).createfoirequestcontactfromobject(_foirequestcontact, foirequestid,
                                         _foirequest['version'] + 1, userid)
     foirequest.personalAttributes = requestserviceministrybuilder(
     ).createfoirequestpersonalattributefromobject(
         _foirequestpersonalattrbs, foirequestid,
         _foirequest['version'] + 1, userid)
     FOIMinistryRequest.deActivateFileNumberVersion(
         ministryid, _foiministryrequest['filenumber'],
         _foiministryrequest['version'] + 1, userid)
     return FOIRequest.saverequest(foirequest)
Пример #2
0
 def updaterequest(self, foirequestschema, foirequestid, userid):
     if self.isNotBlankorNone(foirequestschema, "wfinstanceid",
                              "main") == True:
         return FOIRequest.updateWFInstance(
             foirequestid, foirequestschema.get("wfinstanceid"), userid)
     if foirequestschema.get("selectedMinistries") is not None:
         allstatus = FOIRequestStatus().getrequeststatuses()
         updatedministries = []
         for ministry in foirequestschema.get("selectedMinistries"):
             for status in allstatus:
                 if ministry["status"] == status["name"]:
                     updatedministries.append({
                         "filenumber":
                         ministry["filenumber"],
                         "requeststatusid":
                         status["requeststatusid"]
                     })
         return FOIRequest.updateStatus(foirequestid, updatedministries,
                                        userid)
Пример #3
0
 def getrequestdetailsforministry(self, foirequestid, foiministryrequestid,
                                  authmembershipgroups):
     request = FOIRequest.getrequest(foirequestid)
     requestministry = FOIMinistryRequest.getrequestbyministryrequestid(
         foiministryrequestid)
     requestministrydivisions = FOIMinistryRequestDivision.getdivisions(
         foiministryrequestid, requestministry['version'])
     baserequestinfo = {}
     if requestministry["assignedministrygroup"] in authmembershipgroups:
         baserequestinfo = self.__preparebaseinfo(request,
                                                  foiministryrequestid,
                                                  requestministry,
                                                  requestministrydivisions)
     return baserequestinfo
Пример #4
0
 def saverequestversion(self, foirequestschema, foirequestid, ministryid,
                        userid):
     activeversion = 1
     filenumber = foirequestschema.get("idNumber")
     #Identify version
     if foirequestid is not None:
         _foirequest = FOIRequest().getrequest(foirequestid)
         if _foirequest != {}:
             activeversion = _foirequest["version"] + 1
         else:
             return _foirequest
         FOIMinistryRequest.deActivateFileNumberVersion(
             ministryid, filenumber, activeversion, userid)
         self.__disablewatchers(ministryid, foirequestschema, userid)
         return self.saverequest(foirequestschema, userid, foirequestid,
                                 ministryid, filenumber, activeversion,
                                 _foirequest["foirawrequestid"],
                                 _foirequest["wfinstanceid"])
Пример #5
0
 def __getauditfromrawrequest(self, type, id, groups):
     _rawdescriptions = []
     if type == "ministryrequest":
         requestrecord  = FOIRequest().getrequest(id)
         rawrequestid= requestrecord['foirawrequestid']
     else:
         rawrequestid= id
     rawrecords = FOIRawRequest().getDescriptionSummaryById(rawrequestid) 
     
     
     for entry in rawrecords:
         fromdate =dateutil.parser.parse(entry['fromdate']).strftime('%Y-%m-%d') if entry['fromdate'] is not None else None 
         todate = dateutil.parser.parse(entry['todate']).strftime('%Y-%m-%d') if entry['todate'] is not None else None
         if AuthHelper.getusertype() == "iao":
             _rawdescriptions.append({"description": entry['description'], "fromdate": fromdate, "todate": todate, "createdat": entry['createdat'] , "createdby": entry['createdby'], "status": entry['status']})        
         else:
             if entry['ispiiredacted'] == True:
                 _rawdescriptions.append({"description": entry['description'], "fromdate": fromdate, "todate": todate, "createdat": entry['createdat'] , "createdby": entry['createdby'], "status": entry['status']})            
     return _rawdescriptions
 def createfoirequestfromobject(self, foiobject, userid):
     foirequest = FOIRequest()
     foirequest.foirawrequestid = foiobject['foirawrequestid']
     foirequest.foirequestid = foiobject['foirequestid']
     foirequest.version = foiobject["version"] + 1
     foirequest.initialdescription = foiobject['initialdescription']
     foirequest.initialrecordsearchfromdate = foiobject[
         'initialrecordsearchfromdate'] if 'initialrecordsearchfromdate' in foiobject else None
     foirequest.initialrecordsearchtodate = foiobject[
         'initialrecordsearchfromdate'] if 'initialrecordsearchfromdate' in foiobject else None
     foirequest.receiveddate = foiobject[
         'receiveddate'] if 'receiveddate' in foiobject else None
     foirequest.requesttype = foiobject['requesttype']
     foirequest.wfinstanceid = foiobject['wfinstanceid']
     foirequest.applicantcategoryid = foiobject[
         "applicantcategory.applicantcategoryid"]
     foirequest.deliverymodeid = foiobject["deliverymode.deliverymodeid"]
     foirequest.receivedmodeid = foiobject["receivedmode.receivedmodeid"]
     foirequest.createdby = userid
     return foirequest
Пример #7
0
    def saverequest(self,
                    foirequestschema,
                    userid,
                    foirequestid=None,
                    ministryid=None,
                    filenumber=None,
                    version=None,
                    rawrequestid=None,
                    wfinstanceid=None):
        activeversion = 1 if version is None else version

        # FOI Request
        openfoirequest = FOIRequest()
        openfoirequest.foirawrequestid = foirequestschema.get(
            "foirawrequestid") if rawrequestid is None else rawrequestid
        openfoirequest.version = activeversion
        openfoirequest.requesttype = foirequestschema.get("requestType")
        openfoirequest.initialdescription = foirequestschema.get("description")
        openfoirequest.receiveddate = foirequestschema.get("receivedDate")
        openfoirequest.ministryRequests = self.__prepareministries(
            foirequestschema, activeversion, filenumber, ministryid, userid)
        openfoirequest.contactInformations = self.__prearecontactinformation(
            foirequestschema, userid)
        if requestservicebuilder().isNotBlankorNone(foirequestschema,
                                                    "fromDate",
                                                    "main") == True:
            openfoirequest.initialrecordsearchfromdate = foirequestschema.get(
                "fromDate")
        if requestservicebuilder().isNotBlankorNone(foirequestschema, "toDate",
                                                    "main") == True:
            openfoirequest.initialrecordsearchtodate = foirequestschema.get(
                "toDate")
        if requestservicebuilder().isNotBlankorNone(foirequestschema,
                                                    "deliveryMode",
                                                    "main") == True:
            openfoirequest.deliverymodeid = requestserviceconfigurator(
            ).getvalueof("deliveryMode", foirequestschema.get("deliveryMode"))
        if requestservicebuilder().isNotBlankorNone(foirequestschema,
                                                    "receivedMode",
                                                    "main") == True:
            openfoirequest.receivedmodeid = requestserviceconfigurator(
            ).getvalueof("receivedMode", foirequestschema.get("receivedMode"))
        if requestservicebuilder().isNotBlankorNone(foirequestschema,
                                                    "category",
                                                    "main") == True:
            openfoirequest.applicantcategoryid = requestserviceconfigurator(
            ).getvalueof("category", foirequestschema.get("category"))
        openfoirequest.personalAttributes = self._prearepersonalattributes(
            foirequestschema, userid)
        openfoirequest.requestApplicants = self.__prepareapplicants(
            foirequestschema, userid)
        if foirequestid is not None:
            openfoirequest.foirequestid = foirequestid
        openfoirequest.wfinstanceid = wfinstanceid if wfinstanceid is not None else None
        openfoirequest.createdby = userid
        return FOIRequest.saverequest(openfoirequest)
Пример #8
0
    def getrequest(self, foirequestid, foiministryrequestid):
        request = FOIRequest.getrequest(foirequestid)
        requestministry = FOIMinistryRequest.getrequestbyministryrequestid(
            foiministryrequestid)
        requestcontactinformation = FOIRequestContactInformation.getrequestcontactinformation(
            foirequestid, request['version'])
        requestapplicants = FOIRequestApplicantMapping.getrequestapplicants(
            foirequestid, request['version'])
        personalattributes = FOIRequestPersonalAttribute.getrequestpersonalattributes(
            foirequestid, request['version'])
        requestministrydivisions = FOIMinistryRequestDivision.getdivisions(
            foiministryrequestid, requestministry['version'])

        baserequestinfo = self.__preparebaseinfo(request, foiministryrequestid,
                                                 requestministry,
                                                 requestministrydivisions)
        baserequestinfo[
            'lastStatusUpdateDate'] = FOIMinistryRequest.getLastStatusUpdateDate(
                foiministryrequestid,
                requestministry['requeststatus.requeststatusid']).strftime(
                    self.__genericdateformat()),
        for contactinfo in requestcontactinformation:
            if contactinfo['contacttype.name'] == 'Email':
                baserequestinfo.update(
                    {'email': contactinfo['contactinformation']})
            else:
                baserequestinfo.update({
                    contactinfo['dataformat']:
                    contactinfo['contactinformation']
                })

        additionalpersonalinfo = {}
        for applicant in requestapplicants:
            firstname = applicant['foirequestapplicant.firstname']
            middlename = applicant['foirequestapplicant.middlename']
            lastname = applicant['foirequestapplicant.lastname']
            businessname = applicant['foirequestapplicant.businessname']
            dob = parse(applicant['foirequestapplicant.dob']).strftime(
                self.__genericdateformat(
                )) if applicant['foirequestapplicant.dob'] is not None else ''
            alsoknownas = applicant['foirequestapplicant.alsoknownas']
            requestortypeid = applicant['requestortype.requestortypeid']
            if requestortypeid == 1:
                baserequestinfo.update(
                    self.__prepareapplicant(firstname, middlename, lastname,
                                            businessname))
            additionalpersonalinfo.update(
                self.__prepareadditionalpersonalinfo(firstname, middlename,
                                                     lastname, dob,
                                                     alsoknownas,
                                                     requestortypeid))

        for personalattribute in personalattributes:
            attribute, location = self.__preparepersonalattribute(
                personalattribute)
            if location == "main":
                baserequestinfo.update(attribute)
            elif location == "additionalPersonalInfo":
                additionalpersonalinfo.update(attribute)

        baserequestinfo['additionalPersonalInfo'] = additionalpersonalinfo
        originalduedate = FOIMinistryRequest.getrequestoriginalduedate(
            foiministryrequestid)
        baserequestinfo['originalDueDate'] = originalduedate.strftime(
            self.__genericdateformat())
        return baserequestinfo