示例#1
0
    def post(self):

        item = request.get_json() if request.get_json() else request.form

        try:
            model = EmergencyPetModel()
            model.call = item["call"]
            model.call_type = item["call_type"]
            model.latitude = item["lat"]
            model.longitude = item["log"]
            model.status = item["status"]
            model.proposal_id = item["proposal_id"]
            model.created_date = date.today()

            model.save()
            return 201, "created"
        except Exception as e:
            return 500, f"nao criado {e}"
示例#2
0
def insert_into_emergency_pet(item):
    try:
        if item:
            model = EmergencyPetModel()
            model.call = item['call']
            model.call_type = item['call_type']
            model.label = item['label']
            model.status = item['status']
            model.longitude = item['log']
            model.latitude = item['lat']
            model.collab_id = item['collab_id']
            model.provider_id = item['provider_id']
            model.proposal_id = item['proposal_id']

            model.save()

            return 'created', 201
        else:
            return 'not created, invalid payload', 400
    except Exception as e:
        return f"{e}", 500