Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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