Merge lp:~daker/loco-team-portal/pep8-fixes into lp:loco-team-portal
- pep8-fixes
- Merge into 0.2
Proposed by
Adnane Belmadiaf
Status: | Merged |
---|---|
Approved by: | Adnane Belmadiaf |
Approved revision: | 588 |
Merged at revision: | 588 |
Proposed branch: | lp:~daker/loco-team-portal/pep8-fixes |
Merge into: | lp:loco-team-portal |
Diff against target: |
563 lines (+76/-57) 17 files modified
loco_directory/articles/admin.py (+1/-0) loco_directory/articles/management/commands/refresh.py (+3/-4) loco_directory/articles/models.py (+4/-5) loco_directory/articles/tests.py (+1/-0) loco_directory/articles/views.py (+1/-1) loco_directory/events/admin.py (+1/-1) loco_directory/meetings/admin.py (+1/-1) loco_directory/teams/admin.py (+6/-2) loco_directory/teams/feeds.py (+1/-4) loco_directory/teams/forms.py (+4/-5) loco_directory/teams/models.py (+9/-1) loco_directory/teams/tests.py (+9/-10) loco_directory/teams/utils.py (+1/-1) loco_directory/teams/views.py (+27/-17) loco_directory/userprofiles/admin.py (+2/-0) loco_directory/userprofiles/management/commands/update-profiles.py (+2/-3) loco_directory/userprofiles/tests.py (+3/-2) |
To merge this branch: | bzr merge lp:~daker/loco-team-portal/pep8-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
LoCo Team Portal Developers | Pending | ||
Review via email:
|
Commit message
PEP8 fixes
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'loco_directory/articles/admin.py' | |||
2 | --- loco_directory/articles/admin.py 2012-06-01 22:28:09 +0000 | |||
3 | +++ loco_directory/articles/admin.py 2012-12-25 22:04:21 +0000 | |||
4 | @@ -1,3 +1,4 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | ||
6 | 1 | from articles.models import Feed, Article | 2 | from articles.models import Feed, Article |
7 | 2 | from django.contrib import admin | 3 | from django.contrib import admin |
8 | 3 | 4 | ||
9 | 4 | 5 | ||
10 | === modified file 'loco_directory/articles/management/commands/refresh.py' | |||
11 | --- loco_directory/articles/management/commands/refresh.py 2012-12-12 22:46:30 +0000 | |||
12 | +++ loco_directory/articles/management/commands/refresh.py 2012-12-25 22:04:21 +0000 | |||
13 | @@ -1,14 +1,13 @@ | |||
14 | 1 | # -*- coding: utf-8 -*- | ||
15 | 1 | ''' | 2 | ''' |
16 | 2 | Updates all Feeds | 3 | Updates all Feeds |
17 | 3 | ''' | 4 | ''' |
18 | 5 | from django.core.management.base import NoArgsCommand | ||
19 | 4 | 6 | ||
20 | 7 | from articles.models import Feed | ||
21 | 5 | import os | 8 | import os |
22 | 6 | import datetime | 9 | import datetime |
23 | 7 | 10 | ||
24 | 8 | from django.core.management.base import NoArgsCommand | ||
25 | 9 | |||
26 | 10 | from articles.models import Feed | ||
27 | 11 | |||
28 | 12 | REFRESH_LOCK = '/var/lock/loco-directory/refresh' | 11 | REFRESH_LOCK = '/var/lock/loco-directory/refresh' |
29 | 13 | 12 | ||
30 | 14 | 13 | ||
31 | 15 | 14 | ||
32 | === modified file 'loco_directory/articles/models.py' | |||
33 | --- loco_directory/articles/models.py 2012-12-13 22:48:12 +0000 | |||
34 | +++ loco_directory/articles/models.py 2012-12-25 22:04:21 +0000 | |||
35 | @@ -1,15 +1,14 @@ | |||
36 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
37 | 2 | from django.db import models | ||
38 | 3 | from django.conf import settings | ||
39 | 4 | from django.template.defaultfilters import slugify | ||
40 | 5 | |||
41 | 2 | import feedparser | 6 | import feedparser |
42 | 3 | import time | 7 | import time |
43 | 4 | import datetime | 8 | import datetime |
44 | 5 | import socket | 9 | import socket |
45 | 6 | import urllib2 | 10 | import urllib2 |
46 | 7 | 11 | ||
47 | 8 | from django.db import models | ||
48 | 9 | from django.conf import settings | ||
49 | 10 | from django.template.defaultfilters import slugify | ||
50 | 11 | |||
51 | 12 | |||
52 | 13 | from teams.models import Team | 12 | from teams.models import Team |
53 | 14 | from userprofiles.models import UserProfile | 13 | from userprofiles.models import UserProfile |
54 | 15 | 14 | ||
55 | 16 | 15 | ||
56 | === modified file 'loco_directory/articles/tests.py' | |||
57 | --- loco_directory/articles/tests.py 2012-12-11 00:00:46 +0000 | |||
58 | +++ loco_directory/articles/tests.py 2012-12-25 22:04:21 +0000 | |||
59 | @@ -1,3 +1,4 @@ | |||
60 | 1 | # -*- coding: utf-8 -*- | ||
61 | 1 | from django.test import TestCase | 2 | from django.test import TestCase |
62 | 2 | 3 | ||
63 | 3 | from articles.models import Feed, Article | 4 | from articles.models import Feed, Article |
64 | 4 | 5 | ||
65 | === modified file 'loco_directory/articles/views.py' | |||
66 | --- loco_directory/articles/views.py 2012-12-13 22:48:12 +0000 | |||
67 | +++ loco_directory/articles/views.py 2012-12-25 22:04:21 +0000 | |||
68 | @@ -14,4 +14,4 @@ | |||
69 | 14 | 'article': article, | 14 | 'article': article, |
70 | 15 | } | 15 | } |
71 | 16 | return render_to_response('articles/article_detail.html', | 16 | return render_to_response('articles/article_detail.html', |
73 | 17 | context, RequestContext(request)) | 17 | context, RequestContext(request)) |
74 | 18 | 18 | ||
75 | === modified file 'loco_directory/events/admin.py' | |||
76 | --- loco_directory/events/admin.py 2012-12-22 23:22:32 +0000 | |||
77 | +++ loco_directory/events/admin.py 2012-12-25 22:04:21 +0000 | |||
78 | @@ -1,6 +1,6 @@ | |||
79 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
80 | 2 | from django.contrib import admin | 2 | from django.contrib import admin |
82 | 3 | from .models import * | 3 | from .models import (Venue, GlobalEvent, TeamEvent, Attendee) |
83 | 4 | 4 | ||
84 | 5 | 5 | ||
85 | 6 | class TeamEventAdmin(admin.ModelAdmin): | 6 | class TeamEventAdmin(admin.ModelAdmin): |
86 | 7 | 7 | ||
87 | === modified file 'loco_directory/meetings/admin.py' | |||
88 | --- loco_directory/meetings/admin.py 2012-12-04 21:25:51 +0000 | |||
89 | +++ loco_directory/meetings/admin.py 2012-12-25 22:04:21 +0000 | |||
90 | @@ -1,6 +1,6 @@ | |||
91 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
92 | 2 | from django.contrib import admin | 2 | from django.contrib import admin |
94 | 3 | from meetings.models import * | 3 | from meetings.models import (TeamMeeting, AgendaItem) |
95 | 4 | 4 | ||
96 | 5 | admin.site.register(TeamMeeting) | 5 | admin.site.register(TeamMeeting) |
97 | 6 | admin.site.register(AgendaItem) | 6 | admin.site.register(AgendaItem) |
98 | 7 | 7 | ||
99 | === modified file 'loco_directory/teams/admin.py' | |||
100 | --- loco_directory/teams/admin.py 2010-08-24 13:47:33 +0000 | |||
101 | +++ loco_directory/teams/admin.py 2012-12-25 22:04:21 +0000 | |||
102 | @@ -3,21 +3,25 @@ | |||
103 | 3 | from django.contrib import admin | 3 | from django.contrib import admin |
104 | 4 | from teams.models import Team, Continent, Country, Language | 4 | from teams.models import Team, Continent, Country, Language |
105 | 5 | 5 | ||
106 | 6 | |||
107 | 6 | class TeamAdmin(admin.ModelAdmin): | 7 | class TeamAdmin(admin.ModelAdmin): |
108 | 7 | search_fields = ('name',) | 8 | search_fields = ('name',) |
110 | 8 | 9 | ||
111 | 9 | def formfield_for_dbfield(self, db_field, **kwargs): | 10 | def formfield_for_dbfield(self, db_field, **kwargs): |
112 | 10 | field = super(TeamAdmin, self).formfield_for_dbfield(db_field, **kwargs) | 11 | field = super(TeamAdmin, self).formfield_for_dbfield(db_field, **kwargs) |
113 | 11 | if db_field.name == 'description': | 12 | if db_field.name == 'description': |
114 | 12 | field.widget.attrs['rows'] = '4' | 13 | field.widget.attrs['rows'] = '4' |
115 | 13 | return field | 14 | return field |
117 | 14 | 15 | ||
118 | 16 | |||
119 | 15 | class ContinentAdmin(admin.ModelAdmin): | 17 | class ContinentAdmin(admin.ModelAdmin): |
120 | 16 | search_fields = ('name',) | 18 | search_fields = ('name',) |
121 | 17 | 19 | ||
122 | 20 | |||
123 | 18 | class CountryAdmin(admin.ModelAdmin): | 21 | class CountryAdmin(admin.ModelAdmin): |
124 | 19 | search_fields = ('name',) | 22 | search_fields = ('name',) |
125 | 20 | 23 | ||
126 | 24 | |||
127 | 21 | class LanguageAdmin(admin.ModelAdmin): | 25 | class LanguageAdmin(admin.ModelAdmin): |
128 | 22 | search_fields = ('name',) | 26 | search_fields = ('name',) |
129 | 23 | 27 | ||
130 | 24 | 28 | ||
131 | === modified file 'loco_directory/teams/feeds.py' | |||
132 | --- loco_directory/teams/feeds.py 2012-11-26 23:07:59 +0000 | |||
133 | +++ loco_directory/teams/feeds.py 2012-12-25 22:04:21 +0000 | |||
134 | @@ -1,7 +1,6 @@ | |||
135 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
136 | 2 | from django.core.exceptions import ObjectDoesNotExist | 2 | from django.core.exceptions import ObjectDoesNotExist |
139 | 3 | from django.core.urlresolvers import reverse | 3 | from django.contrib.syndication.feeds import Feed |
138 | 4 | from django.contrib.syndication.feeds import Feed, FeedDoesNotExist | ||
140 | 5 | from django.utils.translation import ugettext as _ | 4 | from django.utils.translation import ugettext as _ |
141 | 6 | from meetings.models import TeamMeeting | 5 | from meetings.models import TeamMeeting |
142 | 7 | from events.models import TeamEvent | 6 | from events.models import TeamEvent |
143 | @@ -52,5 +51,3 @@ | |||
144 | 52 | return obj.get_absolute_url() | 51 | return obj.get_absolute_url() |
145 | 53 | else: | 52 | else: |
146 | 54 | return '/' | 53 | return '/' |
147 | 55 | |||
148 | 56 | |||
149 | 57 | 54 | ||
150 | === modified file 'loco_directory/teams/forms.py' | |||
151 | --- loco_directory/teams/forms.py 2012-03-04 20:55:07 +0000 | |||
152 | +++ loco_directory/teams/forms.py 2012-12-25 22:04:21 +0000 | |||
153 | @@ -1,12 +1,10 @@ | |||
154 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
155 | 2 | |||
156 | 3 | from django import forms | 2 | from django import forms |
157 | 4 | from django.utils.translation import ugettext_lazy as _ | ||
158 | 5 | 3 | ||
159 | 6 | from models import Team | 4 | from models import Team |
160 | 7 | from userprofiles.models import UserProfile | ||
161 | 8 | from common.forms import RenderableMixin | 5 | from common.forms import RenderableMixin |
162 | 9 | 6 | ||
163 | 7 | |||
164 | 10 | class UpdateTeamForm(forms.ModelForm, RenderableMixin): | 8 | class UpdateTeamForm(forms.ModelForm, RenderableMixin): |
165 | 11 | class Meta: | 9 | class Meta: |
166 | 12 | model = Team | 10 | model = Team |
167 | @@ -14,12 +12,13 @@ | |||
168 | 14 | 12 | ||
169 | 15 | class Media: | 13 | class Media: |
170 | 16 | css = {'all': ( | 14 | css = {'all': ( |
173 | 17 | '/media/css/colortip-1.0-jquery.css', | 15 | '/media/css/colortip-1.0-jquery.css', |
174 | 18 | )} | 16 | )} |
175 | 19 | js = ( | 17 | js = ( |
176 | 20 | '/media/js/colortip-1.0-jquery.js', | 18 | '/media/js/colortip-1.0-jquery.js', |
177 | 21 | ) | 19 | ) |
178 | 22 | 20 | ||
179 | 21 | |||
180 | 23 | class LoCoCouncilForm(UpdateTeamForm, RenderableMixin): | 22 | class LoCoCouncilForm(UpdateTeamForm, RenderableMixin): |
181 | 24 | class Meta(UpdateTeamForm.Meta): | 23 | class Meta(UpdateTeamForm.Meta): |
182 | 25 | model = Team | 24 | model = Team |
183 | 26 | 25 | ||
184 | === modified file 'loco_directory/teams/models.py' | |||
185 | --- loco_directory/teams/models.py 2012-11-18 22:02:56 +0000 | |||
186 | +++ loco_directory/teams/models.py 2012-12-25 22:04:21 +0000 | |||
187 | @@ -3,10 +3,10 @@ | |||
188 | 3 | from django.db import models | 3 | from django.db import models |
189 | 4 | from django.utils.translation import ugettext_lazy as _ | 4 | from django.utils.translation import ugettext_lazy as _ |
190 | 5 | 5 | ||
191 | 6 | from common.utils import flat_list | ||
192 | 7 | from common.mixins import LocalTimeMixin | 6 | from common.mixins import LocalTimeMixin |
193 | 8 | from userprofiles.models import UserProfile | 7 | from userprofiles.models import UserProfile |
194 | 9 | 8 | ||
195 | 9 | |||
196 | 10 | class Language(models.Model): | 10 | class Language(models.Model): |
197 | 11 | class Meta: | 11 | class Meta: |
198 | 12 | ordering = ('name',) | 12 | ordering = ('name',) |
199 | @@ -16,9 +16,11 @@ | |||
200 | 16 | def __unicode__(self): | 16 | def __unicode__(self): |
201 | 17 | return u'%s' % (self.name) | 17 | return u'%s' % (self.name) |
202 | 18 | 18 | ||
203 | 19 | |||
204 | 19 | class TeamManager(models.Manager): | 20 | class TeamManager(models.Manager): |
205 | 20 | pass | 21 | pass |
206 | 21 | 22 | ||
207 | 23 | |||
208 | 22 | class Continent(models.Model): | 24 | class Continent(models.Model): |
209 | 23 | name = models.TextField(_("Name"), max_length=50) | 25 | name = models.TextField(_("Name"), max_length=50) |
210 | 24 | 26 | ||
211 | @@ -41,6 +43,7 @@ | |||
212 | 41 | def related_teams(self): | 43 | def related_teams(self): |
213 | 42 | return Team.objects.filter(countries__continents=self).distinct() | 44 | return Team.objects.filter(countries__continents=self).distinct() |
214 | 43 | 45 | ||
215 | 46 | |||
216 | 44 | class Country(models.Model): | 47 | class Country(models.Model): |
217 | 45 | name = models.TextField(_("Name"), max_length=100) | 48 | name = models.TextField(_("Name"), max_length=100) |
218 | 46 | continents = models.ManyToManyField(Continent) | 49 | continents = models.ManyToManyField(Continent) |
219 | @@ -66,21 +69,25 @@ | |||
220 | 66 | else: | 69 | else: |
221 | 67 | return 'no_country' | 70 | return 'no_country' |
222 | 68 | 71 | ||
223 | 72 | |||
224 | 69 | def countries_without_continent(): | 73 | def countries_without_continent(): |
225 | 70 | return Country.objects.filter(continents__isnull=True) | 74 | return Country.objects.filter(continents__isnull=True) |
226 | 71 | 75 | ||
227 | 76 | |||
228 | 72 | def countries_without_continent_have_venues(): | 77 | def countries_without_continent_have_venues(): |
229 | 73 | for country in countries_without_continent(): | 78 | for country in countries_without_continent(): |
230 | 74 | if country.venue_set.count() > 0: | 79 | if country.venue_set.count() > 0: |
231 | 75 | return True | 80 | return True |
232 | 76 | return False | 81 | return False |
233 | 77 | 82 | ||
234 | 83 | |||
235 | 78 | def countries_without_continent_have_teams(): | 84 | def countries_without_continent_have_teams(): |
236 | 79 | for country in countries_without_continent(): | 85 | for country in countries_without_continent(): |
237 | 80 | if country.team_set.count() > 0: | 86 | if country.team_set.count() > 0: |
238 | 81 | return True | 87 | return True |
239 | 82 | return False | 88 | return False |
240 | 83 | 89 | ||
241 | 90 | |||
242 | 84 | class Team(models.Model, LocalTimeMixin): | 91 | class Team(models.Model, LocalTimeMixin): |
243 | 85 | lp_name = models.CharField(_("Launchpad Team ID"), max_length=40, null=True) | 92 | lp_name = models.CharField(_("Launchpad Team ID"), max_length=40, null=True) |
244 | 86 | name = models.CharField(_("Team Name"), max_length=80, null=False, default='') | 93 | name = models.CharField(_("Team Name"), max_length=80, null=False, default='') |
245 | @@ -150,5 +157,6 @@ | |||
246 | 150 | events_and_meetings = events_and_meetings[:5] | 157 | events_and_meetings = events_and_meetings[:5] |
247 | 151 | return events_and_meetings | 158 | return events_and_meetings |
248 | 152 | 159 | ||
249 | 160 | |||
250 | 153 | def teams_without_country(): | 161 | def teams_without_country(): |
251 | 154 | return Team.objects.filter(countries__isnull=True) | 162 | return Team.objects.filter(countries__isnull=True) |
252 | 155 | 163 | ||
253 | === modified file 'loco_directory/teams/tests.py' | |||
254 | --- loco_directory/teams/tests.py 2012-11-28 00:46:29 +0000 | |||
255 | +++ loco_directory/teams/tests.py 2012-12-25 22:04:21 +0000 | |||
256 | @@ -1,16 +1,12 @@ | |||
257 | 1 | from django.test import TestCase | 1 | from django.test import TestCase |
258 | 2 | from django.contrib.auth.models import User, Group | ||
259 | 2 | from django.core.urlresolvers import reverse | 3 | from django.core.urlresolvers import reverse |
260 | 3 | from urllib import urlencode | 4 | from urllib import urlencode |
261 | 4 | |||
262 | 5 | from django.contrib.auth.models import User, Group | ||
263 | 6 | |||
264 | 7 | from django_openid_auth.models import UserOpenID | 5 | from django_openid_auth.models import UserOpenID |
265 | 8 | from userprofiles.models import UserProfile | ||
266 | 9 | from teams.models import * | 6 | from teams.models import * |
267 | 10 | from common import launchpad | 7 | from common import launchpad |
268 | 11 | 8 | ||
269 | 12 | 9 | ||
270 | 13 | |||
271 | 14 | class TestBase(TestCase): | 10 | class TestBase(TestCase): |
272 | 15 | 11 | ||
273 | 16 | def setUp(self): | 12 | def setUp(self): |
274 | @@ -60,6 +56,7 @@ | |||
275 | 60 | self.user_foo.groups.add(self.team_group) | 56 | self.user_foo.groups.add(self.team_group) |
276 | 61 | self.user_foo.save() | 57 | self.user_foo.save() |
277 | 62 | 58 | ||
278 | 59 | |||
279 | 63 | class ACLChecksTestCase(TestBase): | 60 | class ACLChecksTestCase(TestBase): |
280 | 64 | 61 | ||
281 | 65 | def testAdminIsATeamChecks(self): | 62 | def testAdminIsATeamChecks(self): |
282 | @@ -69,6 +66,7 @@ | |||
283 | 69 | self.assertEquals(launchpad.is_admin_or_owner(self.user_foo.username, team), True) | 66 | self.assertEquals(launchpad.is_admin_or_owner(self.user_foo.username, team), True) |
284 | 70 | self.assertEquals(launchpad.is_admin_or_owner(self.user_bar.username, team), False) | 67 | self.assertEquals(launchpad.is_admin_or_owner(self.user_bar.username, team), False) |
285 | 71 | 68 | ||
286 | 69 | |||
287 | 72 | class EditTeamTestCase(TestBase): | 70 | class EditTeamTestCase(TestBase): |
288 | 73 | """ | 71 | """ |
289 | 74 | test if team update works correct | 72 | test if team update works correct |
290 | @@ -79,12 +77,12 @@ | |||
291 | 79 | """ | 77 | """ |
292 | 80 | #try to access team-update page as not logged in user | 78 | #try to access team-update page as not logged in user |
293 | 81 | 79 | ||
296 | 82 | data = { 'next' : '/teams/test-team/edit' } | 80 | data = {'next': '/teams/test-team/edit'} |
297 | 83 | response = self.client.get(reverse( 'team-edit', args=['test-team'] ), follow=True) | 81 | response = self.client.get(reverse('team-edit', args=['test-team']), follow=True) |
298 | 84 | self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200) | 82 | self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200) |
299 | 85 | 83 | ||
300 | 86 | #try to update team as not logged in user | 84 | #try to update team as not logged in user |
302 | 87 | response = self.client.post(reverse('team-edit', args=['test-team']), {'Country':'Germany', 'forum_url':'http://ubuntuusers.de'}, follow=True) | 85 | response = self.client.post(reverse('team-edit', args=['test-team']), {'Country': 'Germany', 'forum_url': 'http://ubuntuusers.de'}, follow=True) |
303 | 88 | self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200) | 86 | self.assertRedirects(response, '/openid/login/?%s' % urlencode(data), status_code=302, target_status_code=200) |
304 | 89 | 87 | ||
305 | 90 | def test_user_with_no_rights(self): | 88 | def test_user_with_no_rights(self): |
306 | @@ -108,6 +106,7 @@ | |||
307 | 108 | pass | 106 | pass |
308 | 109 | #FIXME How to use a user with this rights with openid? | 107 | #FIXME How to use a user with this rights with openid? |
309 | 110 | 108 | ||
310 | 109 | |||
311 | 111 | class DisplayNameTestCase(TestBase): | 110 | class DisplayNameTestCase(TestBase): |
312 | 112 | 111 | ||
313 | 113 | def test_override_name(self): | 112 | def test_override_name(self): |
314 | @@ -135,5 +134,5 @@ | |||
315 | 135 | response = self.client.get('/teams/test-team/') | 134 | response = self.client.get('/teams/test-team/') |
316 | 136 | self.assertEquals(response.status_code, 200) | 135 | self.assertEquals(response.status_code, 200) |
317 | 137 | 136 | ||
320 | 138 | self.assertContains(response, 'Override Name', 0) # No instances of override_name | 137 | self.assertContains(response, 'Override Name', 0) # No instances of override_name |
321 | 139 | self.assertContains(response, 'Test Team', 4) # One instance of the team name | 138 | self.assertContains(response, 'Test Team', 4) # One instance of the team name |
322 | 140 | 139 | ||
323 | === modified file 'loco_directory/teams/utils.py' | |||
324 | --- loco_directory/teams/utils.py 2011-02-17 13:04:25 +0000 | |||
325 | +++ loco_directory/teams/utils.py 2012-12-25 22:04:21 +0000 | |||
326 | @@ -2,6 +2,7 @@ | |||
327 | 2 | 2 | ||
328 | 3 | from events.models import TeamEvent | 3 | from events.models import TeamEvent |
329 | 4 | 4 | ||
330 | 5 | |||
331 | 5 | def merge_teams(old_team, new_team): | 6 | def merge_teams(old_team, new_team): |
332 | 6 | msgs = [] | 7 | msgs = [] |
333 | 7 | related_events = TeamEvent.objects.filter(teams__id=old_team.id) | 8 | related_events = TeamEvent.objects.filter(teams__id=old_team.id) |
334 | @@ -60,4 +61,3 @@ | |||
335 | 60 | old_team.delete() | 61 | old_team.delete() |
336 | 61 | msgs += [ugettext('Team "%(old_team)s" merged with "%(new_team)s".' % {'old_team':old_team.name, 'new_team':new_team.name})] | 62 | msgs += [ugettext('Team "%(old_team)s" merged with "%(new_team)s".' % {'old_team':old_team.name, 'new_team':new_team.name})] |
337 | 62 | return msgs | 63 | return msgs |
338 | 63 | |||
339 | 64 | 64 | ||
340 | === modified file 'loco_directory/teams/views.py' | |||
341 | --- loco_directory/teams/views.py 2012-12-18 22:35:47 +0000 | |||
342 | +++ loco_directory/teams/views.py 2012-12-25 22:04:21 +0000 | |||
343 | @@ -19,10 +19,10 @@ | |||
344 | 19 | from articles.models import Article | 19 | from articles.models import Article |
345 | 20 | 20 | ||
346 | 21 | import forms | 21 | import forms |
347 | 22 | |||
348 | 23 | import datetime | 22 | import datetime |
349 | 24 | import vobject | 23 | import vobject |
350 | 25 | 24 | ||
351 | 25 | |||
352 | 26 | def reapprovals(request): | 26 | def reapprovals(request): |
353 | 27 | teams = filter(lambda a: a.approved and a.expires_date != None, | 27 | teams = filter(lambda a: a.approved and a.expires_date != None, |
354 | 28 | Team.objects.all().order_by('expires_date', 'name')) | 28 | Team.objects.all().order_by('expires_date', 'name')) |
355 | @@ -31,11 +31,11 @@ | |||
356 | 31 | # XXX: we have no idea why, but on loco.ubuntu.com we are dealing with | 31 | # XXX: we have no idea why, but on loco.ubuntu.com we are dealing with |
357 | 32 | # datetime.datetime instead of datetime.date - bug 581641 | 32 | # datetime.datetime instead of datetime.date - bug 581641 |
358 | 33 | if type(teams[0].expires_date) == datetime.datetime: | 33 | if type(teams[0].expires_date) == datetime.datetime: |
361 | 34 | next_teams = filter(lambda a: a.expires_date.date() <= today+half_a_year, teams) | 34 | next_teams = filter(lambda a: a.expires_date.date() <= today + half_a_year, teams) |
362 | 35 | later_teams = filter(lambda a: a.expires_date.date() > today+half_a_year, teams) | 35 | later_teams = filter(lambda a: a.expires_date.date() > today + half_a_year, teams) |
363 | 36 | else: | 36 | else: |
366 | 37 | next_teams = filter(lambda a: a.expires_date <= today+half_a_year, teams) | 37 | next_teams = filter(lambda a: a.expires_date <= today + half_a_year, teams) |
367 | 38 | later_teams = filter(lambda a: a.expires_date > today+half_a_year, teams) | 38 | later_teams = filter(lambda a: a.expires_date > today + half_a_year, teams) |
368 | 39 | context = { | 39 | context = { |
369 | 40 | 'next_teams': next_teams, | 40 | 'next_teams': next_teams, |
370 | 41 | 'later_teams': later_teams, | 41 | 'later_teams': later_teams, |
371 | @@ -43,6 +43,7 @@ | |||
372 | 43 | return render_to_response('teams/team_reapprovals.html', | 43 | return render_to_response('teams/team_reapprovals.html', |
373 | 44 | context, RequestContext(request)) | 44 | context, RequestContext(request)) |
374 | 45 | 45 | ||
375 | 46 | |||
376 | 46 | def as_ical(objects, name): | 47 | def as_ical(objects, name): |
377 | 47 | """Return any list events as an ical""" | 48 | """Return any list events as an ical""" |
378 | 48 | filename = "%s.ics" % name.replace(' ', '-').lower() | 49 | filename = "%s.ics" % name.replace(' ', '-').lower() |
379 | @@ -61,6 +62,7 @@ | |||
380 | 61 | 62 | ||
381 | 62 | return response | 63 | return response |
382 | 63 | 64 | ||
383 | 65 | |||
384 | 64 | def team_list(request): | 66 | def team_list(request): |
385 | 65 | continents = Continent.objects.all().order_by('name') | 67 | continents = Continent.objects.all().order_by('name') |
386 | 66 | for continent in continents: | 68 | for continent in continents: |
387 | @@ -75,17 +77,19 @@ | |||
388 | 75 | 'countries_without_continent': all_countries_without_continent, | 77 | 'countries_without_continent': all_countries_without_continent, |
389 | 76 | 'countries_without_continent_have_teams': countries_without_continent_have_teams(), | 78 | 'countries_without_continent_have_teams': countries_without_continent_have_teams(), |
390 | 77 | 'teams_without_country': teams_without_country().order_by('name'), | 79 | 'teams_without_country': teams_without_country().order_by('name'), |
392 | 78 | 'colcycle' : simple_iterator('col_left', 'col_right'), | 80 | 'colcycle': simple_iterator('col_left', 'col_right'), |
393 | 79 | } | 81 | } |
394 | 80 | return render_to_response('teams/team_list.html', context, | 82 | return render_to_response('teams/team_list.html', context, |
395 | 81 | RequestContext(request)) | 83 | RequestContext(request)) |
396 | 82 | 84 | ||
397 | 85 | |||
398 | 83 | def get_events_and_meetings(team_object): | 86 | def get_events_and_meetings(team_object): |
399 | 84 | team_events = list(TeamEvent.objects.filter(teams=team_object)) | 87 | team_events = list(TeamEvent.objects.filter(teams=team_object)) |
400 | 85 | team_meetings = list(TeamMeeting.objects.filter(teams=team_object)) | 88 | team_meetings = list(TeamMeeting.objects.filter(teams=team_object)) |
401 | 86 | team_events.extend(team_meetings) | 89 | team_events.extend(team_meetings) |
402 | 87 | return team_events | 90 | return team_events |
403 | 88 | 91 | ||
404 | 92 | |||
405 | 89 | def team_ical(request, team_slug): | 93 | def team_ical(request, team_slug): |
406 | 90 | """ | 94 | """ |
407 | 91 | Return a ical list with the events and meetings in ical format. | 95 | Return a ical list with the events and meetings in ical format. |
408 | @@ -93,6 +97,7 @@ | |||
409 | 93 | team_object = get_object_or_404(Team, lp_name=team_slug) | 97 | team_object = get_object_or_404(Team, lp_name=team_slug) |
410 | 94 | return as_ical(get_events_and_meetings(team_object), team_object.name) | 98 | return as_ical(get_events_and_meetings(team_object), team_object.name) |
411 | 95 | 99 | ||
412 | 100 | |||
413 | 96 | def team_event_list(request, team_slug): | 101 | def team_event_list(request, team_slug): |
414 | 97 | """ | 102 | """ |
415 | 98 | list with all team events in present and future for the given team | 103 | list with all team events in present and future for the given team |
416 | @@ -105,11 +110,12 @@ | |||
417 | 105 | context = { | 110 | context = { |
418 | 106 | 'team_object': team_object, | 111 | 'team_object': team_object, |
419 | 107 | 'team_event_list': team_event_list, | 112 | 'team_event_list': team_event_list, |
421 | 108 | 'is_member' : is_member, | 113 | 'is_member': is_member, |
422 | 109 | } | 114 | } |
423 | 110 | return render_to_response('teams/team_event_list.html', context, | 115 | return render_to_response('teams/team_event_list.html', context, |
424 | 111 | RequestContext(request)) | 116 | RequestContext(request)) |
425 | 112 | 117 | ||
426 | 118 | |||
427 | 113 | def team_event_history(request, team_slug): | 119 | def team_event_history(request, team_slug): |
428 | 114 | """ | 120 | """ |
429 | 115 | list with all team events in past for the given team | 121 | list with all team events in past for the given team |
430 | @@ -123,6 +129,7 @@ | |||
431 | 123 | return render_to_response('teams/team_event_history.html', context, | 129 | return render_to_response('teams/team_event_history.html', context, |
432 | 124 | RequestContext(request)) | 130 | RequestContext(request)) |
433 | 125 | 131 | ||
434 | 132 | |||
435 | 126 | def team_meeting_list(request, team_slug): | 133 | def team_meeting_list(request, team_slug): |
436 | 127 | """ | 134 | """ |
437 | 128 | list with all team meetings in present and future for the given team | 135 | list with all team meetings in present and future for the given team |
438 | @@ -136,6 +143,7 @@ | |||
439 | 136 | return render_to_response('teams/team_meeting_list.html', context, | 143 | return render_to_response('teams/team_meeting_list.html', context, |
440 | 137 | RequestContext(request)) | 144 | RequestContext(request)) |
441 | 138 | 145 | ||
442 | 146 | |||
443 | 139 | def team_meeting_history(request, team_slug): | 147 | def team_meeting_history(request, team_slug): |
444 | 140 | """ | 148 | """ |
445 | 141 | list with all team meetings in past for the given team | 149 | list with all team meetings in past for the given team |
446 | @@ -180,11 +188,12 @@ | |||
447 | 180 | team_list = Team.objects.all().order_by('name') | 188 | team_list = Team.objects.all().order_by('name') |
448 | 181 | other_teams = team_list.exclude(id=team_object.id) | 189 | other_teams = team_list.exclude(id=team_object.id) |
449 | 182 | return render_to_response('teams/select_other_team.html', | 190 | return render_to_response('teams/select_other_team.html', |
453 | 183 | {'team_object':team_object, | 191 | {'team_object': team_object, |
454 | 184 | 'other_teams':other_teams, | 192 | 'other_teams': other_teams, |
455 | 185 | 'user':request.user, | 193 | 'user': request.user, |
456 | 186 | }, RequestContext(request)) | 194 | }, RequestContext(request)) |
457 | 187 | 195 | ||
458 | 196 | |||
459 | 188 | @login_required | 197 | @login_required |
460 | 189 | def team_merge(request, team_slug, other_team_slug): | 198 | def team_merge(request, team_slug, other_team_slug): |
461 | 190 | old_team = get_object_or_404(Team, lp_name=team_slug) | 199 | old_team = get_object_or_404(Team, lp_name=team_slug) |
462 | @@ -202,9 +211,9 @@ | |||
463 | 202 | request.user.message_set.create(message=msg) | 211 | request.user.message_set.create(message=msg) |
464 | 203 | 212 | ||
465 | 204 | return render_to_response('teams/merge_teams.html', | 213 | return render_to_response('teams/merge_teams.html', |
469 | 205 | {'team_object':old_team, | 214 | {'team_object': old_team, |
470 | 206 | 'other_team_object':new_team, | 215 | 'other_team_object': new_team, |
471 | 207 | 'user':request.user, | 216 | 'user': request.user, |
472 | 208 | }, RequestContext(request)) | 217 | }, RequestContext(request)) |
473 | 209 | 218 | ||
474 | 210 | 219 | ||
475 | @@ -218,7 +227,7 @@ | |||
476 | 218 | is_contact = launchpad.is_admin_or_owner(request.user.username, team_object) | 227 | is_contact = launchpad.is_admin_or_owner(request.user.username, team_object) |
477 | 219 | if not is_on_lc and not is_contact: | 228 | if not is_on_lc and not is_contact: |
478 | 220 | request.user.message_set.create(message=ugettext('You are not allowed to make changes to the team details.')) | 229 | request.user.message_set.create(message=ugettext('You are not allowed to make changes to the team details.')) |
480 | 221 | return redirect( team_object ) | 230 | return redirect(team_object) |
481 | 222 | 231 | ||
482 | 223 | if request.method == "POST": | 232 | if request.method == "POST": |
483 | 224 | if is_on_lc: | 233 | if is_on_lc: |
484 | @@ -228,7 +237,7 @@ | |||
485 | 228 | if form.is_valid(): | 237 | if form.is_valid(): |
486 | 229 | form.save() | 238 | form.save() |
487 | 230 | request.user.message_set.create(message=ugettext('Thanks, your team\'s details have been saved.')) | 239 | request.user.message_set.create(message=ugettext('Thanks, your team\'s details have been saved.')) |
489 | 231 | return redirect( team_object ) | 240 | return redirect(team_object) |
490 | 232 | else: | 241 | else: |
491 | 233 | request.user.message_set.create(message=ugettext('Recent changes to your team\'s details could not be saved.')) | 242 | request.user.message_set.create(message=ugettext('Recent changes to your team\'s details could not be saved.')) |
492 | 234 | else: | 243 | else: |
493 | @@ -239,10 +248,11 @@ | |||
494 | 239 | 248 | ||
495 | 240 | return render_to_response('teams/team_update.html', | 249 | return render_to_response('teams/team_update.html', |
496 | 241 | {'form': form, | 250 | {'form': form, |
499 | 242 | 'team':team_object, | 251 | 'team': team_object, |
500 | 243 | 'user':request.user, | 252 | 'user': request.user, |
501 | 244 | }, RequestContext(request)) | 253 | }, RequestContext(request)) |
502 | 245 | 254 | ||
503 | 255 | |||
504 | 246 | def xml_team_data(request): | 256 | def xml_team_data(request): |
505 | 247 | XMLSerializer = serializers.get_serializer("xml") | 257 | XMLSerializer = serializers.get_serializer("xml") |
506 | 248 | xml_serializer = XMLSerializer() | 258 | xml_serializer = XMLSerializer() |
507 | 249 | 259 | ||
508 | === modified file 'loco_directory/userprofiles/admin.py' | |||
509 | --- loco_directory/userprofiles/admin.py 2010-08-24 13:47:33 +0000 | |||
510 | +++ loco_directory/userprofiles/admin.py 2012-12-25 22:04:21 +0000 | |||
511 | @@ -1,6 +1,8 @@ | |||
512 | 1 | # -*- coding: utf-8 -*- | ||
513 | 1 | from django.contrib import admin | 2 | from django.contrib import admin |
514 | 2 | from userprofiles.models import UserProfile | 3 | from userprofiles.models import UserProfile |
515 | 3 | 4 | ||
516 | 5 | |||
517 | 4 | class UserProfileAdmin(admin.ModelAdmin): | 6 | class UserProfileAdmin(admin.ModelAdmin): |
518 | 5 | search_fields = ('realname',) | 7 | search_fields = ('realname',) |
519 | 6 | 8 | ||
520 | 7 | 9 | ||
521 | === modified file 'loco_directory/userprofiles/management/commands/update-profiles.py' | |||
522 | --- loco_directory/userprofiles/management/commands/update-profiles.py 2012-11-19 22:53:54 +0000 | |||
523 | +++ loco_directory/userprofiles/management/commands/update-profiles.py 2012-12-25 22:04:21 +0000 | |||
524 | @@ -3,13 +3,12 @@ | |||
525 | 3 | 3 | ||
526 | 4 | from django.core.management.base import BaseCommand | 4 | from django.core.management.base import BaseCommand |
527 | 5 | from django.contrib.auth.models import User | 5 | from django.contrib.auth.models import User |
528 | 6 | from optparse import make_option | ||
529 | 6 | 7 | ||
530 | 7 | from userprofiles.models import create_userprofile | 8 | from userprofiles.models import create_userprofile |
531 | 8 | |||
532 | 9 | from optparse import make_option | ||
533 | 10 | from datetime import datetime | ||
534 | 11 | import sys | 9 | import sys |
535 | 12 | 10 | ||
536 | 11 | |||
537 | 13 | class Command(BaseCommand): | 12 | class Command(BaseCommand): |
538 | 14 | help = "Updates user profiles with information from Launchpad." | 13 | help = "Updates user profiles with information from Launchpad." |
539 | 15 | option_list = BaseCommand.option_list + ( | 14 | option_list = BaseCommand.option_list + ( |
540 | 16 | 15 | ||
541 | === modified file 'loco_directory/userprofiles/tests.py' | |||
542 | --- loco_directory/userprofiles/tests.py 2012-11-18 22:02:56 +0000 | |||
543 | +++ loco_directory/userprofiles/tests.py 2012-12-25 22:04:21 +0000 | |||
544 | @@ -1,10 +1,11 @@ | |||
545 | 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
546 | 2 | from django.test import TestCase | 2 | from django.test import TestCase |
548 | 3 | from django.contrib.auth.models import User | 3 | from django.contrib.auth.models import User |
549 | 4 | from django.db.models import signals | 4 | from django.db.models import signals |
550 | 5 | 5 | ||
551 | 6 | from userprofiles.models import UserProfile | 6 | from userprofiles.models import UserProfile |
552 | 7 | 7 | ||
553 | 8 | |||
554 | 8 | class SignalTest(TestCase): | 9 | class SignalTest(TestCase): |
555 | 9 | ''' | 10 | ''' |
556 | 10 | Tests that signals fire properly | 11 | Tests that signals fire properly |
557 | @@ -27,4 +28,4 @@ | |||
558 | 27 | def test_profile_creation(self): | 28 | def test_profile_creation(self): |
559 | 28 | self.user = User.objects.create(username='bob', password='bob') | 29 | self.user = User.objects.create(username='bob', password='bob') |
560 | 29 | self.user.save() | 30 | self.user.save() |
561 | 30 | self.assertEqual(UserProfile.objects.all().count(), 1) | ||
562 | 31 | \ No newline at end of file | 31 | \ No newline at end of file |
563 | 32 | self.assertEqual(UserProfile.objects.all().count(), 1) |