Merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.2 into lp:ubuntu-webcatalog
- law-and-order.2
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 135 | ||||
Merged at revision: | 135 | ||||
Proposed branch: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order.2 | ||||
Merge into: | lp:ubuntu-webcatalog | ||||
Prerequisite: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 | ||||
Diff against target: |
671 lines (+111/-103) 13 files modified
src/webcatalog/admin.py (+4/-4) src/webcatalog/auth.py (+18/-17) src/webcatalog/context_processors.py (+2/-1) src/webcatalog/department_filters.py (+9/-7) src/webcatalog/forms.py (+5/-5) src/webcatalog/hw.py (+12/-12) src/webcatalog/managers.py (+2/-2) src/webcatalog/preflight.py (+2/-2) src/webcatalog/schema.py (+5/-5) src/webcatalog/urls.py (+7/-7) src/webcatalog/utilities.py (+13/-12) src/webcatalog/views.py (+31/-28) src/webcatalog/wsgi.py (+1/-1) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.2 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Anthony Lenton (community) | Approve | ||
Review via email: mp+109002@code.launchpad.net |
Commit message
- Fixing pep8 issues (part 2 of LP: #1007626).
Description of the change
To post a comment you must log in.
Revision history for this message
ISD Branch Mangler (isd-branches-mangler) wrote : | # |
The prerequisite lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 has not yet been merged into lp:ubuntu-webcatalog.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/webcatalog/admin.py' |
2 | --- src/webcatalog/admin.py 2012-04-18 21:27:46 +0000 |
3 | +++ src/webcatalog/admin.py 2012-06-06 17:47:19 +0000 |
4 | @@ -20,7 +20,7 @@ |
5 | from __future__ import ( |
6 | absolute_import, |
7 | with_statement, |
8 | - ) |
9 | +) |
10 | from django.contrib import admin |
11 | from webcatalog.models import ( |
12 | Application, |
13 | @@ -29,18 +29,18 @@ |
14 | DistroSeries, |
15 | Exhibit, |
16 | Machine, |
17 | - ) |
18 | +) |
19 | |
20 | __metaclass__ = type |
21 | __all__ = [ |
22 | 'ApplicationAdmin', |
23 | 'MachineAdmin', |
24 | - ] |
25 | +] |
26 | |
27 | |
28 | class ApplicationAdmin(admin.ModelAdmin): |
29 | list_display = ('package_name', 'name', 'comment', 'distroseries', |
30 | - 'wilson_score') |
31 | + 'wilson_score') |
32 | search_fields = ('package_name', 'name', 'comment') |
33 | list_filter = ('distroseries', 'for_purchase', 'is_latest', 'departments') |
34 | exclude = ('for_purchase', 'archive_id') |
35 | |
36 | === modified file 'src/webcatalog/auth.py' |
37 | --- src/webcatalog/auth.py 2012-01-06 17:54:47 +0000 |
38 | +++ src/webcatalog/auth.py 2012-06-06 17:47:19 +0000 |
39 | @@ -23,7 +23,7 @@ |
40 | __metaclass__ = type |
41 | __all__ = [ |
42 | 'SSOOAuthAuthentication', |
43 | - ] |
44 | +] |
45 | |
46 | from datetime import datetime, timedelta |
47 | from django.conf import settings |
48 | @@ -39,8 +39,8 @@ |
49 | full_claimed_id, |
50 | ) |
51 | |
52 | -TOKEN_CACHE_EXPIRY = timedelta(hours=getattr(settings, |
53 | - 'TOKEN_CACHE_EXPIRY_HOURS', 4)) |
54 | +TOKEN_CACHE_EXPIRY_HOURS = getattr(settings, 'TOKEN_CACHE_EXPIRY_HOURS', 4) |
55 | +TOKEN_CACHE_EXPIRY = timedelta(hours=TOKEN_CACHE_EXPIRY_HOURS) |
56 | |
57 | |
58 | class SSOOAuthAuthentication(OAuthAuthentication): |
59 | @@ -71,8 +71,8 @@ |
60 | request.method, request.build_absolute_uri(), headers=headers, |
61 | query_string=request.META['QUERY_STRING']) |
62 | if (orequest is None or |
63 | - not 'oauth_token' in orequest.parameters or |
64 | - not 'oauth_consumer_key' in orequest.parameters): |
65 | + not 'oauth_token' in orequest.parameters or |
66 | + not 'oauth_consumer_key' in orequest.parameters): |
67 | return False |
68 | |
69 | self.prefetch_oauth_consumer(orequest) |
70 | @@ -95,11 +95,11 @@ |
71 | oauthtoken = request.get_parameter('oauth_token') |
72 | consumer_key = request.get_parameter('oauth_consumer_key') |
73 | tokens = Token.objects.filter(token=oauthtoken, |
74 | - consumer__key=consumer_key) |
75 | - if len(tokens) == 0 or (tokens[0].updated_at < |
76 | - datetime.now() - TOKEN_CACHE_EXPIRY): |
77 | - pieces = web_services.get_data_for_account(token=oauthtoken, |
78 | - openid_identifier=consumer_key, |
79 | + consumer__key=consumer_key) |
80 | + if (len(tokens) == 0 or |
81 | + tokens[0].updated_at < datetime.now() - TOKEN_CACHE_EXPIRY): |
82 | + pieces = web_services.get_data_for_account( |
83 | + token=oauthtoken, openid_identifier=consumer_key, |
84 | signature=request.get_parameter('oauth_signature')) |
85 | if not pieces: |
86 | return |
87 | @@ -111,10 +111,11 @@ |
88 | useropenid__claimed_id=claimed_id) |
89 | except User.DoesNotExist: |
90 | if (not pieces.get('preferred_email') or |
91 | - not pieces.get('username')): |
92 | + not pieces.get('username')): |
93 | return |
94 | user = User.objects.create_user(pieces['username'], |
95 | - pieces['preferred_email'], password=None) |
96 | + pieces['preferred_email'], |
97 | + password=None) |
98 | user.useropenid_set.create(claimed_id=claimed_id) |
99 | |
100 | displayname = pieces['displayname'] |
101 | @@ -123,11 +124,11 @@ |
102 | ' ') |
103 | user.save() |
104 | |
105 | - consumer, created = Consumer.objects.get_or_create(user=user, |
106 | - key=consumer_key, secret=pieces['consumer_secret']) |
107 | - token, created = Token.objects.get_or_create(consumer=consumer, |
108 | - token=pieces['token'], token_secret=pieces['token_secret'], |
109 | - name=pieces['name']) |
110 | + consumer, created = Consumer.objects.get_or_create( |
111 | + user=user, key=consumer_key, secret=pieces['consumer_secret']) |
112 | + token, created = Token.objects.get_or_create( |
113 | + consumer=consumer, token=pieces['token'], |
114 | + token_secret=pieces['token_secret'], name=pieces['name']) |
115 | if not created: |
116 | # Update updated_at |
117 | token.save() |
118 | |
119 | === modified file 'src/webcatalog/context_processors.py' |
120 | --- src/webcatalog/context_processors.py 2012-04-19 14:27:02 +0000 |
121 | +++ src/webcatalog/context_processors.py 2012-06-06 17:47:19 +0000 |
122 | @@ -31,4 +31,5 @@ |
123 | num_recommended_apps=settings.NUM_RECOMMENDED_APPS, |
124 | google_analytics_id=getattr(settings, 'GOOGLE_ANALYTICS_ID', None), |
125 | secondary_google_analytics_id=getattr(settings, |
126 | - 'SECONDARY_GOOGLE_ANALYTICS_ID', None)) |
127 | + 'SECONDARY_GOOGLE_ANALYTICS_ID', |
128 | + None)) |
129 | |
130 | === modified file 'src/webcatalog/department_filters.py' |
131 | --- src/webcatalog/department_filters.py 2012-01-06 17:54:47 +0000 |
132 | +++ src/webcatalog/department_filters.py 2012-06-06 17:47:19 +0000 |
133 | @@ -20,7 +20,7 @@ |
134 | from __future__ import ( |
135 | absolute_import, |
136 | with_statement, |
137 | - ) |
138 | +) |
139 | |
140 | import re |
141 | |
142 | @@ -29,7 +29,7 @@ |
143 | __metaclass__ = type |
144 | __all__ = [ |
145 | 'department_filters', |
146 | - ] |
147 | +] |
148 | |
149 | |
150 | def category_filter(categories_set): |
151 | @@ -79,24 +79,26 @@ |
152 | 'Web Browsers': [category_filter(set(['WebBrowser']))], |
153 | 'Office': [category_filter(set(['Office']))], |
154 | 'Science & Engineering': [category_filter(set(['Science'])), |
155 | - section_filter(['science'])], |
156 | + section_filter(['science'])], |
157 | 'Astronomy': [category_filter(set(['Astronomy']))], |
158 | 'Biology': [category_filter(set(['Biology']))], |
159 | 'Chemistry': [category_filter(set(['Chemistry']))], |
160 | 'Computing & Robotics': [category_filter(set(['ArtificialIntelligence', |
161 | - 'ComputerScience', 'Robotics']))], |
162 | + 'ComputerScience', |
163 | + 'Robotics']))], |
164 | 'Electronics': [category_filter(set(['Electronics']))], |
165 | 'Engineering': [category_filter(set(['Engineering']))], |
166 | 'Geography': [category_filter(set(['Geography']))], |
167 | 'Geology': [category_filter(set(['Geology', 'Geoscience']))], |
168 | 'Mathematics': [category_filter(set(['DataVisualization', 'Math', |
169 | - 'NumericalAnalysis'])), section_filter(['math', 'gnu-r'])], |
170 | + 'NumericalAnalysis'])), |
171 | + section_filter(['math', 'gnu-r'])], |
172 | 'Physics': [category_filter(set(['Electricity', 'Physics']))], |
173 | 'Sound & Video': [category_filter(set(['AudioVideo', 'Audio', 'Video']))], |
174 | 'Themes & Tweaks': [category_filter(set(['Settings']))], |
175 | 'Universal Access': [category_filter(set(['Accessibility']))], |
176 | 'Developer Tools': [category_filter(set(['Development'])), |
177 | - section_filter(['devel'])], |
178 | + section_filter(['devel'])], |
179 | 'Debugging': [category_filter(set(['Debugger']))], |
180 | 'Graphic Interface Design': [category_filter(set(['GUIDesigner']))], |
181 | 'Haskell': [section_filter(['haskell'])], |
182 | @@ -112,6 +114,6 @@ |
183 | 'Python': [section_filter(['python'])], |
184 | 'Ruby': [section_filter(['ruby'])], |
185 | 'Version Control': [category_filter(set(['RevisionControl'])), |
186 | - section_filter(['vcs'])], |
187 | + section_filter(['vcs'])], |
188 | 'Web Development': [category_filter(set(['WebDevelopment']))], |
189 | } |
190 | |
191 | === modified file 'src/webcatalog/forms.py' |
192 | --- src/webcatalog/forms.py 2012-05-25 07:42:30 +0000 |
193 | +++ src/webcatalog/forms.py 2012-06-06 17:47:19 +0000 |
194 | @@ -20,7 +20,7 @@ |
195 | from __future__ import ( |
196 | absolute_import, |
197 | with_statement, |
198 | - ) |
199 | +) |
200 | |
201 | import apt |
202 | import json |
203 | @@ -40,7 +40,7 @@ |
204 | __all__ = [ |
205 | 'ApplicationForm', |
206 | 'desktop_field_mappings', |
207 | - ] |
208 | +] |
209 | |
210 | desktop_field_mappings = { |
211 | 'x-appinstall-package': 'package_name', |
212 | @@ -53,7 +53,7 @@ |
213 | 'x-appinstall-section': 'section', |
214 | 'type': 'app_type', |
215 | 'icon': 'icon_name', |
216 | - } |
217 | +} |
218 | |
219 | |
220 | class ApplicationForm(forms.ModelForm): |
221 | @@ -143,7 +143,7 @@ |
222 | app_data['description'] = description |
223 | if 'debtags' in app_data and app_data['debtags']: |
224 | app_data['debtags'] = json.dumps([get_hw_short_description(x) |
225 | - for x in app_data['debtags']]) |
226 | + for x in app_data['debtags']]) |
227 | app_data['application_id'] = app_data.get('id') |
228 | |
229 | try: |
230 | @@ -195,7 +195,7 @@ |
231 | text = render_to_string('webcatalog/email_download_link.txt', |
232 | context) |
233 | sender = ("Ubuntu Application Directory <%s>" % |
234 | - settings.NOREPLY_FROM_ADDRESS) |
235 | + settings.NOREPLY_FROM_ADDRESS) |
236 | recipient = [self.cleaned_data['email']] |
237 | message = EmailMultiAlternatives(subject, text, sender, recipient) |
238 | message.attach_alternative(html, 'text/html') |
239 | |
240 | === modified file 'src/webcatalog/hw.py' |
241 | --- src/webcatalog/hw.py 2012-03-26 17:28:23 +0000 |
242 | +++ src/webcatalog/hw.py 2012-06-06 17:47:19 +0000 |
243 | @@ -48,32 +48,32 @@ |
244 | 'hardware::digicam': _('This software requires a digital camera, but none ' |
245 | 'are currently connected'), |
246 | 'hardware::webcam': _('This software requires a video camera, but none ' |
247 | - 'are currently connected'), |
248 | + 'are currently connected'), |
249 | 'hardware::input:mouse': _('This software requires a mouse, ' |
250 | - 'but none is currently setup.'), |
251 | + 'but none is currently setup.'), |
252 | 'hardware::input:joystick': _('This software requires a joystick, ' |
253 | - 'but none are currently connected.'), |
254 | + 'but none are currently connected.'), |
255 | 'hardware::input:touchscreen': _('This software requires a touchscreen, ' |
256 | - 'but the computer does not have one.'), |
257 | + 'but the computer does not have one.'), |
258 | 'hardware::gps': _('This software requires a GPS, ' |
259 | - 'but the computer does not have one.'), |
260 | + 'but the computer does not have one.'), |
261 | 'hardware::laptop': _('This software is for notebook computers.'), |
262 | 'hardware::printer': _('This software requires a printer, but none ' |
263 | 'are currently set up.'), |
264 | 'hardware::scanner': _('This software requires a scanner, but none are ' |
265 | - 'currently set up.'), |
266 | + 'currently set up.'), |
267 | 'hardware::stoarge:cd': _('This software requires a CD drive, but none ' |
268 | - 'are currently connected.'), |
269 | + 'are currently connected.'), |
270 | 'hardware::storage:cd-writer': _('This software requires a CD burner, ' |
271 | - 'but none are currently connected.'), |
272 | + 'but none are currently connected.'), |
273 | 'hardware::storage:dvd': _('This software requires a DVD drive, but none ' |
274 | - 'are currently connected.'), |
275 | + 'are currently connected.'), |
276 | 'hardware::storage:dvd-writer': _('This software requires a DVD burner, ' |
277 | - 'but none are currently connected.'), |
278 | + 'but none are currently connected.'), |
279 | 'hardware::storage:floppy': _('This software requires a floppy disk ' |
280 | - 'drive, but none are currently connected.'), |
281 | + 'drive, but none are currently connected.'), |
282 | 'hardware::video:opengl': _('This computer does not have graphics fast ' |
283 | - 'enough for this software.'), |
284 | + 'enough for this software.'), |
285 | # private extension |
286 | OPENGL_DRIVER_BLACKLIST_TAG: _(u'This software does not work with the ' |
287 | u'\u201c%s\u201D graphics driver this ' |
288 | |
289 | === modified file 'src/webcatalog/managers.py' |
290 | --- src/webcatalog/managers.py 2012-03-16 01:42:36 +0000 |
291 | +++ src/webcatalog/managers.py 2012-06-06 17:47:19 +0000 |
292 | @@ -20,13 +20,13 @@ |
293 | from __future__ import ( |
294 | absolute_import, |
295 | with_statement, |
296 | - ) |
297 | +) |
298 | |
299 | |
300 | __metaclass__ = type |
301 | __all__ = [ |
302 | 'ApplicationManager', |
303 | - ] |
304 | +] |
305 | |
306 | from django.db import models |
307 | from django.http import Http404 |
308 | |
309 | === modified file 'src/webcatalog/preflight.py' |
310 | --- src/webcatalog/preflight.py 2012-05-31 20:29:23 +0000 |
311 | +++ src/webcatalog/preflight.py 2012-06-06 17:47:19 +0000 |
312 | @@ -20,7 +20,7 @@ |
313 | from __future__ import ( |
314 | absolute_import, |
315 | with_statement, |
316 | - ) |
317 | +) |
318 | |
319 | from django import db |
320 | from django.conf import settings |
321 | @@ -34,7 +34,7 @@ |
322 | __metaclass__ = type |
323 | __all__ = [ |
324 | 'WebcatalogPreflight' |
325 | - ] |
326 | +] |
327 | |
328 | |
329 | class WebcatalogPreflight(Preflight): |
330 | |
331 | === modified file 'src/webcatalog/schema.py' |
332 | --- src/webcatalog/schema.py 2012-06-04 10:54:02 +0000 |
333 | +++ src/webcatalog/schema.py 2012-06-06 17:47:19 +0000 |
334 | @@ -34,7 +34,7 @@ |
335 | |
336 | class oops(schema.Section): |
337 | oops_dir = schema.StringOption(help='Absolute path to the directory' |
338 | - ' oops reports will be stored in') |
339 | + ' oops reports will be stored in') |
340 | |
341 | class openid(schema.Section): |
342 | openid_sso_server_url = schema.StringOption() |
343 | @@ -56,13 +56,13 @@ |
344 | oauth_data_store = schema.StringOption( |
345 | default='webcatalog.models.oauthtoken.DataStore') |
346 | convoy_root = schema.StringOption() |
347 | - featured_apps = schema.ListOption(item=schema.StringOption(), |
348 | - default=[]) |
349 | + featured_apps = schema.ListOption( |
350 | + item=schema.StringOption(), default=[]) |
351 | number_top_rated_apps = schema.IntOption(default=8) |
352 | screenshots_base_url = schema.StringOption( |
353 | default='http://screenshots.ubuntu.com/') |
354 | - hib_apps = schema.ListOption(item=schema.StringOption(), |
355 | - default=[]) |
356 | + hib_apps = schema.ListOption( |
357 | + item=schema.StringOption(), default=[]) |
358 | ubuntu_series_for_versions = schema.DictOption( |
359 | item=schema.StringOption()) |
360 | |
361 | |
362 | === modified file 'src/webcatalog/urls.py' |
363 | --- src/webcatalog/urls.py 2012-05-07 13:43:04 +0000 |
364 | +++ src/webcatalog/urls.py 2012-06-06 17:47:19 +0000 |
365 | @@ -20,17 +20,18 @@ |
366 | from __future__ import ( |
367 | absolute_import, |
368 | with_statement, |
369 | - ) |
370 | +) |
371 | from django.conf.urls.defaults import patterns, include, url |
372 | from django.views.generic import TemplateView |
373 | |
374 | __metaclass__ = type |
375 | __all__ = [ |
376 | 'urlpatterns', |
377 | - ] |
378 | - |
379 | - |
380 | -urlpatterns = patterns('webcatalog.views', |
381 | +] |
382 | + |
383 | + |
384 | +urlpatterns = patterns( |
385 | + 'webcatalog.views', |
386 | url(r'^$', 'index', name='wc-index'), |
387 | url(r'^department/(?P<distro>[-.+\w]+)/(?P<dept_slug_or_id>[\w\d-]+)/$', |
388 | 'department_overview', name='wc-department'), |
389 | @@ -45,8 +46,7 @@ |
390 | url(r'^applications/(?P<package_name>[-.+:\w]+)/$', 'application_detail', |
391 | name="wc-package-detail"), |
392 | url(r'^applications/(?P<distro>[-.+\w]+)/(?P<package_name>[-.+:\w]+)/' |
393 | - r'reviews/$', |
394 | - 'application_reviews', name="wc-package-reviews"), |
395 | + r'reviews/$', 'application_reviews', name="wc-package-reviews"), |
396 | url(r'^applications/(?P<distro>[-.+\w]+)/(?P<package_name>[-.+:\w]+)/' |
397 | r'reviews-ajax/$', 'application_reviews', kwargs={'ajax': True}, |
398 | name="wc-package-reviews-ajax"), |
399 | |
400 | === modified file 'src/webcatalog/utilities.py' |
401 | --- src/webcatalog/utilities.py 2012-06-04 10:55:44 +0000 |
402 | +++ src/webcatalog/utilities.py 2012-06-06 17:47:19 +0000 |
403 | @@ -26,7 +26,7 @@ |
404 | 'UserAgentString', |
405 | 'WebServices', |
406 | 'WebServiceError', |
407 | - ] |
408 | +] |
409 | |
410 | import json |
411 | import logging |
412 | @@ -41,7 +41,7 @@ |
413 | from piston_mini_client.auth import ( |
414 | BasicAuthorizer, |
415 | OAuthAuthorizer, |
416 | - ) |
417 | +) |
418 | from piston_mini_client.failhandlers import APIError |
419 | from piston_mini_client.validators import ValidationException |
420 | from rnrclient import RatingsAndReviewsAPI |
421 | @@ -61,9 +61,10 @@ |
422 | |
423 | @property |
424 | def identity_provider(self): |
425 | - return SingleSignOnAPI(service_root=settings.SSO_API_SERVICE_ROOT, |
426 | - auth=BasicAuthorizer(settings.SSO_API_AUTH_USERNAME, |
427 | - settings.SSO_API_AUTH_PASSWORD)) |
428 | + auth = BasicAuthorizer(settings.SSO_API_AUTH_USERNAME, |
429 | + settings.SSO_API_AUTH_PASSWORD) |
430 | + return SingleSignOnAPI( |
431 | + service_root=settings.SSO_API_SERVICE_ROOT, auth=auth) |
432 | |
433 | @property |
434 | def rnr_api(self): |
435 | @@ -77,8 +78,8 @@ |
436 | return cached_reviews |
437 | |
438 | try: |
439 | - fresh_reviews = self.rnr_api.get_reviews(packagename=package_name, |
440 | - distroseries=distroseries, page=page) |
441 | + fresh_reviews = self.rnr_api.get_reviews( |
442 | + packagename=package_name, distroseries=distroseries, page=page) |
443 | except (ValidationException, APIError): |
444 | fresh_reviews = [] |
445 | cache.set(key, fresh_reviews, settings.REVIEWS_CACHE_TIMEOUT) |
446 | @@ -112,7 +113,7 @@ |
447 | if response.getcode() == 200: |
448 | data = json.loads(response.read()) |
449 | fresh_screenshots = [entry['large_image_url'] |
450 | - for entry in data.get('screenshots', [])] |
451 | + for entry in data.get('screenshots', [])] |
452 | except (IOError, ValueError, TypeError): |
453 | pass |
454 | cache.set(key, fresh_screenshots, settings.REVIEWS_CACHE_TIMEOUT) |
455 | @@ -150,12 +151,12 @@ |
456 | token=token, consumer_key=openid_identifier) |
457 | |
458 | if result: |
459 | - authorizer = OAuthAuthorizer(token_key=result['token'], |
460 | - token_secret=result['token_secret'], |
461 | + authorizer = OAuthAuthorizer( |
462 | + token_key=result['token'], token_secret=result['token_secret'], |
463 | consumer_key=result['consumer_key'], |
464 | consumer_secret=result['consumer_secret']) |
465 | api = SingleSignOnAPI(service_root=settings.SSO_API_SERVICE_ROOT, |
466 | - auth=authorizer) |
467 | + auth=authorizer) |
468 | me = api.me() |
469 | data = { |
470 | 'displayname': me.displayname, |
471 | @@ -176,7 +177,7 @@ |
472 | |
473 | def full_claimed_id(consumer_key): |
474 | return '%s/+id/%s' % (settings.OPENID_SSO_SERVER_URL.strip('/'), |
475 | - consumer_key) |
476 | + consumer_key) |
477 | |
478 | |
479 | class UserAgentString(object): |
480 | |
481 | === modified file 'src/webcatalog/views.py' |
482 | --- src/webcatalog/views.py 2012-06-06 12:54:15 +0000 |
483 | +++ src/webcatalog/views.py 2012-06-06 17:47:19 +0000 |
484 | @@ -20,7 +20,7 @@ |
485 | from __future__ import ( |
486 | absolute_import, |
487 | with_statement, |
488 | - ) |
489 | +) |
490 | |
491 | import json |
492 | import operator |
493 | @@ -35,12 +35,12 @@ |
494 | from django.http import ( |
495 | HttpResponseRedirect, |
496 | HttpResponse, |
497 | - ) |
498 | +) |
499 | from django.shortcuts import ( |
500 | get_list_or_404, |
501 | get_object_or_404, |
502 | render_to_response, |
503 | - ) |
504 | +) |
505 | from django.template import RequestContext |
506 | from django.utils.translation import ugettext as _ |
507 | |
508 | @@ -50,7 +50,7 @@ |
509 | Department, |
510 | DistroSeries, |
511 | Exhibit, |
512 | - ) |
513 | +) |
514 | from webcatalog.utilities import WebServices |
515 | |
516 | |
517 | @@ -62,7 +62,7 @@ |
518 | 'index', |
519 | 'department_overview', |
520 | 'search', |
521 | - ] |
522 | +] |
523 | |
524 | |
525 | def _get_page_num_from_request(request, paginator): |
526 | @@ -91,9 +91,10 @@ |
527 | apps = Application.objects.filter(is_latest=True) |
528 | apps = apps.filter(reduce(operator.or_, ors)).order_by('name') |
529 | |
530 | - crumbs = [{'name': 'All Apps', 'url': reverse('wc-index')}, |
531 | - {'name': 'Search results', 'url': request.build_absolute_uri()}, |
532 | - ] |
533 | + crumbs = [ |
534 | + {'name': 'All Apps', 'url': reverse('wc-index')}, |
535 | + {'name': 'Search results', 'url': request.build_absolute_uri()}, |
536 | + ] |
537 | |
538 | paginator = Paginator(apps, settings.PAGE_BATCH_SIZE) |
539 | page_num = _get_page_num_from_request(request, paginator) |
540 | @@ -104,16 +105,15 @@ |
541 | 'breadcrumbs': crumbs, |
542 | 'available_distroseries': DistroSeries.objects.order_by('-code_name'), |
543 | 'distroseries': distro, |
544 | - }) |
545 | + }) |
546 | return render_to_response('webcatalog/search_results.html', |
547 | - context_instance=context) |
548 | + context_instance=context) |
549 | |
550 | |
551 | def index(request): |
552 | depts = Department.objects.filter(parent=None).order_by('name') |
553 | - depts = depts.order_by('name') |
554 | - exhibits = list(Exhibit.objects.filter(Q(display=True) | |
555 | - Q(display=None, published=True,)).order_by('weight')) |
556 | + qs = Q(display=True) | Q(display=None, published=True,) |
557 | + exhibits = list(Exhibit.objects.filter(qs).order_by('weight')) |
558 | featured_apps = [Application.objects.find_best(package_name=app) |
559 | for app in settings.FEATURED_APPS] |
560 | featured_apps = [x for x in featured_apps if x] |
561 | @@ -138,7 +138,7 @@ |
562 | 'top_rated_apps': top_rated, |
563 | }) |
564 | return render_to_response('webcatalog/index.html', |
565 | - context_instance=context) |
566 | + context_instance=context) |
567 | |
568 | |
569 | def department_overview(request, dept_slug_or_id=None, distro=None): |
570 | @@ -159,15 +159,16 @@ |
571 | paginator = Paginator(apps, settings.PAGE_BATCH_SIZE) |
572 | page_num = _get_page_num_from_request(request, paginator) |
573 | |
574 | - context = RequestContext(request, dict={'dept': dept, |
575 | + context = { |
576 | + 'dept': dept, |
577 | 'subdepts': subdepts, |
578 | 'page': paginator.page(page_num), |
579 | 'breadcrumbs': dept.crumbs(), |
580 | 'available_distroseries': DistroSeries.objects.order_by('-code_name'), |
581 | 'distroseries': distro, |
582 | - }) |
583 | + } |
584 | return render_to_response('webcatalog/department_overview.html', |
585 | - context_instance=context) |
586 | + context_instance=RequestContext(request, context)) |
587 | |
588 | |
589 | def application_list(request): |
590 | @@ -185,9 +186,10 @@ |
591 | |
592 | depts = Department.objects.filter(parent=None).order_by('name') |
593 | |
594 | + context = RequestContext(request, |
595 | + dict(applications=applications, depts=depts)) |
596 | return render_to_response('webcatalog/application_list.html', |
597 | - context_instance=RequestContext(request, |
598 | - dict(applications=applications, depts=depts))) |
599 | + context_instance=context) |
600 | |
601 | |
602 | def application_detail(request, package_name, distro=None): |
603 | @@ -212,7 +214,8 @@ |
604 | |
605 | hib_apps = getattr(settings, 'HIB_APPS', []) |
606 | |
607 | - atts = {'application': app, |
608 | + atts = { |
609 | + 'application': app, |
610 | 'available_distroseries': app.available_distroseries(), |
611 | 'breadcrumbs': app.crumbs(), |
612 | 'distroseries': distro, |
613 | @@ -221,7 +224,7 @@ |
614 | 'email_form': form, |
615 | 'debtags': debtags, |
616 | 'display_hib_widget': app.package_name in hib_apps |
617 | - } |
618 | + } |
619 | |
620 | return render_to_response( |
621 | 'webcatalog/application_detail.html', RequestContext( |
622 | @@ -235,12 +238,12 @@ |
623 | # unity-lens-utilities, probably via a myapps PPA as well as extras?). |
624 | # Don't break when this happens. |
625 | apps = get_list_or_404(Application, package_name=package_name, |
626 | - distroseries__code_name=distro) |
627 | + distroseries__code_name=distro) |
628 | app = apps[0] |
629 | |
630 | # XXX michaeln 2011-09-15 bug=851662 Better review language options. |
631 | - reviews = WebServices().get_reviews_for_package(package_name, |
632 | - distroseries=distro, page=page) |
633 | + reviews = WebServices().get_reviews_for_package( |
634 | + package_name, distroseries=distro, page=page) |
635 | |
636 | context = dict(application=app, reviews=reviews) |
637 | if ajax: |
638 | @@ -277,8 +280,7 @@ |
639 | def application_screenshots(request, package_name): |
640 | app = Application.objects.find_best_or_404(package_name=package_name) |
641 | screenshots = WebServices().get_screenshots_for_package(package_name) |
642 | - return HttpResponse(json.dumps(screenshots), |
643 | - mimetype='application/json') |
644 | + return HttpResponse(json.dumps(screenshots), mimetype='application/json') |
645 | |
646 | |
647 | def combo_view(request): |
648 | @@ -291,8 +293,9 @@ |
649 | content_type = "text/javascript" |
650 | elif fnames[0].endswith(".css"): |
651 | content_type = "text/css" |
652 | - content = combine_files(fnames, os.path.abspath(settings.CONVOY_ROOT), |
653 | - resource_prefix=settings.MEDIA_URL, rewrite_urls=True) |
654 | + content = combine_files( |
655 | + fnames, os.path.abspath(settings.CONVOY_ROOT), |
656 | + resource_prefix=settings.MEDIA_URL, rewrite_urls=True) |
657 | # We're turning the generator returned by combine_files into a string |
658 | # here since GZipMiddleware would consume it if not. See Bug #822888. |
659 | return HttpResponse( |
660 | |
661 | === modified file 'src/webcatalog/wsgi.py' |
662 | --- src/webcatalog/wsgi.py 2012-03-30 13:22:36 +0000 |
663 | +++ src/webcatalog/wsgi.py 2012-06-06 17:47:19 +0000 |
664 | @@ -37,6 +37,6 @@ |
665 | logging.config.fileConfig(settings.WEBAPP_LOGGING_CONFIG) |
666 | oops_dir = getattr(settings, 'OOPS_DIR', '/tmp') |
667 | oops_app = OopsWare(WSGIHandler(), oops_dir=oops_dir, |
668 | - key=appserver_id, hide_meta=True) |
669 | + key=appserver_id, hide_meta=True) |
670 | oops_app.serial = OOPSRFC822Serializer(appserver_id, oops_dir, None) |
671 | return oops_app |
Looks good, thanks!