Daniel Holbach has proposed merging lp:~dholbach/loco-directory/579842 into
lp:loco-directory.
Requested reviews:
loco-directory-dev (loco-directory-dev)
Related bugs:
#570619 Categorise Teams into Continents
https://bugs.launchpad.net/bugs/570619
#579842 Add country list
https://bugs.launchpad.net/bugs/579842
--
https://code.launchpad.net/~dholbach/loco-directory/579842/+merge/26814
Your team loco-directory-dev is requested to review the proposed merge of
lp:~dholbach/loco-directory/579842 into lp:loco-directory.
=== modified file 'INSTALL'
--- INSTALL 2010-03-01 16:21:45 +0000
+++ INSTALL 2010-06-04 14:29:22 +0000
@@ -8,7 +8,7 @@
- sudo -u postgres createdb -O postgres loco_directory
Generally:
- - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south
+ - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south iso-codes
- cd loco_directory
- cp local_settings.py.sample local_settings.py
# edit local_settings.py and set DATABASE_USER, DATABASE_PASSWORD, SECRET_KEY
@@ -22,5 +22,5 @@
- ./manage.py syncdb
- ./manage.py migrate
- ./manage.py init-ld
- - ./manage.py lpupdate
+ - ./manage.py update
- ./manage.py runserver
=== modified file 'loco_directory/teams/admin.py'
--- loco_directory/teams/admin.py 2009-12-21 11:03:49 +0000
+++ loco_directory/teams/admin.py 2010-06-04 14:29:22 +0000
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.contrib import admin
-from teams.models import Team, TeamAdministrator
+from teams.models import Team, TeamAdministrator, Continent, Country
class TeamAdmin(admin.ModelAdmin):
search_fields = ('name',)
@@ -16,5 +16,14 @@
search_fields = ('lpid',)
list_display = ('lpid',)
+class ContinentAdmin(admin.ModelAdmin):
+ search_fields = ('name',)
+
+class CountryAdmin(admin.ModelAdmin):
+ search_fields = ('name',)
+
admin.site.register(Team, TeamAdmin)
admin.site.register(TeamAdministrator, TeamAdministratorAdmin)
+admin.site.register(Continent, ContinentAdmin)
+admin.site.register(Country, CountryAdmin)
+
=== added file 'loco_directory/teams/management/commands/update-countries.py'
--- loco_directory/teams/management/commands/update-countries.py 1970-01-01 00:00:00 +0000
+++ loco_directory/teams/management/commands/update-countries.py 2010-06-04 14:29:22 +0000
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+from django.core.management.base import NoArgsCommand
+
+from teams import models
+
+import xml.dom.minidom
+import os
+import sys
+
+class Command(NoArgsCommand):
+ help = "Update list of continents and countries."
+
+ def handle_noargs(self, **options):
+ for continent_name in ['North America', 'South America', 'Africa', \
+ 'Asia', 'Europe', 'Australia', 'Antarctica']:
+ continent, created = models.Continent.objects.get_or_create(name=continent_name)
+ if created:
+ continent.save()
+
+ country_list = "/usr/share/xml/iso-codes/iso_3166.xml"
+ if not os.path.exists(country_list):
+ print >> sys.stderr, "Please install the iso-codes package."
+ sys.exit(1)
+
+ doc = xml.dom.minidom.parse(country_list)
+ country_entries = doc.getElementsByTagName('iso_3166_entry')
+ for country_entry in country_entries:
+ if country_entry.getAttribute('name'):
+ country, created = models.Country.objects.get_or_create(name=country_entry.getAttribute('name'))
+ if created:
+ country.save()
=== added file 'loco_directory/teams/management/commands/update.py'
--- loco_directory/teams/management/commands/update.py 1970-01-01 00:00:00 +0000
+++ loco_directory/teams/management/commands/update.py 2010-06-04 14:29:22 +0000
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+
+from django.core.management.base import NoArgsCommand
+
+import subprocess
+import os
+
+from django.conf import settings
+
+class Command(NoArgsCommand):
+ help = "Update everything."
+
+ def handle_noargs(self, **options):
+ pwd = os.getcwd()
+ os.chdir(settings.PROJECT_PATH)
+ subprocess.call(["./manage.py", "update-countries"])
+ subprocess.call(["./manage.py", "lpupdate"])
+ os.chdir(pwd)
+
=== added file 'loco_directory/teams/migrations/0003_add_countries.py'
--- loco_directory/teams/migrations/0003_add_countries.py 1970-01-01 00:00:00 +0000
+++ loco_directory/teams/migrations/0003_add_countries.py 2010-06-04 14:29:22 +0000
@@ -0,0 +1,94 @@
+
+from south.db import db
+from django.db import models
+from teams.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Adding model 'Country'
+ db.create_table('teams_country', (
+ ('id', orm['teams.country:id']),
+ ('name', orm['teams.country:name']),
+ ))
+ db.send_create_signal('teams', ['Country'])
+
+ # Adding model 'Continent'
+ db.create_table('teams_continent', (
+ ('id', orm['teams.continent:id']),
+ ('name', orm['teams.continent:name']),
+ ))
+ db.send_create_signal('teams', ['Continent'])
+
+ # Adding ManyToManyField 'Country.continents'
+ db.create_table('teams_country_continents', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('country', models.ForeignKey(orm.Country, null=False)),
+ ('continent', models.ForeignKey(orm.Continent, null=False))
+ ))
+
+ # Adding ManyToManyField 'Team.countries'
+ db.create_table('teams_countries', (
+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
+ ('team', models.ForeignKey(orm.Team, null=False)),
+ ('country', models.ForeignKey(orm.Country, null=False))
+ ))
+
+
+
+ def backwards(self, orm):
+
+ # Deleting model 'Country'
+ db.delete_table('teams_country')
+
+ # Deleting model 'Continent'
+ db.delete_table('teams_continent')
+
+ # Dropping ManyToManyField 'Country.continents'
+ db.delete_table('teams_country_continents')
+
+ # Dropping ManyToManyField 'Team.countries'
+ db.delete_table('teams_countries')
+
+
+
+ models = {
+ 'teams.continent': {
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'})
+ },
+ 'teams.country': {
+ 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'})
+ },
+ 'teams.team': {
+ 'Meta': {'db_table': "'teams'"},
+ 'admins': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.TeamAdministrator']"}),
+ 'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+ 'approved_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'countries': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Country']"}),
+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
+ 'expires_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
+ 'forum_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'irc_chan': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True', 'blank': 'True'}),
+ 'lp_name': ('django.db.models.fields.SlugField', [], {'max_length': '40', 'null': 'True', 'db_index': 'True'}),
+ 'ml_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'mugshot_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True'}),
+ 'owner': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'null': 'True', 'db_index': 'True'}),
+ 'provides_support': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+ 'spr': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+ 'web_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'wiki_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ },
+ 'teams.teamadministrator': {
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'lpid': ('django.db.models.fields.SlugField', [], {'max_length': '40', 'db_index': 'True'})
+ }
+ }
+
+ complete_apps = ['teams']
=== modified file 'loco_directory/teams/models.py'
--- loco_directory/teams/models.py 2010-01-18 14:41:22 +0000
+++ loco_directory/teams/models.py 2010-06-04 14:29:22 +0000
@@ -9,10 +9,23 @@
def __unicode__(self):
return u'%s' % (self.lpid)
+class Continent(models.Model):
+ name = models.TextField(_("Name"), max_length=50)
+
+ def __unicode__(self):
+ return u'%s' % (self.name)
+
+class Country(models.Model):
+ name = models.TextField(_("Name"), max_length=100)
+ continents = models.ManyToManyField(Continent)
+
+ def __unicode__(self):
+ return u'%s' % (self.name)
+
class Team(models.Model):
lp_name = models.SlugField(_("Launchpad Team ID"), max_length=40, null=True)
name = models.CharField(_("Team Name"), max_length=80, null=True)
- country = models.CharField(_("Country"), max_length=50, null=True, blank=True)
+ countries = models.ManyToManyField(Country)
spr = models.CharField(_("State/Province/Region"), max_length=50, null=True, blank=True)
city = models.CharField(_("City"), max_length=50, null=True, blank=True)
wiki_url = models.URLField(_("Ubuntu Wiki Page"), verify_exists=False, null=True, blank=True)
=== modified file 'loco_directory/teams/views.py'
--- loco_directory/teams/views.py 2010-05-27 14:59:22 +0000
+++ loco_directory/teams/views.py 2010-06-04 14:29:22 +0000
@@ -49,7 +49,7 @@
if form.is_valid():
if form.cleaned_data['q']:
q = form.cleaned_data['q']
- team_list = team_list.filter(Q(name__icontains=q) | Q(country__icontains=q) | Q(city__icontains=q))
+ team_list = team_list.filter(Q(name__icontains=q) | Q(countries__name__icontains=q) | Q(city__icontains=q))
context = {
'team_list': team_list,
=== modified file 'loco_directory/templates/teams/team_detail.html'
--- loco_directory/templates/teams/team_detail.html 2010-05-27 14:59:22 +0000
+++ loco_directory/templates/teams/team_detail.html 2010-06-04 14:29:22 +0000
@@ -31,8 +31,12 @@
<tr>
<th scope="row"><label>{% trans "Location:" %}</label></th>
<td>
- {% if team.country %}
- {% trans team.country %}{% if team.spr %}, {% trans team.spr %}{% endif %}{% if team.city %}, {% trans team.city %}{% endif %}
+ {% if team.countries.all %}
+ {% for country in team.countries.all %}
+ {{ country.name }}
+ {% endfor %}
+ {% if team.spr %}, {% trans team.spr %}{% endif %}
+ {% if team.city %}, {% trans team.city %}{% endif %}
{% else %}
{% trans "None Specified" %}
{% endif %}
=== added file 'loco_directory/venues/migrations/0003_add_country.py'
--- loco_directory/venues/migrations/0003_add_country.py 1970-01-01 00:00:00 +0000
+++ loco_directory/venues/migrations/0003_add_country.py 2010-06-04 14:29:22 +0000
@@ -0,0 +1,47 @@
+
+from south.db import db
+from django.db import models
+from venues.models import *
+
+class Migration:
+
+ def forwards(self, orm):
+
+ # Adding field 'Venue.country'
+ db.add_column('venues_venue', 'country', orm['venues.venue:country'])
+
+
+
+ def backwards(self, orm):
+
+ # Deleting field 'Venue.country'
+ db.delete_column('venues_venue', 'country_id')
+
+
+
+ models = {
+ 'teams.continent': {
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'})
+ },
+ 'teams.country': {
+ 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']"}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'})
+ },
+ 'venues.venue': {
+ 'Meta': {'unique_together': "(('name', 'country', 'city'), ('longitude', 'latitude'))"},
+ 'address': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
+ 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+ 'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['teams.Country']", 'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+ 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
+ 'map_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
+ 'venue_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['venues']
=== modified file 'loco_directory/venues/models.py'
--- loco_directory/venues/models.py 2010-05-02 13:39:19 +0000
+++ loco_directory/venues/models.py 2010-06-04 14:29:22 +0000
@@ -2,7 +2,7 @@
from django.utils.translation import ugettext_lazy as _
from django.db.models import permalink
-# Create your models here.
+from teams.models import Country
class VenueManager(models.Manager):
"""
@@ -15,7 +15,7 @@
a venue
"""
name = models.CharField(help_text=_('Name of the Venue'), max_length=150)
- country = models.CharField(help_text=_('Country Name'), max_length=150, null=True, blank=True)
+ country = models.ForeignKey(Country, null=True)
city = models.CharField(help_text=_('City Name'), max_length=150, null=True, blank=True)
address = models.CharField(help_text=_('Address with Street and Number'), max_length=150, null=True, blank=True)
longitude = models.FloatField(help_text=_('Longitude in Degrees East'), null=True, blank=True)
_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help : https://help.launchpad.net/ListHelp