Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.

Commit

Permalink
Removed 2-3 obvious duplicates from pass-list dataset. Also modified …
Browse files Browse the repository at this point in the history
…FederalSite model to auto-set a slug on creation
  • Loading branch information
Colin Craig committed Jun 24, 2016
1 parent 8d5c0f1 commit 8f9d195
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
4 changes: 1 addition & 3 deletions ekip/nationalparks/data/pass-list-20160603.csv
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Kisatchie NF - Winn District,318-628-4664,Winnfield,LA,http://www.fs.fed.us/r8/k
Adams National Historical Park,617-770-1175,Quincy,MA,http://www.nps.gov/adam,YES,YES
Assabet River NWR,978-562-3527,Sudbury,MA,http://www.fws.gov/refuge/assabet_river/,YES,YES
Boston National Historical Park,617-242-5642,Boston,MA,http://www.nps.gov/bost,NO,YES
Buffumville Lake,"508-248-5697
Buffumville Lake,"508-248-5697
",Charlton,MA,http://www.nae.usace.army.mil/Missions/Recreation/BuffumvilleLake.aspx,YES,YES
Cape Cod National Seashore - Provincelands V.C.,508-487-1256,Provincetown,MA,http://www.nps.gov/caco,YES,YES
Cape Cod National Seashore - Salt Pond V.C.,508-255-3421,Eastham,MA,http://www.nps.gov/caco,YES,YES
Expand Down Expand Up @@ -922,7 +922,6 @@ Deschutes NF - Redmond Air Center,541-504-7200,Redmond,OR,http://www.fs.fed.us/r
Deschutes NF - Sisters District,541-549-7700,Sisters,OR,http://www.fs.fed.us/r6/centraloregon/contact/,YES,YES
Dorena Lake - Schwarz Park (Campground),541-942-5631,Cottage Grove,OR,http://corpslakes.usace.army.mil/visitors/projects.cfm?Id=G204910,YES,YES
Eugene District BLM Office,541-683-6600,Eugene,OR,http://www.blm.gov/or/districts/eugene/index.php,YES,YES
Fort Vancouver National Historic Site,360-816-6230,Vancouver ,OR,http://www.nps.gov/fova/,YES,YES
Fremont-Winema NF - Main Office,541-947-2151,Lakeview,OR,http://www.fs.fed.us/r6/frewin/contact/,YES,YES
John Day Lock and Dam - LePage Park,541-506-4807,Rufus,OR,http://www.nwp.usace.army.mil/Locations/ColumbiaRiver/JohnDay.aspx,YES,YES
Klamath Falls Resource Area,541-883-6916,Klamath Falls,OR,http://www.blm.gov/or/districts/lakeview/index.php,YES,YES
Expand Down Expand Up @@ -1075,7 +1074,6 @@ Hords Creek,325-625-2322,Coleman,TX,http://www.swf-wc.usace.army.mil/hords/,YES,
Laguna Atascosa NWR,956-748-3607,Rio Hondo,TX,http://www.fws.gov/southwest/refuges/texas/laguna.html,YES,YES
Lake Meredith National Recreation Area,806-857-3151,Fritch,TX,http://www.nps.gov/lamr/,YES,YES
Lake Oí the Pines Lake,903-665-2336,Jefferson,TX,http://www.swf-wc.usace.army.mil/lakeopines/,YES,YES
Lake Texoma ( both OK and TX),903-465-4990,Denison,TX,http://www.swt.usace.army.mil/Locations/TulsaDistrictLakes/Oklahoma/LakeTexoma.aspx,YES,YES
Lavon Lake,972-442-3141,Wylie,TX,http://www.swf-wc.usace.army.mil/lavon/,YES,YES
Lewisville Lake,469-645-9100,Lewisville,TX,http://www.swf-wc.usace.army.mil/lewisville/,YES,YES
Navarro Mills,254-578-1431,Purdon,TX,http://www.swf-wc.usace.army.mil/navarro/,YES,YES
Expand Down
20 changes: 20 additions & 0 deletions ekip/nationalparks/migrations/0011_auto_20160624_1959.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-24 19:59
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('nationalparks', '0010_auto_20150902_1902'),
]

operations = [
migrations.AlterField(
model_name='federalsite',
name='slug',
field=models.SlugField(max_length=80, null=True, unique=True),
),
]
12 changes: 11 additions & 1 deletion ekip/nationalparks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FederalSite(models.Model):
city = models.CharField(max_length=128)
state = USStateField(blank=False, null=False, db_index=True)
website = models.URLField(max_length=512)
slug = models.SlugField(unique=True, null=True)
slug = models.SlugField(unique=True, null=True, max_length=80)
annual_pass = models.BooleanField(
default=False, help_text="True if the site offers an annual pass")
senior_pass = models.BooleanField(
Expand All @@ -115,6 +115,16 @@ class FederalSite(models.Model):
def kids_pass(self):
return (self.annual_pass and self.active_participant)

def save(self, *args, **kwargs):
""" Generate and save a slug when this object is saved for the first
time. """

if not self.id:
name = self.name
name = name.replace('National Wildlife Refuge', 'NWR')
self.slug = slugify(name + self.city)[:80]
super(FederalSite, self).save(*args, **kwargs)

def __str__(self):
return "%s (%s, %s)" % (self.name, self.city, self.state)

Expand Down
2 changes: 1 addition & 1 deletion ekip/redemption/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def redeem_confirm(request, slug):
def redeem_for_site(request, slug):
""" Display and process a form that allows a user to enter multiple voucher
ids for a single recreation site. """

federal_site = get_object_or_404(FederalSite, slug=slug)
VoucherEntryFormSet = formset_factory(VoucherEntryForm, extra=10)

Expand Down

0 comments on commit 8f9d195

Please sign in to comment.