Exemplo n.º 1
0
 def get(self):
     args = parser.parse_args()
     distance = args.get('distance')
     location = args.get('location')
     filter_kwargs = {}
     if distance is not None and location is not None:
         filter_kwargs = {
             'location__near': [location['lon'], location['lat']],
             'location__max_distance': distance * METERS_PER_MILE
         }
     records = Business.objects(**filter_kwargs)
     return list(records)
Exemplo n.º 2
0
 def delete(self, _id):
     get_record_by_id(_id)
     Business.objects(_id=_id).delete()
     return '', 204
Exemplo n.º 3
0
def get_record_by_id(_id):
    record = Business.objects(_id=_id)
    if not record:
        abort(404, message="Business with id {} doesn't exist".format(_id))
    return record[0]