Exemplo n.º 1
0
def process_site(row):
    name = fc.clean_name(row['NAME'])
    agency = abbreviate_agency(fc.clean_agency(row['AGENCY']))

    field_trip_site, created = FieldTripSite.objects.get_or_create(
        name=name, agency=agency)

    field_trip_site.phone = fc.clean_phone(row['PHONE_1'])
    field_trip_site.city = fc.clean_text(row['City'])
    field_trip_site.state = fc.clean_state(row['Region'])
    field_trip_site.website = fc.clean_website(row['WEBSITE'])
    field_trip_site.address_line_1 = fc.clean_text(row['StAddr'])
    field_trip_site.advance_reservation = fc.clean_advance_reservation(
        row['ADV_RES_RE'])

    field_trip_site.larger_groups = fc.clean_thirty_five_or_more(
        row['THRIRTYFIV'])
    field_trip_site.zipcode = fc.clean_postal_code(row['PostalCode'])
    field_trip_site.save()

    # Clear the deck.
    field_trip_site.best_visit_times.remove()
    field_trip_site.facilities.remove()

    youth_facilities = fc.clean_youth_facilities(row['YOUTH_FACI'])
    yfacilities = create_youth_facilities(youth_facilities)
    field_trip_site.facilities.add(*yfacilities)

    best_times_data = fc.clean_best_times(row['BEST_TIMES'])
    if best_times_data:
        best_times = create_best_times(best_times_data)
        field_trip_site.best_visit_times.add(*best_times)

    field_trip_site.save()
Exemplo n.º 2
0
def process_site(row):
    """ Clean up the data, and save a FieldTrip object. """
    name = fc.clean_name(row['NAME'])
    agency = abbreviate_agency(fc.clean_agency(row['AGENCY']))

    field_trip_site, created = FieldTripSite.objects.get_or_create(
        name=name, agency=agency)

    field_trip_site.phone = fc.clean_phone(row['PHONE'])
    field_trip_site.city = fc.clean_text(row['CITY'])
    field_trip_site.state = fc.clean_state(row['STATE'])
    field_trip_site.address_line_1 = fc.clean_text(row['ADDRESS'])
    field_trip_site.zipcode = fc.clean_postal_code(row['ZIPCODE'])
    field_trip_site.website = fc.clean_website(row['WEBSITE'])
    field_trip_site.advance_reservation = fc.clean_advance_reservation(
        row['ADVANCE_RESERVATION'])
        
    field_trip_site.larger_groups = fc.clean_thirty_five_or_more(
        row['THIRTY_FIVE'])
    field_trip_site.save()

    # Clear old data for this facility
    field_trip_site.facilities.remove()

    youth_facilities = fc.clean_youth_facilities(row['YOUTH_FACILITIES'])
    yfacilities = create_youth_facilities(youth_facilities)
    field_trip_site.facilities.add(*yfacilities)

	# Clear old data for this facility
    field_trip_site.best_visit_times.remove()
    
    best_times_data = fc.clean_best_times(row['BEST_TIMES'])
    if best_times_data:
        best_times = create_best_times(best_times_data)
        field_trip_site.best_visit_times.add(*best_times)

    field_trip_site.save()