def post(self): data = Application.parser.parse_args() if not safe_str_cmp( current_identity.lendercode, '000') and not safe_str_cmp( current_identity.lendercode, '1') and not safe_str_cmp( current_identity.lendercode, data['lendercode']): return { 'Message': "You do not have access to submit to that lender. Application lendercode: {} and User lendercode: {}" .format(data['lendercode'], current_identity.lendercode) }, 401 appData = (data['firstname'], data['lastname'], data['ssn'], data['employer'], data['income'], data['incomeFrequency'], data['requestedAmount'], data['requestedTerm'], data['phoneNumber'], data['emailAddress'], data['isBranchEmployee'], data['employeeID'], data['lendercode'], "Submitted") application = ApplicationModel(appData) application.getNewStatus() application.save_to_db() return { 'Message': 'Application submitted successfully.', 'Application': application.json() }, 200
def post(self): parser = self.default_parser parser.add_argument('name', type=str, required=True, help="An app needs a name") parser.add_argument('photo', type=str) parser.add_argument('description', type=str) data = parser.parse_args() app = ApplicationModel.find_by_name(data.get('name')) if app: return { 'message': 'Application is already registered with id {}'.format(app.id) } app = ApplicationModel(**data) try: app.save_to_db() except Exception as e: return { 'message': 'something goes wrong with your insert db action', 'error': e.args } return app.json(), 201
def post(self): parser = reqparse.RequestParser() parser.add_argument('job', type=int, required=True, help="This field cannot be blank") parser.add_argument('user', type=int, required=True, help="This field cannot be blank") data = parser.parse_args() application_job = data['job'] application_candidate = data['user'] find_if_application_exists = ApplicationModel.find_by_job_and_candidate( application_job, application_candidate) if find_if_application_exists: return { 'message': 'Application Already exists with the job and the candidate' }, 400 job = ApplicationModel(application_job, application_candidate) job.save_to_db() return {'message': 'Application Created Successfully'}, 200