def get(self, id): application = ApplicationModel.find_by_id(id) if application is not None: job = application.json()['job'] candidate = application.json()['candidate'] return {'job': job, 'candidate': candidate}, 200 else: return {'error': 'Application with that id doesnot exist'}, 404
def getSecurtyIds(self, appId): if appId in self.appSecurtyDict.keys(): return self.appSecurtyDict[appId] SecurtyIdArray = [] Application = ApplicationModel.find_by_id(appId) SecurityApplictions = SecurityApplictionModel.find_by_applicationID( appId) for SecurityAppliction in SecurityApplictions: # check if to this security have image if SecurityAppliction.securityRankIdFeature != -1: SecurtyIdArray.append(SecurityAppliction.securityId) self.appSecurtyDict[appId] = SecurtyIdArray return self.appSecurtyDict[appId]
def get(self, _id): application = ApplicationModel.find_by_id(_id) if not safe_str_cmp( current_identity.lendercode, '000') and not safe_str_cmp( current_identity.lendercode, application.lendercode): return { 'Message': "You do not have access to that application. Application lendercode: {} and User lendercode: {}" .format(application.lendercode, current_identity.lendercode) }, 401 if application: return {'Application': application.json()}, 200 return {"Message": "No application found with that ID."}, 404
def put(self): data = Application.parser.parse_args() application = ApplicationModel.find_by_id(data['id']) if application == None: return { 'Message': "Application with id of '{}' does not exist.".format( data['id']) }, 404 if not safe_str_cmp( current_identity.lendercode, '000') and not safe_str_cmp( current_identity.lendercode, application.lendercode): return { 'Message': "You do not have access to that application. Application lendercode: {} and User lendercode: {}" .format(application.lendercode, current_identity.lendercode) }, 401 application.firstname = data['firstname'] application.lastname = data['lastname'] application.ssn = data['ssn'] application.employer = data['employer'] application.income = data['income'] application.incomeFrequency = data['incomeFrequency'] application.requestedAmount = data['requestedAmount'] application.requestedTerm = data['requestedTerm'] application.phoneNumber = data['phoneNumber'] application.emailAddress = data['emailAddress'] application.isBranchEmployee = data['isBranchEmployee'] application.employeeID = data['employeeID'] application.lendercode = data['lendercode'] application.status = "Re-Submitted" if data['status']: application.status = data['status'] else: application.getNewStatus() application.save_to_db() return { 'Message': 'Application re-submitted successfully.', 'Application': application.json() }, 200
def delete(self, _id): application = ApplicationModel.find_by_id(_id) if application is None: return { 'Message': "Application with id of '{}' does not exist.".format(_id) }, 404 if not safe_str_cmp( current_identity.lendercode, '000') and not safe_str_cmp( current_identity.lendercode, application.lendercode): return { 'Message': "You do not have access to that application. Application lendercode: {} and User lendercode: {}" .format(application.lendercode, current_identity.lendercode) }, 401 if application: application.delete_from_db() return {'Message': 'Application deleted.'}, 200
def getAppImage(self, appId): if appId in self.appDict.keys(): return self.appDict[appId] root = '/pictures/' imageDict = {} imageArray = [] Application = ApplicationModel.find_by_id(appId) if (Application != False): imageDict['picture1'] = root + Application.picture1 imageDict['picture2'] = root + Application.picture2 imageArray.append(Application.picture1) imageArray.append(Application.picture2) SecurityApplictions = SecurityApplictionModel.find_by_applicationID( appId) imageDict['securtyImges'] = [] for SecurityAppliction in SecurityApplictions: # check if to this security have image if SecurityAppliction.securityRankIdFeature != -1: imageDict['securtyImges'].append(root + SecurityAppliction.image) imageArray.append(SecurityAppliction.image) self.appDict[appId] = imageDict return imageDict
def get(self, _id=None): app = ApplicationModel.find_by_id(_id) if app: return app.json(), 200 return {'message': 'Application not found'.format(_id)}, 404