Merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 into lp:ubuntu-webcatalog
- law-and-order.1
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Natalia Bidart | ||||
Approved revision: | 134 | ||||
Merged at revision: | 134 | ||||
Proposed branch: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 | ||||
Merge into: | lp:ubuntu-webcatalog | ||||
Prerequisite: | lp:~nataliabidart/ubuntu-webcatalog/law-and-order | ||||
Diff against target: |
511 lines (+78/-72) 13 files modified
src/webcatalog/api/forms.py (+2/-2) src/webcatalog/api/handlers.py (+1/-1) src/webcatalog/api/urls.py (+5/-4) src/webcatalog/management/commands/check_all_latest.py (+4/-4) src/webcatalog/management/commands/cleanup.py (+6/-4) src/webcatalog/management/commands/import_app_install_data.py (+21/-18) src/webcatalog/management/commands/import_exhibits.py (+5/-5) src/webcatalog/management/commands/import_for_purchase_apps.py (+2/-3) src/webcatalog/management/commands/import_ratings_stats.py (+3/-3) src/webcatalog/middleware/exception.py (+3/-3) src/webcatalog/models/applications.py (+19/-17) src/webcatalog/models/oauthtoken.py (+4/-5) src/webcatalog/templatetags/webcatalog.py (+3/-3) |
||||
To merge this branch: | bzr merge lp:~nataliabidart/ubuntu-webcatalog/law-and-order.1 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Anthony Lenton (community) | Approve | ||
Review via email: mp+108993@code.launchpad.net |
Commit message
- Fixing pep8 issues (part 1 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 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/api/forms.py' | |||
2 | --- src/webcatalog/api/forms.py 2012-01-06 17:54:47 +0000 | |||
3 | +++ src/webcatalog/api/forms.py 2012-06-06 16:45:24 +0000 | |||
4 | @@ -36,7 +36,7 @@ | |||
5 | 36 | fields = ( | 36 | fields = ( |
6 | 37 | 'hostname', | 37 | 'hostname', |
7 | 38 | 'logo_checksum', | 38 | 'logo_checksum', |
9 | 39 | ) | 39 | ) |
10 | 40 | 40 | ||
11 | 41 | 41 | ||
12 | 42 | class MachineUpdatePackagesForm(forms.ModelForm): | 42 | class MachineUpdatePackagesForm(forms.ModelForm): |
13 | @@ -45,4 +45,4 @@ | |||
14 | 45 | fields = ( | 45 | fields = ( |
15 | 46 | 'packages_checksum', | 46 | 'packages_checksum', |
16 | 47 | 'package_list', | 47 | 'package_list', |
18 | 48 | ) | 48 | ) |
19 | 49 | 49 | ||
20 | === modified file 'src/webcatalog/api/handlers.py' | |||
21 | --- src/webcatalog/api/handlers.py 2012-03-23 20:14:03 +0000 | |||
22 | +++ src/webcatalog/api/handlers.py 2012-06-06 16:45:24 +0000 | |||
23 | @@ -28,7 +28,7 @@ | |||
24 | 28 | HttpResponse, | 28 | HttpResponse, |
25 | 29 | HttpResponseBadRequest, | 29 | HttpResponseBadRequest, |
26 | 30 | HttpResponseNotFound, | 30 | HttpResponseNotFound, |
28 | 31 | ) | 31 | ) |
29 | 32 | from piston.handler import BaseHandler | 32 | from piston.handler import BaseHandler |
30 | 33 | 33 | ||
31 | 34 | from webcatalog.models import Machine | 34 | from webcatalog.models import Machine |
32 | 35 | 35 | ||
33 | === modified file 'src/webcatalog/api/urls.py' | |||
34 | --- src/webcatalog/api/urls.py 2012-04-18 22:29:29 +0000 | |||
35 | +++ src/webcatalog/api/urls.py 2012-06-06 16:45:24 +0000 | |||
36 | @@ -37,13 +37,14 @@ | |||
37 | 37 | 37 | ||
38 | 38 | server_status_resource = never_cache(Resource(handler=ServerStatusHandler)) | 38 | server_status_resource = never_cache(Resource(handler=ServerStatusHandler)) |
39 | 39 | list_machines_resource = never_cache(Resource(handler=ListMachinesHandler, | 39 | list_machines_resource = never_cache(Resource(handler=ListMachinesHandler, |
41 | 40 | authentication=auth)) | 40 | authentication=auth)) |
42 | 41 | machine_resource = never_cache(CSRFExemptResource(handler=MachineHandler, | 41 | machine_resource = never_cache(CSRFExemptResource(handler=MachineHandler, |
44 | 42 | authentication=auth)) | 42 | authentication=auth)) |
45 | 43 | packages_resource = never_cache(CSRFExemptResource(handler=PackagesHandler, | 43 | packages_resource = never_cache(CSRFExemptResource(handler=PackagesHandler, |
47 | 44 | authentication=auth)) | 44 | authentication=auth)) |
48 | 45 | 45 | ||
50 | 46 | urlpatterns = patterns('', | 46 | urlpatterns = patterns( |
51 | 47 | '', | ||
52 | 47 | # get status of the service (usually just "ok", might be "read-only") | 48 | # get status of the service (usually just "ok", might be "read-only") |
53 | 48 | # to ensure we inform the user when he wants to write a review or | 49 | # to ensure we inform the user when he wants to write a review or |
54 | 49 | # send a moderation request | 50 | # send a moderation request |
55 | 50 | 51 | ||
56 | === modified file 'src/webcatalog/management/commands/check_all_latest.py' | |||
57 | --- src/webcatalog/management/commands/check_all_latest.py 2012-03-16 04:25:10 +0000 | |||
58 | +++ src/webcatalog/management/commands/check_all_latest.py 2012-06-06 16:45:24 +0000 | |||
59 | @@ -19,7 +19,7 @@ | |||
60 | 19 | 19 | ||
61 | 20 | from __future__ import ( | 20 | from __future__ import ( |
62 | 21 | absolute_import, | 21 | absolute_import, |
64 | 22 | ) | 22 | ) |
65 | 23 | 23 | ||
66 | 24 | from django.core.management.base import BaseCommand | 24 | from django.core.management.base import BaseCommand |
67 | 25 | 25 | ||
68 | @@ -28,7 +28,7 @@ | |||
69 | 28 | __metaclass__ = type | 28 | __metaclass__ = type |
70 | 29 | __all__ = [ | 29 | __all__ = [ |
71 | 30 | 'Command', | 30 | 'Command', |
73 | 31 | ] | 31 | ] |
74 | 32 | 32 | ||
75 | 33 | BATCH_SIZE = 200 | 33 | BATCH_SIZE = 200 |
76 | 34 | 34 | ||
77 | @@ -48,8 +48,8 @@ | |||
78 | 48 | Application.objects.all().update(is_latest=False) | 48 | Application.objects.all().update(is_latest=False) |
79 | 49 | 49 | ||
80 | 50 | # 2. Update is_latest in batches of BATCH_SIZE. | 50 | # 2. Update is_latest in batches of BATCH_SIZE. |
83 | 51 | packages = Application.objects.values_list('id', | 51 | packages = Application.objects.values_list('id', 'package_name') |
84 | 52 | 'package_name').order_by('package_name', '-distroseries__version') | 52 | packages = packages.order_by('package_name', '-distroseries__version') |
85 | 53 | current_package_name = None | 53 | current_package_name = None |
86 | 54 | to_update = [] | 54 | to_update = [] |
87 | 55 | for app_id, app_package_name in packages: | 55 | for app_id, app_package_name in packages: |
88 | 56 | 56 | ||
89 | === modified file 'src/webcatalog/management/commands/cleanup.py' | |||
90 | --- src/webcatalog/management/commands/cleanup.py 2012-04-17 16:56:44 +0000 | |||
91 | +++ src/webcatalog/management/commands/cleanup.py 2012-06-06 16:45:24 +0000 | |||
92 | @@ -106,13 +106,15 @@ | |||
93 | 106 | help = "Cleans the Django session and OAuth nonce tables." | 106 | help = "Cleans the Django session and OAuth nonce tables." |
94 | 107 | 107 | ||
95 | 108 | option_list = LabelCommand.option_list + ( | 108 | option_list = LabelCommand.option_list + ( |
97 | 109 | make_option('--cursor-life', default=3600, dest="cursor_secs", | 109 | make_option( |
98 | 110 | '--cursor-life', default=3600, dest="cursor_secs", | ||
99 | 110 | action='store', | 111 | action='store', |
100 | 111 | help="Hold a cursor open a maximum of SECS seconds"), | 112 | help="Hold a cursor open a maximum of SECS seconds"), |
102 | 112 | make_option('--batch-time', default=5, dest="batch_secs", | 113 | make_option( |
103 | 114 | '--batch-time', default=5, dest="batch_secs", | ||
104 | 113 | action="store", | 115 | action="store", |
105 | 114 | help="Try to keep batch removal transaction time to SECS seconds"), | 116 | help="Try to keep batch removal transaction time to SECS seconds"), |
107 | 115 | ) | 117 | ) |
108 | 116 | 118 | ||
109 | 117 | def handle_label(self, table, **options): | 119 | def handle_label(self, table, **options): |
110 | 118 | if not psycopg2_available: | 120 | if not psycopg2_available: |
111 | @@ -124,7 +126,7 @@ | |||
112 | 124 | cleaner_cls = CLEANERS.get(table, None) | 126 | cleaner_cls = CLEANERS.get(table, None) |
113 | 125 | if cleaner_cls is None: | 127 | if cleaner_cls is None: |
114 | 126 | msg = ("Invalid cleaner.\nNo cleaner found for table: %s\n" | 128 | msg = ("Invalid cleaner.\nNo cleaner found for table: %s\n" |
116 | 127 | "Supported tables are: %s" % (table, CLEANERS.keys())) | 129 | "Supported tables are: %s" % (table, CLEANERS.keys())) |
117 | 128 | raise CommandError(msg) | 130 | raise CommandError(msg) |
118 | 129 | cleaner = cleaner_cls() | 131 | cleaner = cleaner_cls() |
119 | 130 | connection.isolation_level = ISOLATION_LEVEL_AUTOCOMMIT | 132 | connection.isolation_level = ISOLATION_LEVEL_AUTOCOMMIT |
120 | 131 | 133 | ||
121 | === modified file 'src/webcatalog/management/commands/import_app_install_data.py' | |||
122 | --- src/webcatalog/management/commands/import_app_install_data.py 2012-05-09 15:31:34 +0000 | |||
123 | +++ src/webcatalog/management/commands/import_app_install_data.py 2012-06-06 16:45:24 +0000 | |||
124 | @@ -20,7 +20,7 @@ | |||
125 | 20 | from __future__ import ( | 20 | from __future__ import ( |
126 | 21 | absolute_import, | 21 | absolute_import, |
127 | 22 | with_statement, | 22 | with_statement, |
129 | 23 | ) | 23 | ) |
130 | 24 | 24 | ||
131 | 25 | import os | 25 | import os |
132 | 26 | import re | 26 | import re |
133 | @@ -43,12 +43,11 @@ | |||
134 | 43 | from webcatalog.models import ( | 43 | from webcatalog.models import ( |
135 | 44 | Application, | 44 | Application, |
136 | 45 | DistroSeries, | 45 | DistroSeries, |
138 | 46 | ) | 46 | ) |
139 | 47 | from webcatalog.utilities import create_png_from_file | 47 | from webcatalog.utilities import create_png_from_file |
140 | 48 | 48 | ||
141 | 49 | __metaclass__ = type | 49 | __metaclass__ = type |
144 | 50 | __all__ = [ | 50 | __all__ = [] |
143 | 51 | ] | ||
145 | 52 | 51 | ||
146 | 53 | 52 | ||
147 | 54 | class CacheMaker(object): | 53 | class CacheMaker(object): |
148 | @@ -97,21 +96,23 @@ | |||
149 | 97 | class Command(LabelCommand): | 96 | class Command(LabelCommand): |
150 | 98 | 97 | ||
151 | 99 | help = ("Update Application data from apt cache and " | 98 | help = ("Update Application data from apt cache and " |
153 | 100 | "app-install-data(-partner) packages.") | 99 | "app-install-data(-partner) packages.") |
154 | 101 | option_list = LabelCommand.option_list + ( | 100 | option_list = LabelCommand.option_list + ( |
156 | 102 | make_option('--local-app-install-data', | 101 | make_option( |
157 | 102 | '--local-app-install-data', | ||
158 | 103 | action='store', | 103 | action='store', |
159 | 104 | dest='local_app_install_data', | 104 | dest='local_app_install_data', |
160 | 105 | default='', | 105 | default='', |
161 | 106 | help=('Use a local app-install-data deb package rather than ' | 106 | help=('Use a local app-install-data deb package rather than ' |
162 | 107 | 'downloading from the archive.')), | 107 | 'downloading from the archive.')), |
164 | 108 | make_option('--local-app-install-data-partner', | 108 | make_option( |
165 | 109 | '--local-app-install-data-partner', | ||
166 | 109 | action='store', | 110 | action='store', |
167 | 110 | dest='local_app_install_data_partner', | 111 | dest='local_app_install_data_partner', |
168 | 111 | default='', | 112 | default='', |
169 | 112 | help=('Use a local app-install-data-partner deb package rather ' | 113 | help=('Use a local app-install-data-partner deb package rather ' |
170 | 113 | 'than downloading from the archive.')), | 114 | 'than downloading from the archive.')), |
172 | 114 | ) | 115 | ) |
173 | 115 | verbosity = 1 | 116 | verbosity = 1 |
174 | 116 | 117 | ||
175 | 117 | def set_cache(self, distroseries): | 118 | def set_cache(self, distroseries): |
176 | @@ -141,12 +142,12 @@ | |||
177 | 141 | self.update_from_app_data(package, distroseries, deb_location) | 142 | self.update_from_app_data(package, distroseries, deb_location) |
178 | 142 | 143 | ||
179 | 143 | def update_from_app_data(self, package_name, distroseries, | 144 | def update_from_app_data(self, package_name, distroseries, |
181 | 144 | deb_location=''): | 145 | deb_location=''): |
182 | 145 | data_dir = tempfile.mkdtemp() | 146 | data_dir = tempfile.mkdtemp() |
183 | 146 | # Download app install data if necessary | 147 | # Download app install data if necessary |
184 | 147 | if deb_location == '': | 148 | if deb_location == '': |
187 | 148 | deb_location = self.get_package_data_for_series(package_name, | 149 | deb_location = self.get_package_data_for_series( |
188 | 149 | distroseries.code_name, data_dir) | 150 | package_name, distroseries.code_name, data_dir) |
189 | 150 | 151 | ||
190 | 151 | # Extract and parse the deb archive. | 152 | # Extract and parse the deb archive. |
191 | 152 | deb_file = DebFile(deb_location) | 153 | deb_file = DebFile(deb_location) |
192 | @@ -166,7 +167,7 @@ | |||
193 | 166 | shutil.rmtree(data_dir) | 167 | shutil.rmtree(data_dir) |
194 | 167 | 168 | ||
195 | 168 | def get_package_data_for_series(self, package_name, distroseries, | 169 | def get_package_data_for_series(self, package_name, distroseries, |
197 | 169 | working_dir): | 170 | working_dir): |
198 | 170 | install_data_url = self.get_package_uri_for_series( | 171 | install_data_url = self.get_package_uri_for_series( |
199 | 171 | package_name, distroseries) | 172 | package_name, distroseries) |
200 | 172 | rest, sep, deb_filename = install_data_url.rpartition('/') | 173 | rest, sep, deb_filename = install_data_url.rpartition('/') |
201 | @@ -180,7 +181,7 @@ | |||
202 | 180 | 181 | ||
203 | 181 | def get_package_uri_for_series(self, package_name, distroseries): | 182 | def get_package_uri_for_series(self, package_name, distroseries): |
204 | 182 | self.output("Determining URI for current version of " | 183 | self.output("Determining URI for current version of " |
206 | 183 | "{0} in {1}.\n".format(package_name, distroseries), 1) | 184 | "{0} in {1}.\n".format(package_name, distroseries), 1) |
207 | 184 | self.set_cache(distroseries) | 185 | self.set_cache(distroseries) |
208 | 185 | return self.cache[package_name].candidate.uri | 186 | return self.cache[package_name].candidate.uri |
209 | 186 | 187 | ||
210 | @@ -267,10 +268,11 @@ | |||
211 | 267 | distroseries, created = DistroSeries.objects.get_or_create( | 268 | distroseries, created = DistroSeries.objects.get_or_create( |
212 | 268 | code_name=distroseries_name) | 269 | code_name=distroseries_name) |
213 | 269 | if created: | 270 | if created: |
216 | 270 | self.output("Created a DistroSeries record called '{0}'.\n".format( | 271 | msg = "Created a DistroSeries record called '{0}'.\n" |
217 | 271 | distroseries_name), 1) | 272 | self.output(msg.format(distroseries_name), 1) |
218 | 272 | 273 | ||
220 | 273 | prefetched_apps = dict((app.package_name, app) for app in | 274 | prefetched_apps = dict( |
221 | 275 | (app.package_name, app) for app in | ||
222 | 274 | Application.objects.filter(distroseries=distroseries)) | 276 | Application.objects.filter(distroseries=distroseries)) |
223 | 275 | 277 | ||
224 | 276 | self.set_cache(distroseries_name) | 278 | self.set_cache(distroseries_name) |
225 | @@ -297,7 +299,8 @@ | |||
226 | 297 | for attribute, value in [ | 299 | for attribute, value in [ |
227 | 298 | ('description', candidate.description), | 300 | ('description', candidate.description), |
228 | 299 | ('section', candidate.section), ('version', version), | 301 | ('section', candidate.section), ('version', version), |
230 | 300 | ('name', app_name), ('comment', app_comment)]: | 302 | ('name', app_name), ('comment', app_comment), |
231 | 303 | ]: | ||
232 | 301 | if getattr(app, attribute) != value: | 304 | if getattr(app, attribute) != value: |
233 | 302 | setattr(app, attribute, value) | 305 | setattr(app, attribute, value) |
234 | 303 | updated = True | 306 | updated = True |
235 | @@ -312,7 +315,7 @@ | |||
236 | 312 | name=app_name, | 315 | name=app_name, |
237 | 313 | version=version, | 316 | version=version, |
238 | 314 | comment=app_comment, | 317 | comment=app_comment, |
240 | 315 | ) | 318 | ) |
241 | 316 | 319 | ||
242 | 317 | screenshot_url = package.candidateRecord.get('Screenshot-Url') | 320 | screenshot_url = package.candidateRecord.get('Screenshot-Url') |
243 | 318 | if screenshot_url is not None and ( | 321 | if screenshot_url is not None and ( |
244 | 319 | 322 | ||
245 | === modified file 'src/webcatalog/management/commands/import_exhibits.py' | |||
246 | --- src/webcatalog/management/commands/import_exhibits.py 2012-04-13 20:49:20 +0000 | |||
247 | +++ src/webcatalog/management/commands/import_exhibits.py 2012-06-06 16:45:24 +0000 | |||
248 | @@ -19,7 +19,7 @@ | |||
249 | 19 | 19 | ||
250 | 20 | from __future__ import ( | 20 | from __future__ import ( |
251 | 21 | absolute_import, | 21 | absolute_import, |
253 | 22 | ) | 22 | ) |
254 | 23 | 23 | ||
255 | 24 | import json | 24 | import json |
256 | 25 | import urllib | 25 | import urllib |
257 | @@ -31,12 +31,12 @@ | |||
258 | 31 | from webcatalog.models import ( | 31 | from webcatalog.models import ( |
259 | 32 | DistroSeries, | 32 | DistroSeries, |
260 | 33 | Exhibit, | 33 | Exhibit, |
262 | 34 | ) | 34 | ) |
263 | 35 | 35 | ||
264 | 36 | __metaclass__ = type | 36 | __metaclass__ = type |
265 | 37 | __all__ = [ | 37 | __all__ = [ |
266 | 38 | 'Command', | 38 | 'Command', |
268 | 39 | ] | 39 | ] |
269 | 40 | 40 | ||
270 | 41 | 41 | ||
271 | 42 | class Command(BaseCommand): | 42 | class Command(BaseCommand): |
272 | @@ -71,7 +71,7 @@ | |||
273 | 71 | Exhibit.objects.filter(pk=instance.pk).update(**args) | 71 | Exhibit.objects.filter(pk=instance.pk).update(**args) |
274 | 72 | 72 | ||
275 | 73 | distroseries = [DistroSeries.objects.get_or_create(**ds)[0] | 73 | distroseries = [DistroSeries.objects.get_or_create(**ds)[0] |
277 | 74 | for ds in exhibit.get('distroseries', [])] | 74 | for ds in exhibit.get('distroseries', [])] |
278 | 75 | 75 | ||
279 | 76 | to_remove = instance.distroseries.exclude( | 76 | to_remove = instance.distroseries.exclude( |
280 | 77 | pk__in=[x.id for x in distroseries]) | 77 | pk__in=[x.id for x in distroseries]) |
281 | @@ -81,4 +81,4 @@ | |||
282 | 81 | # Unpublish other exhibits | 81 | # Unpublish other exhibits |
283 | 82 | Exhibit.objects.filter(published=True).exclude( | 82 | Exhibit.objects.filter(published=True).exclude( |
284 | 83 | sca_id__in=[xibit['id'] for xibit in exhibits]).update( | 83 | sca_id__in=[xibit['id'] for xibit in exhibits]).update( |
286 | 84 | published=False) | 84 | published=False) |
287 | 85 | 85 | ||
288 | === modified file 'src/webcatalog/management/commands/import_for_purchase_apps.py' | |||
289 | --- src/webcatalog/management/commands/import_for_purchase_apps.py 2012-05-02 14:58:15 +0000 | |||
290 | +++ src/webcatalog/management/commands/import_for_purchase_apps.py 2012-06-06 16:45:24 +0000 | |||
291 | @@ -22,7 +22,7 @@ | |||
292 | 22 | from __future__ import ( | 22 | from __future__ import ( |
293 | 23 | absolute_import, | 23 | absolute_import, |
294 | 24 | with_statement, | 24 | with_statement, |
296 | 25 | ) | 25 | ) |
297 | 26 | 26 | ||
298 | 27 | import json | 27 | import json |
299 | 28 | import os | 28 | import os |
300 | @@ -41,8 +41,7 @@ | |||
301 | 41 | ) | 41 | ) |
302 | 42 | 42 | ||
303 | 43 | __metaclass__ = type | 43 | __metaclass__ = type |
306 | 44 | __all__ = [ | 44 | __all__ = [] |
305 | 45 | ] | ||
307 | 46 | 45 | ||
308 | 47 | 46 | ||
309 | 48 | class Command(BaseCommand): | 47 | class Command(BaseCommand): |
310 | 49 | 48 | ||
311 | === modified file 'src/webcatalog/management/commands/import_ratings_stats.py' | |||
312 | --- src/webcatalog/management/commands/import_ratings_stats.py 2012-03-20 22:23:31 +0000 | |||
313 | +++ src/webcatalog/management/commands/import_ratings_stats.py 2012-06-06 16:45:24 +0000 | |||
314 | @@ -20,7 +20,7 @@ | |||
315 | 20 | from datetime import ( | 20 | from datetime import ( |
316 | 21 | datetime, | 21 | datetime, |
317 | 22 | timedelta, | 22 | timedelta, |
319 | 23 | ) | 23 | ) |
320 | 24 | import json | 24 | import json |
321 | 25 | 25 | ||
322 | 26 | from django.core.management.base import LabelCommand | 26 | from django.core.management.base import LabelCommand |
323 | @@ -29,11 +29,11 @@ | |||
324 | 29 | Application, | 29 | Application, |
325 | 30 | DistroSeries, | 30 | DistroSeries, |
326 | 31 | ReviewStatsImport, | 31 | ReviewStatsImport, |
328 | 32 | ) | 32 | ) |
329 | 33 | from webcatalog.utilities import ( | 33 | from webcatalog.utilities import ( |
330 | 34 | dampened_rating, | 34 | dampened_rating, |
331 | 35 | WebServices, | 35 | WebServices, |
333 | 36 | ) | 36 | ) |
334 | 37 | 37 | ||
335 | 38 | 38 | ||
336 | 39 | class Command(LabelCommand): | 39 | class Command(LabelCommand): |
337 | 40 | 40 | ||
338 | === modified file 'src/webcatalog/middleware/exception.py' | |||
339 | --- src/webcatalog/middleware/exception.py 2011-09-12 13:58:47 +0000 | |||
340 | +++ src/webcatalog/middleware/exception.py 2012-06-06 16:45:24 +0000 | |||
341 | @@ -55,9 +55,9 @@ | |||
342 | 55 | lineno = tb.tb_lineno - 1 | 55 | lineno = tb.tb_lineno - 1 |
343 | 56 | loader = tb.tb_frame.f_globals.get('__loader__') | 56 | loader = tb.tb_frame.f_globals.get('__loader__') |
344 | 57 | module_name = tb.tb_frame.f_globals.get('__name__') | 57 | module_name = tb.tb_frame.f_globals.get('__name__') |
348 | 58 | pre_context_lineno, pre_context, context_line, post_context = \ | 58 | lines = self._get_lines_from_file( |
349 | 59 | self._get_lines_from_file(filename, lineno, 7, loader, | 59 | filename, lineno, 7, loader, module_name) |
350 | 60 | module_name) | 60 | pre_context_lineno, pre_context, context_line, post_context = lines |
351 | 61 | if pre_context_lineno is not None: | 61 | if pre_context_lineno is not None: |
352 | 62 | frames.append({ | 62 | frames.append({ |
353 | 63 | 'tb': tb, | 63 | 'tb': tb, |
354 | 64 | 64 | ||
355 | === modified file 'src/webcatalog/models/applications.py' | |||
356 | --- src/webcatalog/models/applications.py 2012-06-06 16:45:24 +0000 | |||
357 | +++ src/webcatalog/models/applications.py 2012-06-06 16:45:24 +0000 | |||
358 | @@ -20,7 +20,7 @@ | |||
359 | 20 | from __future__ import ( | 20 | from __future__ import ( |
360 | 21 | absolute_import, | 21 | absolute_import, |
361 | 22 | with_statement, | 22 | with_statement, |
363 | 23 | ) | 23 | ) |
364 | 24 | 24 | ||
365 | 25 | import logging | 25 | import logging |
366 | 26 | from datetime import datetime | 26 | from datetime import datetime |
367 | @@ -43,7 +43,7 @@ | |||
368 | 43 | 'Exhibit', | 43 | 'Exhibit', |
369 | 44 | 'Machine', | 44 | 'Machine', |
370 | 45 | 'ReviewStatsImport', | 45 | 'ReviewStatsImport', |
372 | 46 | ] | 46 | ] |
373 | 47 | 47 | ||
374 | 48 | 48 | ||
375 | 49 | class DistroSeries(models.Model): | 49 | class DistroSeries(models.Model): |
376 | @@ -82,18 +82,19 @@ | |||
377 | 82 | categories = models.CharField(max_length=255, blank=True) | 82 | categories = models.CharField(max_length=255, blank=True) |
378 | 83 | departments = models.ManyToManyField('Department', blank=True) | 83 | departments = models.ManyToManyField('Department', blank=True) |
379 | 84 | icon_name = models.CharField(max_length=255, blank=True) | 84 | icon_name = models.CharField(max_length=255, blank=True) |
382 | 85 | icon = models.ImageField(upload_to='icons/%Y/%m', max_length=200, | 85 | icon = models.ImageField( |
383 | 86 | null=True, blank=True) | 86 | upload_to='icons/%Y/%m', max_length=200, null=True, blank=True) |
384 | 87 | for_purchase = models.BooleanField(default=False) | 87 | for_purchase = models.BooleanField(default=False) |
388 | 88 | archive_id = models.CharField(max_length=64, null=True, | 88 | archive_id = models.CharField( |
389 | 89 | db_index=True, blank=True) | 89 | max_length=64, null=True, db_index=True, blank=True) |
390 | 90 | price = models.DecimalField(max_digits=7, decimal_places=2, null=True, | 90 | price = models.DecimalField( |
391 | 91 | max_digits=7, decimal_places=2, null=True, | ||
392 | 91 | blank=True, help_text="For-purchase applications (in US Dollars).") | 92 | blank=True, help_text="For-purchase applications (in US Dollars).") |
393 | 92 | application_id = models.IntegerField(null=True, blank=True) | 93 | application_id = models.IntegerField(null=True, blank=True) |
394 | 93 | 94 | ||
395 | 94 | ratings_total = models.IntegerField(null=True, blank=True) | 95 | ratings_total = models.IntegerField(null=True, blank=True) |
398 | 95 | ratings_average = models.DecimalField(max_digits=3, decimal_places=2, | 96 | ratings_average = models.DecimalField( |
399 | 96 | null=True, blank=True) | 97 | max_digits=3, decimal_places=2, null=True, blank=True) |
400 | 97 | ratings_histogram = models.CharField(max_length=128, blank=True) | 98 | ratings_histogram = models.CharField(max_length=128, blank=True) |
401 | 98 | is_latest = models.BooleanField() | 99 | is_latest = models.BooleanField() |
402 | 99 | wilson_score = models.FloatField(null=True, blank=True, db_index=True) | 100 | wilson_score = models.FloatField(null=True, blank=True, db_index=True) |
403 | @@ -154,7 +155,7 @@ | |||
404 | 154 | name=dept_name, defaults={'slug': slugify(dept_name)}) | 155 | name=dept_name, defaults={'slug': slugify(dept_name)}) |
405 | 155 | if created: | 156 | if created: |
406 | 156 | logging.warn("Department %s automatically created!" % | 157 | logging.warn("Department %s automatically created!" % |
408 | 157 | dept_name) | 158 | dept_name) |
409 | 158 | self.departments.add(dept) | 159 | self.departments.add(dept) |
410 | 159 | break | 160 | break |
411 | 160 | 161 | ||
412 | @@ -164,8 +165,9 @@ | |||
413 | 164 | crumbs = depts[0].crumbs(distro=self.distroseries.code_name) | 165 | crumbs = depts[0].crumbs(distro=self.distroseries.code_name) |
414 | 165 | else: | 166 | else: |
415 | 166 | crumbs = [{'name': 'All Apps', 'url': reverse('wc-index')}] | 167 | crumbs = [{'name': 'All Apps', 'url': reverse('wc-index')}] |
418 | 167 | crumbs.append({'name': self.name, 'url': reverse('wc-package-detail', | 168 | url = reverse('wc-package-detail', |
419 | 168 | args=[self.distroseries.code_name, self.package_name])}) | 169 | args=[self.distroseries.code_name, self.package_name]) |
420 | 170 | crumbs.append({'name': self.name, 'url': url}) | ||
421 | 169 | return crumbs | 171 | return crumbs |
422 | 170 | 172 | ||
423 | 171 | def license_type(self): | 173 | def license_type(self): |
424 | @@ -198,7 +200,7 @@ | |||
425 | 198 | ('icon_128', 'Icon 128x128'), | 200 | ('icon_128', 'Icon 128x128'), |
426 | 199 | ('screenshot', 'Screenshot'), | 201 | ('screenshot', 'Screenshot'), |
427 | 200 | ('video', 'Video'), | 202 | ('video', 'Video'), |
429 | 201 | ) | 203 | ) |
430 | 202 | 204 | ||
431 | 203 | application = models.ForeignKey(Application) | 205 | application = models.ForeignKey(Application) |
432 | 204 | media_type = models.CharField(max_length=16, choices=MEDIA_CHOICES) | 206 | media_type = models.CharField(max_length=16, choices=MEDIA_CHOICES) |
433 | @@ -268,7 +270,7 @@ | |||
434 | 268 | published = models.BooleanField() | 270 | published = models.BooleanField() |
435 | 269 | display = models.NullBooleanField( | 271 | display = models.NullBooleanField( |
436 | 270 | help_text="Yes: Always display. No: Never display. " | 272 | help_text="Yes: Always display. No: Never display. " |
438 | 271 | "Unknown: Display if published") | 273 | "Unknown: Display if published") |
439 | 272 | weight = models.IntegerField(default=0) | 274 | weight = models.IntegerField(default=0) |
440 | 273 | 275 | ||
441 | 274 | class Meta: | 276 | class Meta: |
442 | @@ -281,7 +283,7 @@ | |||
443 | 281 | if not pkg_name: | 283 | if not pkg_name: |
444 | 282 | return '' | 284 | return '' |
445 | 283 | return reverse('wc-package-detail', | 285 | return reverse('wc-package-detail', |
447 | 284 | kwargs={'package_name': pkg_name}) | 286 | kwargs={'package_name': pkg_name}) |
448 | 285 | 287 | ||
451 | 286 | return reverse('wc-package-list') + '?' + '&'.join( | 288 | pkgs = '&'.join('pkg_name=%s' % pkg_name for pkg_name in pkg_names) |
452 | 287 | ['pkg_name=%s' % pkg_name for pkg_name in pkg_names]) | 289 | return reverse('wc-package-list') + '?' + pkgs |
453 | 288 | 290 | ||
454 | === modified file 'src/webcatalog/models/oauthtoken.py' | |||
455 | --- src/webcatalog/models/oauthtoken.py 2012-01-06 17:54:47 +0000 | |||
456 | +++ src/webcatalog/models/oauthtoken.py 2012-06-06 16:45:24 +0000 | |||
457 | @@ -24,7 +24,7 @@ | |||
458 | 24 | 'Consumer', | 24 | 'Consumer', |
459 | 25 | 'Nonce', | 25 | 'Nonce', |
460 | 26 | 'DataStore', | 26 | 'DataStore', |
462 | 27 | ] | 27 | ] |
463 | 28 | 28 | ||
464 | 29 | import os.path | 29 | import os.path |
465 | 30 | import random | 30 | import random |
466 | @@ -45,9 +45,7 @@ | |||
467 | 45 | 45 | ||
468 | 46 | 46 | ||
469 | 47 | def _set_seed(): | 47 | def _set_seed(): |
473 | 48 | if (not hasattr(_set_seed, 'seed') and | 48 | if (not hasattr(_set_seed, 'seed') and os.path.exists("/dev/random")): |
471 | 49 | os.path.exists("/dev/random")): | ||
472 | 50 | |||
474 | 51 | data = open("/dev/random").read(struct.calcsize('Q')) | 49 | data = open("/dev/random").read(struct.calcsize('Q')) |
475 | 52 | random.seed(struct.unpack('Q', data)) | 50 | random.seed(struct.unpack('Q', data)) |
476 | 53 | _set_seed.seed = True | 51 | _set_seed.seed = True |
477 | @@ -92,7 +90,8 @@ | |||
478 | 92 | 90 | ||
479 | 93 | key = models.CharField(max_length=64) | 91 | key = models.CharField(max_length=64) |
480 | 94 | 92 | ||
482 | 95 | secret = models.CharField(max_length=255, blank=True, null=False, | 93 | secret = models.CharField( |
483 | 94 | max_length=255, blank=True, null=False, | ||
484 | 96 | default=partial(generate_random_string, CONSUMER_SECRET_LENGTH)) | 95 | default=partial(generate_random_string, CONSUMER_SECRET_LENGTH)) |
485 | 97 | 96 | ||
486 | 98 | created_at = models.DateTimeField(auto_now_add=True) | 97 | created_at = models.DateTimeField(auto_now_add=True) |
487 | 99 | 98 | ||
488 | === modified file 'src/webcatalog/templatetags/webcatalog.py' | |||
489 | --- src/webcatalog/templatetags/webcatalog.py 2012-03-12 20:14:34 +0000 | |||
490 | +++ src/webcatalog/templatetags/webcatalog.py 2012-06-06 16:45:24 +0000 | |||
491 | @@ -20,12 +20,12 @@ | |||
492 | 20 | from __future__ import ( | 20 | from __future__ import ( |
493 | 21 | absolute_import, | 21 | absolute_import, |
494 | 22 | with_statement, | 22 | with_statement, |
496 | 23 | ) | 23 | ) |
497 | 24 | 24 | ||
498 | 25 | __metaclass__ = type | 25 | __metaclass__ = type |
499 | 26 | __all__ = [ | 26 | __all__ = [ |
500 | 27 | 'install_options', | 27 | 'install_options', |
502 | 28 | ] | 28 | ] |
503 | 29 | 29 | ||
504 | 30 | import string | 30 | import string |
505 | 31 | 31 | ||
506 | @@ -198,4 +198,4 @@ | |||
507 | 198 | stars.append(0) | 198 | stars.append(0) |
508 | 199 | 199 | ||
509 | 200 | return dict(stars=stars, total=num_ratings, | 200 | return dict(stars=stars, total=num_ratings, |
511 | 201 | STATIC_URL=settings.STATIC_URL, size=size) | 201 | STATIC_URL=settings.STATIC_URL, size=size) |
+1