Merge lp:~dholbach/loco-team-portal/579842 into lp:loco-team-portal

Proposed by Daniel Holbach
Status: Merged
Merged at revision: 149
Proposed branch: lp:~dholbach/loco-team-portal/579842
Merge into: lp:loco-team-portal
Diff against target: 342 lines (+227/-9)
10 files modified
INSTALL (+2/-2)
loco_directory/teams/admin.py (+10/-1)
loco_directory/teams/management/commands/update-countries.py (+32/-0)
loco_directory/teams/management/commands/update.py (+19/-0)
loco_directory/teams/migrations/0003_add_countries.py (+94/-0)
loco_directory/teams/models.py (+14/-1)
loco_directory/teams/views.py (+1/-1)
loco_directory/templates/teams/team_detail.html (+6/-2)
loco_directory/venues/migrations/0003_add_country.py (+47/-0)
loco_directory/venues/models.py (+2/-2)
To merge this branch: bzr merge lp:~dholbach/loco-team-portal/579842
Reviewer Review Type Date Requested Status
Thomas Bechtold (community) Approve
Review via email: mp+26814@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomas Bechtold (toabctl) wrote :

looks good and works for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'INSTALL'
2--- INSTALL 2010-03-01 16:21:45 +0000
3+++ INSTALL 2010-06-04 14:29:22 +0000
4@@ -8,7 +8,7 @@
5 - sudo -u postgres createdb -O postgres loco_directory
6
7 Generally:
8- - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south
9+ - sudo apt-get install python-django python-launchpadlib libjs-jquery-ui python-django-openid-auth python-django-south iso-codes
10 - cd loco_directory
11 - cp local_settings.py.sample local_settings.py
12 # edit local_settings.py and set DATABASE_USER, DATABASE_PASSWORD, SECRET_KEY
13@@ -22,5 +22,5 @@
14 - ./manage.py syncdb
15 - ./manage.py migrate
16 - ./manage.py init-ld
17- - ./manage.py lpupdate
18+ - ./manage.py update
19 - ./manage.py runserver
20
21=== modified file 'loco_directory/teams/admin.py'
22--- loco_directory/teams/admin.py 2009-12-21 11:03:49 +0000
23+++ loco_directory/teams/admin.py 2010-06-04 14:29:22 +0000
24@@ -1,7 +1,7 @@
25 # -*- coding: utf-8 -*-
26
27 from django.contrib import admin
28-from teams.models import Team, TeamAdministrator
29+from teams.models import Team, TeamAdministrator, Continent, Country
30
31 class TeamAdmin(admin.ModelAdmin):
32 search_fields = ('name',)
33@@ -16,5 +16,14 @@
34 search_fields = ('lpid',)
35 list_display = ('lpid',)
36
37+class ContinentAdmin(admin.ModelAdmin):
38+ search_fields = ('name',)
39+
40+class CountryAdmin(admin.ModelAdmin):
41+ search_fields = ('name',)
42+
43 admin.site.register(Team, TeamAdmin)
44 admin.site.register(TeamAdministrator, TeamAdministratorAdmin)
45+admin.site.register(Continent, ContinentAdmin)
46+admin.site.register(Country, CountryAdmin)
47+
48
49=== added file 'loco_directory/teams/management/commands/update-countries.py'
50--- loco_directory/teams/management/commands/update-countries.py 1970-01-01 00:00:00 +0000
51+++ loco_directory/teams/management/commands/update-countries.py 2010-06-04 14:29:22 +0000
52@@ -0,0 +1,32 @@
53+#!/usr/bin/python
54+
55+from django.core.management.base import NoArgsCommand
56+
57+from teams import models
58+
59+import xml.dom.minidom
60+import os
61+import sys
62+
63+class Command(NoArgsCommand):
64+ help = "Update list of continents and countries."
65+
66+ def handle_noargs(self, **options):
67+ for continent_name in ['North America', 'South America', 'Africa', \
68+ 'Asia', 'Europe', 'Australia', 'Antarctica']:
69+ continent, created = models.Continent.objects.get_or_create(name=continent_name)
70+ if created:
71+ continent.save()
72+
73+ country_list = "/usr/share/xml/iso-codes/iso_3166.xml"
74+ if not os.path.exists(country_list):
75+ print >> sys.stderr, "Please install the iso-codes package."
76+ sys.exit(1)
77+
78+ doc = xml.dom.minidom.parse(country_list)
79+ country_entries = doc.getElementsByTagName('iso_3166_entry')
80+ for country_entry in country_entries:
81+ if country_entry.getAttribute('name'):
82+ country, created = models.Country.objects.get_or_create(name=country_entry.getAttribute('name'))
83+ if created:
84+ country.save()
85
86=== added file 'loco_directory/teams/management/commands/update.py'
87--- loco_directory/teams/management/commands/update.py 1970-01-01 00:00:00 +0000
88+++ loco_directory/teams/management/commands/update.py 2010-06-04 14:29:22 +0000
89@@ -0,0 +1,19 @@
90+#!/usr/bin/python
91+
92+from django.core.management.base import NoArgsCommand
93+
94+import subprocess
95+import os
96+
97+from django.conf import settings
98+
99+class Command(NoArgsCommand):
100+ help = "Update everything."
101+
102+ def handle_noargs(self, **options):
103+ pwd = os.getcwd()
104+ os.chdir(settings.PROJECT_PATH)
105+ subprocess.call(["./manage.py", "update-countries"])
106+ subprocess.call(["./manage.py", "lpupdate"])
107+ os.chdir(pwd)
108+
109
110=== added file 'loco_directory/teams/migrations/0003_add_countries.py'
111--- loco_directory/teams/migrations/0003_add_countries.py 1970-01-01 00:00:00 +0000
112+++ loco_directory/teams/migrations/0003_add_countries.py 2010-06-04 14:29:22 +0000
113@@ -0,0 +1,94 @@
114+
115+from south.db import db
116+from django.db import models
117+from teams.models import *
118+
119+class Migration:
120+
121+ def forwards(self, orm):
122+
123+ # Adding model 'Country'
124+ db.create_table('teams_country', (
125+ ('id', orm['teams.country:id']),
126+ ('name', orm['teams.country:name']),
127+ ))
128+ db.send_create_signal('teams', ['Country'])
129+
130+ # Adding model 'Continent'
131+ db.create_table('teams_continent', (
132+ ('id', orm['teams.continent:id']),
133+ ('name', orm['teams.continent:name']),
134+ ))
135+ db.send_create_signal('teams', ['Continent'])
136+
137+ # Adding ManyToManyField 'Country.continents'
138+ db.create_table('teams_country_continents', (
139+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
140+ ('country', models.ForeignKey(orm.Country, null=False)),
141+ ('continent', models.ForeignKey(orm.Continent, null=False))
142+ ))
143+
144+ # Adding ManyToManyField 'Team.countries'
145+ db.create_table('teams_countries', (
146+ ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
147+ ('team', models.ForeignKey(orm.Team, null=False)),
148+ ('country', models.ForeignKey(orm.Country, null=False))
149+ ))
150+
151+
152+
153+ def backwards(self, orm):
154+
155+ # Deleting model 'Country'
156+ db.delete_table('teams_country')
157+
158+ # Deleting model 'Continent'
159+ db.delete_table('teams_continent')
160+
161+ # Dropping ManyToManyField 'Country.continents'
162+ db.delete_table('teams_country_continents')
163+
164+ # Dropping ManyToManyField 'Team.countries'
165+ db.delete_table('teams_countries')
166+
167+
168+
169+ models = {
170+ 'teams.continent': {
171+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
172+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'})
173+ },
174+ 'teams.country': {
175+ 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']"}),
176+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
177+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'})
178+ },
179+ 'teams.team': {
180+ 'Meta': {'db_table': "'teams'"},
181+ 'admins': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.TeamAdministrator']"}),
182+ 'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
183+ 'approved_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
184+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
185+ 'countries': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Country']"}),
186+ 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}),
187+ 'expires_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}),
188+ 'forum_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
189+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
190+ 'irc_chan': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True', 'blank': 'True'}),
191+ 'lp_name': ('django.db.models.fields.SlugField', [], {'max_length': '40', 'null': 'True', 'db_index': 'True'}),
192+ 'ml_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
193+ 'mugshot_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
194+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'null': 'True'}),
195+ 'owner': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'null': 'True', 'db_index': 'True'}),
196+ 'provides_support': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
197+ 'spr': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
198+ 'web_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
199+ 'wiki_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
200+ },
201+ 'teams.teamadministrator': {
202+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
203+ 'lpid': ('django.db.models.fields.SlugField', [], {'max_length': '40', 'db_index': 'True'})
204+ }
205+ }
206+
207+ complete_apps = ['teams']
208
209=== modified file 'loco_directory/teams/models.py'
210--- loco_directory/teams/models.py 2010-01-18 14:41:22 +0000
211+++ loco_directory/teams/models.py 2010-06-04 14:29:22 +0000
212@@ -9,10 +9,23 @@
213 def __unicode__(self):
214 return u'%s' % (self.lpid)
215
216+class Continent(models.Model):
217+ name = models.TextField(_("Name"), max_length=50)
218+
219+ def __unicode__(self):
220+ return u'%s' % (self.name)
221+
222+class Country(models.Model):
223+ name = models.TextField(_("Name"), max_length=100)
224+ continents = models.ManyToManyField(Continent)
225+
226+ def __unicode__(self):
227+ return u'%s' % (self.name)
228+
229 class Team(models.Model):
230 lp_name = models.SlugField(_("Launchpad Team ID"), max_length=40, null=True)
231 name = models.CharField(_("Team Name"), max_length=80, null=True)
232- country = models.CharField(_("Country"), max_length=50, null=True, blank=True)
233+ countries = models.ManyToManyField(Country)
234 spr = models.CharField(_("State/Province/Region"), max_length=50, null=True, blank=True)
235 city = models.CharField(_("City"), max_length=50, null=True, blank=True)
236 wiki_url = models.URLField(_("Ubuntu Wiki Page"), verify_exists=False, null=True, blank=True)
237
238=== modified file 'loco_directory/teams/views.py'
239--- loco_directory/teams/views.py 2010-05-27 14:59:22 +0000
240+++ loco_directory/teams/views.py 2010-06-04 14:29:22 +0000
241@@ -49,7 +49,7 @@
242 if form.is_valid():
243 if form.cleaned_data['q']:
244 q = form.cleaned_data['q']
245- team_list = team_list.filter(Q(name__icontains=q) | Q(country__icontains=q) | Q(city__icontains=q))
246+ team_list = team_list.filter(Q(name__icontains=q) | Q(countries__name__icontains=q) | Q(city__icontains=q))
247
248 context = {
249 'team_list': team_list,
250
251=== modified file 'loco_directory/templates/teams/team_detail.html'
252--- loco_directory/templates/teams/team_detail.html 2010-05-27 14:59:22 +0000
253+++ loco_directory/templates/teams/team_detail.html 2010-06-04 14:29:22 +0000
254@@ -31,8 +31,12 @@
255 <tr>
256 <th scope="row"><label>{% trans "Location:" %}</label></th>
257 <td>
258- {% if team.country %}
259- {% trans team.country %}{% if team.spr %}, {% trans team.spr %}{% endif %}{% if team.city %}, {% trans team.city %}{% endif %}
260+ {% if team.countries.all %}
261+ {% for country in team.countries.all %}
262+ {{ country.name }}&nbsp;
263+ {% endfor %}
264+ {% if team.spr %}, {% trans team.spr %}{% endif %}
265+ {% if team.city %}, {% trans team.city %}{% endif %}
266 {% else %}
267 {% trans "None Specified" %}
268 {% endif %}
269
270=== added file 'loco_directory/venues/migrations/0003_add_country.py'
271--- loco_directory/venues/migrations/0003_add_country.py 1970-01-01 00:00:00 +0000
272+++ loco_directory/venues/migrations/0003_add_country.py 2010-06-04 14:29:22 +0000
273@@ -0,0 +1,47 @@
274+
275+from south.db import db
276+from django.db import models
277+from venues.models import *
278+
279+class Migration:
280+
281+ def forwards(self, orm):
282+
283+ # Adding field 'Venue.country'
284+ db.add_column('venues_venue', 'country', orm['venues.venue:country'])
285+
286+
287+
288+ def backwards(self, orm):
289+
290+ # Deleting field 'Venue.country'
291+ db.delete_column('venues_venue', 'country_id')
292+
293+
294+
295+ models = {
296+ 'teams.continent': {
297+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
298+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '50'})
299+ },
300+ 'teams.country': {
301+ 'continents': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['teams.Continent']"}),
302+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
303+ 'name': ('django.db.models.fields.TextField', [], {'max_length': '100'})
304+ },
305+ 'venues.venue': {
306+ 'Meta': {'unique_together': "(('name', 'country', 'city'), ('longitude', 'latitude'))"},
307+ 'address': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
308+ 'city': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}),
309+ 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
310+ 'country': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['teams.Country']", 'null': 'True'}),
311+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
312+ 'latitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
313+ 'longitude': ('django.db.models.fields.FloatField', [], {'null': 'True', 'blank': 'True'}),
314+ 'map_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
315+ 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
316+ 'venue_url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'})
317+ }
318+ }
319+
320+ complete_apps = ['venues']
321
322=== modified file 'loco_directory/venues/models.py'
323--- loco_directory/venues/models.py 2010-05-02 13:39:19 +0000
324+++ loco_directory/venues/models.py 2010-06-04 14:29:22 +0000
325@@ -2,7 +2,7 @@
326 from django.utils.translation import ugettext_lazy as _
327 from django.db.models import permalink
328
329-# Create your models here.
330+from teams.models import Country
331
332 class VenueManager(models.Manager):
333 """
334@@ -15,7 +15,7 @@
335 a venue
336 """
337 name = models.CharField(help_text=_('Name of the Venue'), max_length=150)
338- country = models.CharField(help_text=_('Country Name'), max_length=150, null=True, blank=True)
339+ country = models.ForeignKey(Country, null=True)
340 city = models.CharField(help_text=_('City Name'), max_length=150, null=True, blank=True)
341 address = models.CharField(help_text=_('Address with Street and Number'), max_length=150, null=True, blank=True)
342 longitude = models.FloatField(help_text=_('Longitude in Degrees East'), null=True, blank=True)

Subscribers

People subscribed via source and target branches