Пример #1
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)
Пример #2
0
 def __prearecontactinformation(self, foirequestschema, userid):
     contactinformationarr = []
     contacttypes = ContactType().getcontacttypes()
     for contact in requestserviceconfigurator().contacttypemapping():
         if foirequestschema.get(contact["key"]) is not None:
             contactinformationarr.append(
                 requestservicebuilder().createcontactinformation(
                     contact["key"], contact["name"],
                     foirequestschema.get(contact["key"]), contacttypes,
                     userid))
     return contactinformationarr
Пример #3
0
 def __disablewatchers(self, ministryid, requestschema, userid):
     requeststatusid = requestschema.get(
         "requeststatusid") if 'requeststatusid' in requestschema else None
     if requeststatusid is not None:
         status = requestserviceconfigurator().getstatusname(
             requeststatusid)
         if status == "Open":
             watchers = watcherservice().getministryrequestwatchers(
                 int(ministryid), True)
             for watcher in watchers:
                 watcherschema = {
                     "ministryrequestid": ministryid,
                     "watchedbygroup": watcher["watchedbygroup"],
                     "watchedby": watcher["watchedby"],
                     "isactive": False
                 }
                 watcherservice().createministryrequestwatcher(
                     watcherschema, userid, None)
Пример #4
0
 def _prearepersonalattributes(self, foirequestschema, userid):
     personalattributearr = []
     if foirequestschema.get("requestType") == "personal":
         attributetypes = PersonalInformationAttribute(
         ).getpersonalattributes()
         for attrb in requestserviceconfigurator().personalattributemapping(
         ):
             attrbvalue = None
             if attrb["location"] == "main" and requestservicebuilder(
             ).isNotBlankorNone(foirequestschema, attrb["key"],
                                "main") == True:
                 attrbvalue = foirequestschema.get(attrb["key"])
             if attrb[
                     "location"] == "additionalPersonalInfo" and requestservicebuilder(
                     ).isNotBlankorNone(foirequestschema, attrb["key"],
                                        "additionalPersonalInfo") == True:
                 attrbvalue = foirequestschema.get(
                     attrb["location"])[attrb["key"]]
             if attrbvalue is not None and attrbvalue and attrbvalue != "":
                 personalattributearr.append(
                     requestservicebuilder().createpersonalattribute(
                         attrb["name"], attrbvalue, attributetypes, userid))
     return personalattributearr
Пример #5
0
 async def posteventtoworkflow(self, id, wfinstanceid, requestschema, data, usertype): 
     requeststatusid =  requestschema.get("requeststatusid") if 'requeststatusid' in requestschema  else None 
     if requeststatusid is not None:
         status = requestserviceconfigurator().getstatusname(requeststatusid)
         workflowservice().postopenedevent(id, wfinstanceid, requestschema, data, status, usertype)