Exemplo n.º 1
0
def create(event, context):

    data = json.loads(event['body'])

    if not validate_location_json(data):
        raise Exception('Invalid content provided.')

    try:
        location = LocationModel(name=data['name'],
                                 street_1=data['street_1'],
                                 street_2=data.get('street_2', None),
                                 city=data['city'],
                                 state=data['state'],
                                 zip_code=data['zip_code'],
                                 country=data['country'],
                                 type_id=data['type_id'])

        location.save()

        response = {'statusCode': 200, 'body': json.dumps(dict(location))}
    except Exception as ex:
        response = {
            'statusCode': 500,
            'body': json.dumps({'errorMessage': 'There was a problem saving'})
        }

    return response
Exemplo n.º 2
0
def create_location():
    if request.method == "POST":
        name = request.form["name"]
        new_location = LocationModel(name=name)
        new_location.save()

    else:
        return render_template("add-location.html")
        
    pass
Exemplo n.º 3
0
def _add_locations(lines_as_ordered_dicts, case):
    return {
        location: LocationModel(
            facies_name=location.facies,
            zone_name=location.zone,
            region_name=location.region,
            license=location.license,
            case=case,
        )
        for location in _get_unique_locations(lines_as_ordered_dicts)
    }