# HG changeset patch # User Brian Neal # Date 1242261099 0 # Node ID e602b5302b94e8f8761832c4d8e91b4c4cfdb169 # Parent 432f7467543a8511c01ce2c3b9b28f48385b56e0 Added support for countries beside the USA. diff -r 432f7467543a -r e602b5302b94 mysite/band/admin.py --- a/mysite/band/admin.py Sun Apr 19 18:36:56 2009 +0000 +++ b/mysite/band/admin.py Thu May 14 00:31:39 2009 +0000 @@ -12,6 +12,7 @@ from mysite.band.models import Album_Track from mysite.band.models import Band from mysite.band.models import City +from mysite.band.models import Country from mysite.band.models import Fan from mysite.band.models import Gear from mysite.band.models import Gig @@ -70,7 +71,7 @@ model = City class CityAdmin(admin.ModelAdmin): - list_display = ('name', 'state') + list_display = ('name', 'state', 'country') list_filter = ('state', ) search_fields = ('name', ) @@ -78,6 +79,10 @@ ####################################################################### +admin.site.register(Country) + +####################################################################### + class StateAdmin(admin.ModelAdmin): inlines = [ CityInline, diff -r 432f7467543a -r e602b5302b94 mysite/band/models.py --- a/mysite/band/models.py Sun Apr 19 18:36:56 2009 +0000 +++ b/mysite/band/models.py Thu May 14 00:31:39 2009 +0000 @@ -60,6 +60,18 @@ ####################################################################### +class Country(models.Model): + name = models.CharField(max_length=64) + + class Meta: + ordering = ('name', ) + verbose_name_plural = 'Countries' + + def __unicode__(self): + return self.name + +####################################################################### + class State(models.Model): name = models.CharField(max_length = 16) abbrev = USStateField() @@ -75,6 +87,7 @@ class City(models.Model): name = models.CharField(max_length = 50) state = models.ForeignKey(State, null = True, blank = True) + country = models.ForeignKey(Country, null=True, blank=True) class Meta: verbose_name_plural = 'Cities' diff -r 432f7467543a -r e602b5302b94 mysite/band/views.py --- a/mysite/band/views.py Sun Apr 19 18:36:56 2009 +0000 +++ b/mysite/band/views.py Thu May 14 00:31:39 2009 +0000 @@ -77,6 +77,7 @@ venues = set([]) cities = set([]) states = set([]) + countries = set([]) bands = set([]) for gig in previous: if gig.venue.id not in venues: @@ -85,6 +86,8 @@ cities.add(gig.venue.city.id) if gig.venue.city.state and gig.venue.city.state.id not in states: states.add(gig.venue.city.state.id) + if gig.venue.city.country and gig.venue.city.country.id not in countries: + countries.add(gig.venue.city.country.id) for band in gig.bands.all(): if band.id not in bands: bands.add(band.id) @@ -93,6 +96,7 @@ stats['venues'] = len(venues) stats['cities'] = len(cities) stats['states'] = len(states) + stats['countries'] = len(countries) stats['bands'] = len(bands) flyerGigs = Gig.objects.exclude(flyer__isnull = True).order_by('-date') diff -r 432f7467543a -r e602b5302b94 mysite/templates/band/gigs.html --- a/mysite/templates/band/gigs.html Sun Apr 19 18:36:56 2009 +0000 +++ b/mysite/templates/band/gigs.html Thu May 14 00:31:39 2009 +0000 @@ -44,6 +44,9 @@ {% else %} {{ show.venue.city.name }} {% endif %} + {% ifnotequal show.venue.city.country.name "USA" %} + {{ show.venue.city.country.name }} + {% endifnotequal %}
{% if show.venue.phone %} {{ show.venue.phone }} @@ -119,6 +122,9 @@ {{ show.venue.name }}, {% endif %} {{ show.venue.city.name }}, {{ show.venue.city.state.abbrev }} + {% ifnotequal show.venue.city.country.name "USA" %} + {{ show.venue.city.country.name }} + {% endifnotequal %} {% for band in show.bands.all %} @@ -145,6 +151,7 @@ Number of unique venues:{{ stats.venues }} Number of unique cities:{{ stats.cities }} Number of unique states:{{ stats.states }} + Number of unique countries:{{ stats.countries }} Number of unique bands:{{ stats.bands }} {% endif %}