Ejemplo n.º 1
0
 def post(self):
     parser = reqparse.RequestParser()
     parser.add_argument('type', type=str, required=True, help='Account type cannot be blank!')
     parser.add_argument('number', type=str, required=True, help='Account number cannot be blank!')
     parser.add_argument('name', type=str, required=True, help='User Name cannot be blank!')
     parser.add_argument('first_name', type=str, required=True, help='User Fist Name cannot be blank!')
     parser.add_argument('address', type=str, required=True, help='User address cannot be blank!')
     parser.add_argument('birthdate', type=str, required=True, help='User birthdate cannot be blank!')
     args = parser.parse_args()
     account = AccountModel(
         account_type = args['type'],
         account_number = args['number'],
         name = args['name'],
         first_name = args['first_name'],
         address = args['address'],
         birthdate = args['birthdate'],
         )
     account.id = db.get_max_id()+1
     location = geolocator.geocode(account.address)
     if location != None:
         account.latitude = location.latitude
         account.longitude = location.longitude
     else:
         account.latitude = None;
         account.longitude = None;
     db.post(account.type, account.number, account.name, account.first_name, account.address, account.birthdate,
             account.latitude, account.longitude)
     return account, status.HTTP_201_CREATED