def insert_new_area(): data = request.json roles = [ 'area_code', 'area_name', 'area_size', 'longitude', 'latitude', 'city' ] if not validate(roles, data): abort(422) code = data['area_code'] name = data['area_name'] size = data['area_size'] longitude = data['longitude'] latitude = data['latitude'] city = data['city'] area = Area(code=code, name=name, size=size, longitude=longitude, latitude=latitude, city=city) area.save(True) return jsonify({"success": True, "area": area.format()})
def create_areas(): # get the access token name = request.data.get('name', '') geodata = request.data.get('geodata', '') center_lat = request.data.get('center_lat') center_lng = request.data.get('center_lng') zoom = request.data.get('zoom') area = Area(name=name, geodata=geodata, center_lat=center_lat, center_lng=center_lng, zoom=zoom) area.save() response = jsonify({ 'id': area.id, 'name': area.name, 'geodata': area.geodata, 'center_lat' : area.center_lat, 'center_lng' : area.center_lng, 'zoom' : area.zoom, 'date_created': area.date_created, 'date_modified': area.date_modified }) return make_response(response), 201