Merge lp:~daker/loco-team-portal/fix.960695.common-app into lp:loco-team-portal
- fix.960695.common-app
- Merge into 0.2
Proposed by
Adnane Belmadiaf
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Chris Johnston | ||||
Approved revision: | 533 | ||||
Merged at revision: | 551 | ||||
Proposed branch: | lp:~daker/loco-team-portal/fix.960695.common-app | ||||
Merge into: | lp:loco-team-portal | ||||
Diff against target: |
704 lines (+128/-76) 11 files modified
loco_directory/common/context_processors.py (+14/-7) loco_directory/common/forms.py (+4/-3) loco_directory/common/launchpad.py (+1/-1) loco_directory/common/management/commands/recoverdata.py (+16/-16) loco_directory/common/mixins.py (+4/-5) loco_directory/common/shortcuts.py (+11/-8) loco_directory/common/templatetags/markup.py (+4/-1) loco_directory/common/templatetags/teams_tags.py (+2/-1) loco_directory/common/utils.py (+14/-11) loco_directory/common/views.py (+56/-21) loco_directory/common/widgets.py (+2/-2) |
||||
To merge this branch: | bzr merge lp:~daker/loco-team-portal/fix.960695.common-app | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Johnston | Approve | ||
Review via email: mp+108439@code.launchpad.net |
Commit message
* Fixed the common app coding style
Description of the change
To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'loco_directory/common/context_processors.py' |
2 | --- loco_directory/common/context_processors.py 2011-04-15 15:05:40 +0000 |
3 | +++ loco_directory/common/context_processors.py 2012-06-30 22:09:18 +0000 |
4 | @@ -4,14 +4,16 @@ |
5 | |
6 | from django.conf import settings |
7 | |
8 | + |
9 | def loco_version(request): |
10 | """ |
11 | - add the loco version to template context processor. |
12 | + add the loco version to template context processor. |
13 | """ |
14 | - |
15 | + |
16 | version = getattr(settings, 'VERSION_STRING', 'unknown') |
17 | return {'loco_version': version} |
18 | |
19 | + |
20 | def google_api_key(request): |
21 | """ |
22 | Return the Google API Key or "" if none is defined. |
23 | @@ -20,29 +22,34 @@ |
24 | google_api_key = getattr(settings, 'GOOGLE_API_KEY', '') |
25 | return {'google_api_key': google_api_key} |
26 | |
27 | + |
28 | def flickr_api_key(request): |
29 | """ |
30 | Return the Flickr API Key or "" if none is defined. |
31 | """ |
32 | - |
33 | + |
34 | flickr_api_key = getattr(settings, 'FLICKR_API_KEY', '') |
35 | return {'flickr_api_key': flickr_api_key} |
36 | - |
37 | + |
38 | + |
39 | def pixie_api_key(request): |
40 | """ |
41 | Return the Pix.ie API Key or "" if none is defined. |
42 | """ |
43 | - |
44 | + |
45 | pixie_api_key = getattr(settings, 'PIXIE_API_KEY', '') |
46 | return {'pixie_api_key': pixie_api_key} |
47 | |
48 | + |
49 | def login_redirect(request): |
50 | return {'login_next': request.get_full_path()} |
51 | |
52 | + |
53 | def url_base(request): |
54 | url = request.get_full_path().split('/') |
55 | - return {'url_base': url[1]} |
56 | - |
57 | + return {'url_base': url[1]} |
58 | + |
59 | + |
60 | def site_search(request): |
61 | from common.forms import SiteSearchForm |
62 | search_form = SiteSearchForm(data=request.GET) |
63 | |
64 | === modified file 'loco_directory/common/forms.py' |
65 | --- loco_directory/common/forms.py 2010-11-20 17:25:50 +0000 |
66 | +++ loco_directory/common/forms.py 2012-06-30 22:09:18 +0000 |
67 | @@ -2,12 +2,13 @@ |
68 | from django import forms |
69 | from django.utils.translation import ugettext as _ |
70 | |
71 | + |
72 | # Taken from http://djangosnippets.org/snippets/1732/ |
73 | class RenderableMixin(object): |
74 | """ |
75 | Mixin to render forms from a predefined template |
76 | """ |
77 | - |
78 | + |
79 | @property |
80 | def form_class_name(self): |
81 | return '.'.join([self.__module__, self.__class__.__name__.lower()]) |
82 | @@ -23,7 +24,7 @@ |
83 | |
84 | context_dict = dict( |
85 | non_field_errors=self.non_field_errors(), |
86 | - fields=[ forms.forms.BoundField(self, field, name) for name, field in self.fields.iteritems()], |
87 | + fields=[forms.forms.BoundField(self, field, name) for name, field in self.fields.iteritems()], |
88 | errors=self.errors, |
89 | data=self.data, |
90 | form=self, |
91 | @@ -40,6 +41,7 @@ |
92 | Context(context_dict) |
93 | ) |
94 | |
95 | + |
96 | class SiteSearchForm(forms.Form): |
97 | """ |
98 | A Search form for the whole site |
99 | @@ -49,4 +51,3 @@ |
100 | def as_line(self): |
101 | "Returns this form rendered. Only the fields. Nothing else HTML." |
102 | return self._html_output(u'%(label)s %(errors)s%(field)s%(help_text)s', u'%s', '', u'%s', False) |
103 | - |
104 | |
105 | === modified file 'loco_directory/common/launchpad.py' |
106 | --- loco_directory/common/launchpad.py 2012-06-20 11:02:00 +0000 |
107 | +++ loco_directory/common/launchpad.py 2012-06-30 22:09:18 +0000 |
108 | @@ -38,7 +38,7 @@ |
109 | if is_debug_user(user.username): |
110 | return True |
111 | if user.is_staff: |
112 | - return True |
113 | + return True |
114 | lc_in_groups = user.groups.filter(name__exact='ubuntu-lococouncil') |
115 | return (lc_in_groups.count() == 1) |
116 | |
117 | |
118 | === modified file 'loco_directory/common/management/commands/recoverdata.py' |
119 | --- loco_directory/common/management/commands/recoverdata.py 2011-08-30 19:24:24 +0000 |
120 | +++ loco_directory/common/management/commands/recoverdata.py 2012-06-30 22:09:18 +0000 |
121 | @@ -13,6 +13,7 @@ |
122 | from venues.models import * |
123 | from meetings.models import * |
124 | |
125 | + |
126 | class Command(BaseCommand): |
127 | args = 'dump_file' |
128 | help = 'Attempt to recover missing data from a json dump' |
129 | @@ -22,13 +23,13 @@ |
130 | print "You must supply a dumpfile" |
131 | return |
132 | dumpfile = args[0] |
133 | - |
134 | + |
135 | try: |
136 | json = open(dumpfile) |
137 | except: |
138 | print "Unable to open %s" % dumpfile |
139 | return |
140 | - |
141 | + |
142 | try: |
143 | decoder = simplejson.JSONDecoder() |
144 | data = decoder.decode(json.read()) |
145 | @@ -37,7 +38,7 @@ |
146 | return |
147 | finally: |
148 | json.close() |
149 | - |
150 | + |
151 | print "Loading %s" % dumpfile |
152 | users = dict() |
153 | profiles = dict() |
154 | @@ -46,11 +47,11 @@ |
155 | globalevents = dict() |
156 | teamevents = dict() |
157 | venues = dict() |
158 | - basemeetings=dict() |
159 | + basemeetings = dict() |
160 | teammeetings = dict() |
161 | agendaitems = dict() |
162 | agendaitems_needparent = dict() |
163 | - |
164 | + |
165 | # first pass we can collect user, teams and venues |
166 | for record in data: |
167 | # recover users |
168 | @@ -65,7 +66,7 @@ |
169 | ) |
170 | if user_created: |
171 | print "Created User: %s" % users[record['pk']].username |
172 | - |
173 | + |
174 | # recover teams |
175 | if record['model'] == 'teams.team': |
176 | # print "Checking team %s (%s)" % (record['fields']['name'], record['fields']['lp_name']) |
177 | @@ -111,12 +112,12 @@ |
178 | if record['model'] == 'events.baseevent': |
179 | # print "Caching baseevent %s" % (record['fields']['name'],) |
180 | baseevents[record['pk']] = record['fields'] |
181 | - |
182 | + |
183 | # save base meeting |
184 | if record['model'] == 'meetings.basemeeting': |
185 | # print "Caching basemeeting %s" % (record['fields']['name'],) |
186 | basemeetings[record['pk']] = record['fields'] |
187 | - |
188 | + |
189 | # recover userprofile |
190 | if record['model'] == 'userprofiles.userprofile': |
191 | if record['fields']['user'] in users: |
192 | @@ -134,7 +135,6 @@ |
193 | else: |
194 | print u"Failed to create missing userprofile, no such user: %s" % record['fields']['user'] |
195 | |
196 | - |
197 | # third pass we can collect global events and team meetings, using the |
198 | # baseevent and basemeeting data cached in the previous pass |
199 | for record in data: |
200 | @@ -170,7 +170,7 @@ |
201 | 'logs': basemeeting['logs'], |
202 | 'minutes': basemeeting['minutes'], |
203 | 'date_created': basemeeting['date_created'], |
204 | - 'chair': profiles.get(basemeeting['chair'], None),#profile lookup |
205 | + 'chair': profiles.get(basemeeting['chair'], None), # profile lookup |
206 | 'meeting_tz': record['fields']['meeting_tz'], |
207 | } |
208 | ) |
209 | @@ -190,14 +190,14 @@ |
210 | name=baseevent['name'], |
211 | date_begin=baseevent['date_begin'], |
212 | date_end=baseevent['date_end'], |
213 | - venue=venues.get(record['fields']['venue'], None), #venue lookup |
214 | + venue=venues.get(record['fields']['venue'], None), # venue lookup |
215 | channel=record['fields']['channel'], |
216 | defaults={ |
217 | 'description': baseevent['description'], |
218 | 'announce': baseevent['announce'], |
219 | 'date_created': baseevent['date_created'], |
220 | - 'contact': profiles.get(record['fields']['contact'], None), #profile lookup |
221 | - 'global_event': globalevents.get(record['fields']['global_event'], None), #global event lookup |
222 | + 'contact': profiles.get(record['fields']['contact'], None), # profile lookup |
223 | + 'global_event': globalevents.get(record['fields']['global_event'], None), # global event lookup |
224 | 'registration': record['fields']['registration'], |
225 | } |
226 | ) |
227 | @@ -219,7 +219,7 @@ |
228 | created_date=record['fields']['created_date'], |
229 | defaults={ |
230 | 'description': record['fields']['description'], |
231 | - 'parent': None, #saved for later lookup, since they aren't ordered |
232 | + 'parent': None, # saved for later lookup, since they aren't ordered |
233 | 'order': record['fields']['order'], |
234 | 'log': record['fields']['log'], |
235 | } |
236 | @@ -227,7 +227,7 @@ |
237 | if ai_created and record['fields']['parent']: |
238 | agendaitems_needparent[record['pk']] = record['fields']['parent'] |
239 | print u"Created AgendaItem %s: %s" % (agendaitems[record['pk']].pk, unicode(agendaitems[record['pk']].title).encode('ascii', 'ignore')) |
240 | - |
241 | + |
242 | # recover event attendee |
243 | if record['model'] == 'events.attendee': |
244 | if record['fields']['team_event'] in teamevents: |
245 | @@ -259,7 +259,7 @@ |
246 | print u"Created TeamEvent Comment: %s on %s (%s)" % (comment.commenter_profile.user.username, unicode(comment.team_event.name).encode('ascii', 'ignore'), comment.team_event.pk) |
247 | else: |
248 | print u"Failed to create TeamEventComment, no such team event: %s" % record['fields']['team_event'] |
249 | - |
250 | + |
251 | # after fifth pass, set agendaitem parents |
252 | for agendaitem_id in agendaitems_needparent: |
253 | parent_id = agendaitems_needparent[agendaitem_id] |
254 | |
255 | === modified file 'loco_directory/common/mixins.py' |
256 | --- loco_directory/common/mixins.py 2011-06-17 17:10:41 +0000 |
257 | +++ loco_directory/common/mixins.py 2012-06-30 22:09:18 +0000 |
258 | @@ -1,8 +1,9 @@ |
259 | import pytz |
260 | |
261 | + |
262 | class LocalTimeMixin(object): |
263 | '''Provides methods for converting between UTC and localtime |
264 | - |
265 | + |
266 | Classes using this should provide the timezone string as self.tz |
267 | ''' |
268 | |
269 | @@ -13,19 +14,17 @@ |
270 | except: |
271 | return pytz.utc |
272 | timezone = property(get_timezone) |
273 | - |
274 | + |
275 | def tolocaltime(self, dt): |
276 | 'Converts a datetime in UTC to a datetime in this object\'s timezone' |
277 | if dt is None: |
278 | return None |
279 | as_utc = pytz.utc.localize(dt) |
280 | return as_utc.astimezone(self.timezone) |
281 | - |
282 | + |
283 | def fromlocaltime(self, dt): |
284 | 'Converts a datetime in this object\'s timezone to a datetime in UTC' |
285 | if dt is None: |
286 | return None |
287 | local = self.timezone.localize(dt) |
288 | return local.astimezone(pytz.utc) |
289 | - |
290 | - |
291 | |
292 | === modified file 'loco_directory/common/shortcuts.py' |
293 | --- loco_directory/common/shortcuts.py 2010-04-09 14:10:02 +0000 |
294 | +++ loco_directory/common/shortcuts.py 2012-06-30 22:09:18 +0000 |
295 | @@ -9,20 +9,22 @@ |
296 | from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect |
297 | from django.core import urlresolvers |
298 | |
299 | + |
300 | +# pylint: disable-msg=C0103 |
301 | def redirect(to, *args, **kwargs): |
302 | """ |
303 | Returns an HttpResponseRedirect to the apropriate URL for the arguments |
304 | passed. |
305 | - |
306 | + |
307 | The arguments could be: |
308 | - |
309 | + |
310 | * A model: the model's `get_absolute_url()` function will be called. |
311 | - |
312 | + |
313 | * A view name, possibly with arguments: `urlresolvers.reverse()` will |
314 | be used to reverse-resolve the name. |
315 | - |
316 | + |
317 | * A URL, which will be used as-is for the redirect location. |
318 | - |
319 | + |
320 | By default issues a temporary redirect; pass permanent=True to issue a |
321 | permanent redirect |
322 | """ |
323 | @@ -30,11 +32,11 @@ |
324 | redirect_class = HttpResponsePermanentRedirect |
325 | else: |
326 | redirect_class = HttpResponseRedirect |
327 | - |
328 | + |
329 | # If it's a model, use get_absolute_url() |
330 | if hasattr(to, 'get_absolute_url'): |
331 | return redirect_class(to.get_absolute_url()) |
332 | - |
333 | + |
334 | # Next try a reverse URL resolution. |
335 | try: |
336 | return redirect_class(urlresolvers.reverse(to, args=args, kwargs=kwargs)) |
337 | @@ -42,7 +44,7 @@ |
338 | # If this doesn't "feel" like a URL, re-raise. |
339 | if '/' not in to and '.' not in to: |
340 | raise |
341 | - |
342 | + |
343 | # Finally, fall back and assume it's a URL |
344 | return redirect_class(to) |
345 | |
346 | @@ -64,6 +66,7 @@ |
347 | raise AttributeError |
348 | return sum |
349 | |
350 | + |
351 | def queryset_count(field, qs): |
352 | """ |
353 | Returns the number of non-null the values in the given field of the queryset |
354 | |
355 | === modified file 'loco_directory/common/templatetags/markup.py' |
356 | --- loco_directory/common/templatetags/markup.py 2012-02-07 14:36:29 +0000 |
357 | +++ loco_directory/common/templatetags/markup.py 2012-06-30 22:09:18 +0000 |
358 | @@ -20,6 +20,7 @@ |
359 | |
360 | register = template.Library() |
361 | |
362 | + |
363 | @register.filter |
364 | def textile(value): |
365 | try: |
366 | @@ -31,6 +32,7 @@ |
367 | else: |
368 | return mark_safe(force_unicode(textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))) |
369 | |
370 | + |
371 | @register.filter |
372 | def markdown(value, arg=''): |
373 | """ |
374 | @@ -68,13 +70,14 @@ |
375 | |
376 | # Unicode support only in markdown v1.7 or above. Version_info |
377 | # exist only in markdown v1.6.2rc-2 or above. |
378 | - if getattr(markdown, "version_info", None) < (1,7): |
379 | + if getattr(markdown, "version_info", None) < (1, 7): |
380 | return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) |
381 | else: |
382 | return mark_safe(markdown.markdown(force_unicode(value), extensions, safe_mode=safe_mode)) |
383 | else: |
384 | return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) |
385 | |
386 | + |
387 | @register.filter |
388 | def restructuredtext(value): |
389 | try: |
390 | |
391 | === modified file 'loco_directory/common/templatetags/teams_tags.py' |
392 | --- loco_directory/common/templatetags/teams_tags.py 2011-06-19 13:55:34 +0000 |
393 | +++ loco_directory/common/templatetags/teams_tags.py 2012-06-30 22:09:18 +0000 |
394 | @@ -3,8 +3,9 @@ |
395 | |
396 | register = template.Library() |
397 | |
398 | + |
399 | def irc(nickname): |
400 | - """ |
401 | + """ |
402 | Replace dots with underscores |
403 | """ |
404 | return nickname.replace('.', '_') |
405 | |
406 | === modified file 'loco_directory/common/utils.py' |
407 | --- loco_directory/common/utils.py 2011-10-05 00:50:53 +0000 |
408 | +++ loco_directory/common/utils.py 2012-06-30 22:09:18 +0000 |
409 | @@ -6,6 +6,7 @@ |
410 | |
411 | from django.conf import settings |
412 | |
413 | + |
414 | def write_log(job_name, log): |
415 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') |
416 | log_file = os.path.join(stamp_dir, "%s.log" % job_name) |
417 | @@ -15,6 +16,7 @@ |
418 | f.write(log) |
419 | f.close() |
420 | |
421 | + |
422 | def run_job(which, interval, args=None): |
423 | stamp_dir = os.path.join(settings.PROJECT_PATH, 'data') |
424 | if not os.path.exists(stamp_dir): |
425 | @@ -24,7 +26,7 @@ |
426 | datetime.datetime.utcfromtimestamp(os.path.getmtime(stamp_file)) + interval < datetime.datetime.now(): |
427 | pwd = os.getcwd() |
428 | os.chdir(settings.PROJECT_PATH) |
429 | - p = subprocess.Popen(["python", "manage.py", which], stdout=subprocess.PIPE, |
430 | + p = subprocess.Popen(["python", "manage.py", which], stdout=subprocess.PIPE, |
431 | stderr=subprocess.STDOUT, close_fds=True) |
432 | log = p.stdout.read() |
433 | p.communicate() |
434 | @@ -33,6 +35,7 @@ |
435 | os.utime(stamp_file, None) |
436 | write_log(which, log) |
437 | |
438 | + |
439 | def flat_list(some_list): |
440 | """ |
441 | >>> reduce(lambda a,b: a.extend(b) or a, [[2,3],[6],[66,34]]) |
442 | @@ -40,9 +43,10 @@ |
443 | """ |
444 | if not some_list: |
445 | return [] |
446 | - return reduce(lambda a,b: a.extend(b) or a, some_list) |
447 | - |
448 | - |
449 | + return reduce(lambda a, b: a.extend(b) or a, some_list) |
450 | + |
451 | + |
452 | +# pylint: disable-msg=C0103 |
453 | def redirect(to, *args, **kwargs): |
454 | from distutils.version import LooseVersion as V |
455 | import django |
456 | @@ -62,10 +66,10 @@ |
457 | if not os.path.exists(version_file): |
458 | return "version unknown" |
459 | |
460 | - f = email.message_from_file(open(version_file)) |
461 | - version = f["version"] |
462 | - bzr_revno = f["revno"] |
463 | - |
464 | + emai_msg = email.message_from_file(open(version_file)) |
465 | + version = emai_msg["version"] |
466 | + bzr_revno = emai_msg["revno"] |
467 | + |
468 | if debug: |
469 | try: |
470 | from bzrlib.branch import Branch |
471 | @@ -76,6 +80,7 @@ |
472 | |
473 | return "version %s (rev %s)" % (version, bzr_revno) |
474 | |
475 | + |
476 | class simple_iterator(object): |
477 | |
478 | def __init__(self, *args): |
479 | @@ -85,7 +90,7 @@ |
480 | self.values.extend(deepcopy(args[0])) |
481 | else: |
482 | self.values.extend(deepcopy(args)) |
483 | - |
484 | + |
485 | def get_next_index(self): |
486 | if self.index + 1 >= len(self.values): |
487 | self.index = 0 |
488 | @@ -101,5 +106,3 @@ |
489 | def reset(self): |
490 | self.index = -1 |
491 | return '' |
492 | - |
493 | - |
494 | |
495 | === modified file 'loco_directory/common/views.py' |
496 | --- loco_directory/common/views.py 2011-10-11 14:03:43 +0000 |
497 | +++ loco_directory/common/views.py 2012-06-30 22:09:18 +0000 |
498 | @@ -13,6 +13,7 @@ |
499 | MissingUsernameViolation, |
500 | ) |
501 | except ImportError: |
502 | + # pylint: disable-msg=C0103 |
503 | MissingPhysicalMultiFactor = None |
504 | MissingUsernameViolation = None |
505 | |
506 | @@ -25,7 +26,7 @@ |
507 | team_meeting_count = TeamMeeting.objects.next_meetings().count() |
508 | global_event_list = GlobalEvent.objects.next_events()[:5] |
509 | articles = Article.objects.all()[:5] |
510 | - |
511 | + |
512 | context = {'team_event_count': team_event_count, |
513 | 'team_meeting_count': team_meeting_count, |
514 | 'global_event_list': global_event_list, |
515 | @@ -35,36 +36,43 @@ |
516 | return render_to_response('index.html', context, |
517 | RequestContext(request)) |
518 | |
519 | + |
520 | def loco_council(request): |
521 | context = {} |
522 | return render_to_response('loco_council.html', context, |
523 | RequestContext(request)) |
524 | |
525 | + |
526 | def about(request): |
527 | context = {} |
528 | return render_to_response('about.html', context, |
529 | RequestContext(request)) |
530 | |
531 | + |
532 | def about_loco(request): |
533 | context = {} |
534 | return render_to_response('about_loco.html', context, |
535 | RequestContext(request)) |
536 | |
537 | + |
538 | def loco_setup(request): |
539 | context = {} |
540 | return render_to_response('loco_setup.html', context, |
541 | RequestContext(request)) |
542 | |
543 | + |
544 | def irc_chat(request): |
545 | context = {} |
546 | return render_to_response('irc_chat.html', context, |
547 | RequestContext(request)) |
548 | - |
549 | + |
550 | + |
551 | def using_locodir(request): |
552 | context = {} |
553 | return render_to_response('using_locodir.html', context, |
554 | RequestContext(request)) |
555 | - |
556 | + |
557 | + |
558 | def site_logout(request): |
559 | logout(request) |
560 | return HttpResponseRedirect('/') |
561 | @@ -74,17 +82,19 @@ |
562 | """ |
563 | Change the language for a user |
564 | """ |
565 | - next = request.META.get('HTTP_REFERER', None) |
566 | - if not next: |
567 | - next = '/' |
568 | - response = HttpResponseRedirect(next) |
569 | + next_url = request.META.get('HTTP_REFERER', None) |
570 | + if not next_url: |
571 | + next_url = '/' |
572 | + response = HttpResponseRedirect(next_url) |
573 | lang = request.GET.get('lang', '') |
574 | if check_for_language(lang): |
575 | if hasattr(request, 'session'): |
576 | request.session['django_language'] = lang |
577 | - response.set_cookie(settings.LANGUAGE_COOKIE_NAME,lang) |
578 | + response.set_cookie(settings.LANGUAGE_COOKIE_NAME, lang) |
579 | return response |
580 | - |
581 | + |
582 | + |
583 | +# pylint: disable-msg=C0103 |
584 | def site_search(request): |
585 | from common.forms import SiteSearchForm |
586 | from common.utils import simple_iterator |
587 | @@ -110,17 +120,24 @@ |
588 | 'venues': venues, |
589 | 'meetings': meetings, |
590 | 'q': q, |
591 | - 'colcycle' : simple_iterator('col_left', 'col_right'), |
592 | + 'colcycle': simple_iterator('col_left', 'col_right'), |
593 | } |
594 | return render_to_response('site_search.html', context, |
595 | RequestContext(request)) |
596 | - |
597 | + |
598 | + |
599 | +# pylint: disable-msg=C0103 |
600 | def search_teams(q): |
601 | from teams.models import Team |
602 | from django.db.models import Q |
603 | - team_list = Team.objects.filter(Q(name__icontains=q) | Q(countries__name__icontains=q) | Q(city__icontains=q) | Q(languages__name__icontains=q)).order_by('name').distinct() |
604 | + team_list = Team.objects.filter(Q(name__icontains=q) | |
605 | + Q(countries__name__icontains=q) | |
606 | + Q(city__icontains=q) | |
607 | + Q(languages__name__icontains=q)).order_by('name').distinct() |
608 | return team_list |
609 | - |
610 | + |
611 | + |
612 | +# pylint: disable-msg=C0103 |
613 | def search_global_events(q): |
614 | from events.models import GlobalEvent |
615 | from django.db.models import Q |
616 | @@ -128,26 +145,43 @@ |
617 | global_event_list = global_event_list.filter(Q(name__icontains=q)).distinct() |
618 | return global_event_list |
619 | |
620 | + |
621 | +# pylint: disable-msg=C0103 |
622 | def search_team_events(q): |
623 | from events.models import TeamEvent |
624 | from django.db.models import Q |
625 | team_event_list = TeamEvent.objects.next_events() |
626 | - team_event_list = team_event_list.filter(Q(name__icontains=q) | Q(teams__name__icontains=q) | Q(venue__name__icontains=q) | Q(venue__city__icontains=q) | Q(venue__country__name__icontains=q) | Q(global_event__name__icontains=q)).distinct() |
627 | + team_event_list = team_event_list.filter(Q(name__icontains=q) | |
628 | + Q(teams__name__icontains=q) | |
629 | + Q(venue__name__icontains=q) | |
630 | + Q(venue__city__icontains=q) | |
631 | + Q(venue__country__name__icontains=q) | |
632 | + Q(global_event__name__icontains=q)).distinct() |
633 | return team_event_list |
634 | - |
635 | + |
636 | + |
637 | +# pylint: disable-msg=C0103 |
638 | def search_venues(q): |
639 | from venues.models import Venue |
640 | from django.db.models import Q |
641 | - venue_list = Venue.objects.filter(Q(name__icontains=q) | Q(country__name__icontains=q) | Q(city__icontains=q) | Q(address__icontains=q)).order_by('name').distinct() |
642 | + venue_list = Venue.objects.filter(Q(name__icontains=q) | |
643 | + Q(country__name__icontains=q) | |
644 | + Q(city__icontains=q) | |
645 | + Q(address__icontains=q)).order_by('name').distinct() |
646 | return venue_list |
647 | - |
648 | + |
649 | + |
650 | +# pylint: disable-msg=C0103 |
651 | def search_meetings(q): |
652 | from meetings.models import TeamMeeting |
653 | from django.db.models import Q |
654 | meeting_list = TeamMeeting.objects.next_meetings() |
655 | - meeting_list = meeting_list.filter(Q(name__icontains=q) | Q(teams__name__icontains=q) | Q(agenda__title__icontains=q)).distinct() |
656 | + meeting_list = meeting_list.filter(Q(name__icontains=q) | |
657 | + Q(teams__name__icontains=q) | |
658 | + Q(agenda__title__icontains=q)).distinct() |
659 | return meeting_list |
660 | - |
661 | + |
662 | + |
663 | def login_failure(request, message, status=403, |
664 | template_name='login_failure.html', |
665 | exception=None): |
666 | @@ -159,9 +193,10 @@ |
667 | if isinstance(exception, MissingPhysicalMultiFactor): |
668 | context['solution'] = 'Try logging in again using your Yubikey' |
669 | elif isinstance(exception, MissingUsernameViolation): |
670 | - context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use the LoCo Teams Directory' |
671 | + context['solution'] = 'You will need to create a ' \ |
672 | + '<a href="https://launchpad.net/people/+me">' \ |
673 | + 'Launchpad profile</a> to use the LoCo Teams Directory' |
674 | |
675 | data = render_to_string(template_name, context, |
676 | context_instance=RequestContext(request)) |
677 | return HttpResponse(data, status=status) |
678 | - |
679 | |
680 | === modified file 'loco_directory/common/widgets.py' |
681 | --- loco_directory/common/widgets.py 2010-07-29 12:05:20 +0000 |
682 | +++ loco_directory/common/widgets.py 2012-06-30 22:09:18 +0000 |
683 | @@ -7,6 +7,7 @@ |
684 | from django.utils.safestring import mark_safe |
685 | import copy |
686 | |
687 | + |
688 | class PopupRelatedFieldWidgetWrapper(forms.Widget): |
689 | """ |
690 | This class is a wrapper to a given widget to add the add icon for the |
691 | @@ -29,7 +30,7 @@ |
692 | |
693 | def _media(self): |
694 | wm = self.widget.media |
695 | - wm.add_js(['%sjs/admin/RelatedObjectLookups.js'%settings.ADMIN_MEDIA_PREFIX,]) |
696 | + wm.add_js(['%sjs/admin/RelatedObjectLookups.js' % settings.ADMIN_MEDIA_PREFIX, ]) |
697 | return wm |
698 | media = property(_media) |
699 | |
700 | @@ -55,4 +56,3 @@ |
701 | |
702 | def id_for_label(self, id_): |
703 | return self.widget.id_for_label(id_) |
704 | - |
Text conflict in loco_directory/ common/ launchpad. py