Merge lp:~cjohnston/summit/flake8-common into lp:summit
- flake8-common
- Merge into trunk
Proposed by
Chris Johnston
Status: | Needs review |
---|---|
Proposed branch: | lp:~cjohnston/summit/flake8-common |
Merge into: | lp:summit |
Diff against target: |
426 lines (+124/-53) 11 files modified
summit/common/admin/menuadmin.py (+3/-1) summit/common/context_processors.py (+0/-3) summit/common/forms.py (+8/-3) summit/common/launchpad.py (+4/-1) summit/common/management/commands/release.py (+2/-0) summit/common/models.py (+17/-7) summit/common/templatetags/menubuilder.py (+37/-9) summit/common/templatetags/qrcode.py (+37/-20) summit/common/utils.py (+3/-1) summit/common/views.py (+12/-5) summit/common/widgets.py (+1/-3) |
To merge this branch: | bzr merge lp:~cjohnston/summit/flake8-common |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Summit Hackers | Pending | ||
Review via email: mp+173496@code.launchpad.net |
Commit message
Just some flake8 fixes for summit
Description of the change
To post a comment you must log in.
Unmerged revisions
- 555. By Chris Johnston <email address hidden>
-
Flake8 fixes for common
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'summit/common/admin/menuadmin.py' | |||
2 | --- summit/common/admin/menuadmin.py 2012-03-08 01:45:05 +0000 | |||
3 | +++ summit/common/admin/menuadmin.py 2013-07-08 13:28:38 +0000 | |||
4 | @@ -1,10 +1,12 @@ | |||
5 | 1 | from django.contrib import admin | 1 | from django.contrib import admin |
6 | 2 | from common.models import Menu, MenuItem | 2 | from common.models import Menu, MenuItem |
7 | 3 | 3 | ||
8 | 4 | |||
9 | 4 | class MenuItemInline(admin.TabularInline): | 5 | class MenuItemInline(admin.TabularInline): |
10 | 5 | model = MenuItem | 6 | model = MenuItem |
11 | 6 | 7 | ||
12 | 8 | |||
13 | 7 | class MenuAdmin(admin.ModelAdmin): | 9 | class MenuAdmin(admin.ModelAdmin): |
15 | 8 | inlines = [MenuItemInline,] | 10 | inlines = [MenuItemInline, ] |
16 | 9 | 11 | ||
17 | 10 | admin.site.register(Menu, MenuAdmin) | 12 | admin.site.register(Menu, MenuAdmin) |
18 | 11 | 13 | ||
19 | === modified file 'summit/common/context_processors.py' | |||
20 | --- summit/common/context_processors.py 2013-03-07 01:48:40 +0000 | |||
21 | +++ summit/common/context_processors.py 2013-07-08 13:28:38 +0000 | |||
22 | @@ -14,9 +14,6 @@ | |||
23 | 14 | # You should have received a copy of the GNU Affero General Public License | 14 | # You should have received a copy of the GNU Affero General Public License |
24 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | 16 | 16 | ||
26 | 17 | # context processors for The Summit Scheduler | ||
27 | 18 | # see http://docs.djangoproject.com/en/dev/ref/settings/#setting-TEMPLATE_CONTEXT_PROCESSORS | ||
28 | 19 | |||
29 | 20 | from schedule.models.summitmodel import Summit | 17 | from schedule.models.summitmodel import Summit |
30 | 21 | 18 | ||
31 | 22 | from django.conf import settings | 19 | from django.conf import settings |
32 | 23 | 20 | ||
33 | === modified file 'summit/common/forms.py' | |||
34 | --- summit/common/forms.py 2012-01-25 19:47:36 +0000 | |||
35 | +++ summit/common/forms.py 2013-07-08 13:28:38 +0000 | |||
36 | @@ -1,13 +1,13 @@ | |||
37 | 1 | from django.template import Context, loader | 1 | from django.template import Context, loader |
38 | 2 | from django import forms | 2 | from django import forms |
40 | 3 | from django.utils.translation import ugettext as _ | 3 | |
41 | 4 | 4 | ||
42 | 5 | # Taken from http://djangosnippets.org/snippets/1732/ | 5 | # Taken from http://djangosnippets.org/snippets/1732/ |
43 | 6 | class RenderableMixin(object): | 6 | class RenderableMixin(object): |
44 | 7 | """ | 7 | """ |
45 | 8 | Mixin to render forms from a predefined template | 8 | Mixin to render forms from a predefined template |
46 | 9 | """ | 9 | """ |
48 | 10 | 10 | ||
49 | 11 | @property | 11 | @property |
50 | 12 | def form_class_name(self): | 12 | def form_class_name(self): |
51 | 13 | return '.'.join([self.__module__, self.__class__.__name__.lower()]) | 13 | return '.'.join([self.__module__, self.__class__.__name__.lower()]) |
52 | @@ -23,7 +23,12 @@ | |||
53 | 23 | 23 | ||
54 | 24 | context_dict = dict( | 24 | context_dict = dict( |
55 | 25 | non_field_errors=self.non_field_errors(), | 25 | non_field_errors=self.non_field_errors(), |
57 | 26 | fields=[ forms.forms.BoundField(self, field, name) for name, field in self.fields.iteritems()], | 26 | fields=[ |
58 | 27 | forms.forms.BoundField( | ||
59 | 28 | self, | ||
60 | 29 | field, | ||
61 | 30 | name, | ||
62 | 31 | ) for name, field in self.fields.iteritems()], | ||
63 | 27 | errors=self.errors, | 32 | errors=self.errors, |
64 | 28 | data=self.data, | 33 | data=self.data, |
65 | 29 | form=self, | 34 | form=self, |
66 | 30 | 35 | ||
67 | === modified file 'summit/common/launchpad.py' | |||
68 | --- summit/common/launchpad.py 2013-02-04 23:22:10 +0000 | |||
69 | +++ summit/common/launchpad.py 2013-07-08 13:28:38 +0000 | |||
70 | @@ -38,7 +38,10 @@ | |||
71 | 38 | html = f.read() | 38 | html = f.read() |
72 | 39 | services = OpenIDServiceEndpoint().fromHTML(url, html) | 39 | services = OpenIDServiceEndpoint().fromHTML(url, html) |
73 | 40 | if services is not None and len(services) > 0: | 40 | if services is not None and len(services) > 0: |
75 | 41 | services[0].local_id = services[0].local_id.replace('launchpad.net', 'ubuntu.com') | 41 | services[0].local_id = services[0].local_id.replace( |
76 | 42 | 'launchpad.net', | ||
77 | 43 | 'ubuntu.com', | ||
78 | 44 | ) | ||
79 | 42 | return services[0] | 45 | return services[0] |
80 | 43 | else: | 46 | else: |
81 | 44 | return None | 47 | return None |
82 | 45 | 48 | ||
83 | === modified file 'summit/common/management/commands/release.py' | |||
84 | --- summit/common/management/commands/release.py 2013-05-06 21:00:28 +0000 | |||
85 | +++ summit/common/management/commands/release.py 2013-07-08 13:28:38 +0000 | |||
86 | @@ -7,6 +7,7 @@ | |||
87 | 7 | import sys | 7 | import sys |
88 | 8 | import os | 8 | import os |
89 | 9 | 9 | ||
90 | 10 | |||
91 | 10 | def write_version_strings(version): | 11 | def write_version_strings(version): |
92 | 11 | try: | 12 | try: |
93 | 12 | from bzrlib.branch import Branch | 13 | from bzrlib.branch import Branch |
94 | @@ -25,6 +26,7 @@ | |||
95 | 25 | f.close() | 26 | f.close() |
96 | 26 | return (version, bzr_revno) | 27 | return (version, bzr_revno) |
97 | 27 | 28 | ||
98 | 29 | |||
99 | 28 | class Command(LabelCommand): | 30 | class Command(LabelCommand): |
100 | 29 | help = "Prepare release of The Summit Scheduler. Please pass <version> as an argument." | 31 | help = "Prepare release of The Summit Scheduler. Please pass <version> as an argument." |
101 | 30 | 32 | ||
102 | 31 | 33 | ||
103 | === modified file 'summit/common/models.py' | |||
104 | --- summit/common/models.py 2012-10-02 18:07:24 +0000 | |||
105 | +++ summit/common/models.py 2013-07-08 13:28:38 +0000 | |||
106 | @@ -3,6 +3,7 @@ | |||
107 | 3 | from django.contrib.sites.models import Site | 3 | from django.contrib.sites.models import Site |
108 | 4 | from django.contrib.sites.managers import CurrentSiteManager | 4 | from django.contrib.sites.managers import CurrentSiteManager |
109 | 5 | 5 | ||
110 | 6 | |||
111 | 6 | class Menu(models.Model): | 7 | class Menu(models.Model): |
112 | 7 | name = models.CharField(max_length=100) | 8 | name = models.CharField(max_length=100) |
113 | 8 | slug = models.SlugField() | 9 | slug = models.SlugField() |
114 | @@ -19,12 +20,12 @@ | |||
115 | 19 | def save(self, force_insert=False, force_update=False): | 20 | def save(self, force_insert=False, force_update=False): |
116 | 20 | """ | 21 | """ |
117 | 21 | Re-order all items from 10 upwards, at intervals of 10. | 22 | Re-order all items from 10 upwards, at intervals of 10. |
120 | 22 | This makes it easy to insert new items in the middle of | 23 | This makes it easy to insert new items in the middle of |
121 | 23 | existing items without having to manually shuffle | 24 | existing items without having to manually shuffle |
122 | 24 | them all around. | 25 | them all around. |
123 | 25 | """ | 26 | """ |
124 | 26 | super(Menu, self).save(force_insert, force_update) | 27 | super(Menu, self).save(force_insert, force_update) |
126 | 27 | 28 | ||
127 | 28 | current = 10 | 29 | current = 10 |
128 | 29 | for item in MenuItem.objects.filter(menu=self).order_by('order'): | 30 | for item in MenuItem.objects.filter(menu=self).order_by('order'): |
129 | 30 | item.order = current | 31 | item.order = current |
130 | @@ -35,10 +36,19 @@ | |||
131 | 35 | class MenuItem(models.Model): | 36 | class MenuItem(models.Model): |
132 | 36 | menu = models.ForeignKey(Menu) | 37 | menu = models.ForeignKey(Menu) |
133 | 37 | order = models.IntegerField() | 38 | order = models.IntegerField() |
135 | 38 | link_url = models.CharField(max_length=100, help_text='URL or URI to the content, eg /about/ or http://foo.com/') | 39 | link_url = models.CharField( |
136 | 40 | max_length=100, | ||
137 | 41 | help_text='URL or URI to the content, eg /about/ or http://foo.com/', | ||
138 | 42 | ) | ||
139 | 39 | title = models.CharField(max_length=100) | 43 | title = models.CharField(max_length=100) |
143 | 40 | login_required = models.BooleanField(blank=True, help_text='Should this item only be shown to authenticated users?') | 44 | login_required = models.BooleanField( |
144 | 41 | anonymous_only = models.BooleanField(blank=True, help_text='Should this item only be shown to non-logged-in users?') | 45 | blank=True, |
145 | 42 | 46 | help_text='Should this item only be shown to authenticated users?', | |
146 | 47 | ) | ||
147 | 48 | anonymous_only = models.BooleanField( | ||
148 | 49 | blank=True, | ||
149 | 50 | help_text='Should this item only be shown to non-logged-in users?', | ||
150 | 51 | ) | ||
151 | 52 | |||
152 | 43 | def __unicode__(self): | 53 | def __unicode__(self): |
153 | 44 | return "%s %s. %s" % (self.menu.slug, self.order, self.title) | 54 | return "%s %s. %s" % (self.menu.slug, self.order, self.title) |
154 | 45 | 55 | ||
155 | === modified file 'summit/common/templatetags/menubuilder.py' | |||
156 | --- summit/common/templatetags/menubuilder.py 2012-10-06 01:42:35 +0000 | |||
157 | +++ summit/common/templatetags/menubuilder.py 2013-07-08 13:28:38 +0000 | |||
158 | @@ -4,6 +4,7 @@ | |||
159 | 4 | 4 | ||
160 | 5 | register = template.Library() | 5 | register = template.Library() |
161 | 6 | 6 | ||
162 | 7 | |||
163 | 7 | def build_menu(parser, token): | 8 | def build_menu(parser, token): |
164 | 8 | """ | 9 | """ |
165 | 9 | {% menu menu_name %} | 10 | {% menu menu_name %} |
166 | @@ -11,9 +12,12 @@ | |||
167 | 11 | try: | 12 | try: |
168 | 12 | tag_name, menu_name = token.split_contents() | 13 | tag_name, menu_name = token.split_contents() |
169 | 13 | except: | 14 | except: |
171 | 14 | raise template.TemplateSyntaxError, "%r tag requires exactly one argument" % token.contents.split()[0] | 15 | raise template.TemplateSyntaxError, ( |
172 | 16 | "%r tag requires exactly one argument" % token.contents.split()[0] | ||
173 | 17 | ) | ||
174 | 15 | return MenuObject(menu_name) | 18 | return MenuObject(menu_name) |
175 | 16 | 19 | ||
176 | 20 | |||
177 | 17 | class MenuObject(template.Node): | 21 | class MenuObject(template.Node): |
178 | 18 | def __init__(self, menu_name): | 22 | def __init__(self, menu_name): |
179 | 19 | self.menu_name = menu_name | 23 | self.menu_name = menu_name |
180 | @@ -27,12 +31,14 @@ | |||
181 | 27 | context['menuitems'] = get_items(real_menu_name, current_path, user) | 31 | context['menuitems'] = get_items(real_menu_name, current_path, user) |
182 | 28 | return '' | 32 | return '' |
183 | 29 | 33 | ||
184 | 34 | |||
185 | 30 | def build_sub_menu(parser, token): | 35 | def build_sub_menu(parser, token): |
186 | 31 | """ | 36 | """ |
187 | 32 | {% submenu %} | 37 | {% submenu %} |
188 | 33 | """ | 38 | """ |
189 | 34 | return SubMenuObject() | 39 | return SubMenuObject() |
190 | 35 | 40 | ||
191 | 41 | |||
192 | 36 | class SubMenuObject(template.Node): | 42 | class SubMenuObject(template.Node): |
193 | 37 | def __init__(self): | 43 | def __init__(self): |
194 | 38 | pass | 44 | pass |
195 | @@ -52,11 +58,13 @@ | |||
196 | 52 | context['submenu_items'] = context['submenu'] = None | 58 | context['submenu_items'] = context['submenu'] = None |
197 | 53 | return '' | 59 | return '' |
198 | 54 | 60 | ||
199 | 61 | |||
200 | 55 | def get_items(menu_name, current_path, user): | 62 | def get_items(menu_name, current_path, user): |
201 | 56 | """ | 63 | """ |
203 | 57 | If possible, use a cached list of items to avoid continually re-querying | 64 | If possible, use a cached list of items to avoid continually re-querying |
204 | 58 | the database. | 65 | the database. |
206 | 59 | The key contains the menu name, whether the user is authenticated, and the current path. | 66 | The key contains the menu name, whether the user is authenticated, and the |
207 | 67 | current path. | ||
208 | 60 | Disable caching by setting MENU_CACHE_TIME to -1. | 68 | Disable caching by setting MENU_CACHE_TIME to -1. |
209 | 61 | """ | 69 | """ |
210 | 62 | from django.conf import settings | 70 | from django.conf import settings |
211 | @@ -64,26 +72,46 @@ | |||
212 | 64 | debug = getattr(settings, 'DEBUG', False) | 72 | debug = getattr(settings, 'DEBUG', False) |
213 | 65 | 73 | ||
214 | 66 | if cache_time >= 0 and not debug: | 74 | if cache_time >= 0 and not debug: |
216 | 67 | cache_key = 'django-menu-items/%s/%s/%s' % (menu_name, current_path, user.is_authenticated()) | 75 | cache_key = 'django-menu-items/%s/%s/%s' % ( |
217 | 76 | menu_name, | ||
218 | 77 | current_path, | ||
219 | 78 | user.is_authenticated(), | ||
220 | 79 | ) | ||
221 | 68 | menuitems = cache.get(cache_key, []) | 80 | menuitems = cache.get(cache_key, []) |
222 | 69 | if menuitems: | 81 | if menuitems: |
223 | 70 | return menuitems | 82 | return menuitems |
224 | 71 | else: | 83 | else: |
225 | 72 | menuitems = [] | 84 | menuitems = [] |
227 | 73 | 85 | ||
228 | 74 | try: | 86 | try: |
229 | 75 | menu = Menu.objects.get(slug=menu_name) | 87 | menu = Menu.objects.get(slug=menu_name) |
230 | 76 | except Menu.DoesNotExist: | 88 | except Menu.DoesNotExist: |
231 | 77 | return [] | 89 | return [] |
232 | 78 | 90 | ||
233 | 79 | for i in MenuItem.objects.filter(menu=menu).order_by('order'): | 91 | for i in MenuItem.objects.filter(menu=menu).order_by('order'): |
236 | 80 | current = ( i.link_url != '/' and current_path.startswith(i.link_url)) or ( i.link_url == '/' and current_path == '/' ) | 92 | current = ( |
237 | 81 | if menu.base_url and i.link_url == menu.base_url and current_path != i.link_url: | 93 | i.link_url != '/' and current_path.startswith(i.link_url) |
238 | 94 | ) or ( | ||
239 | 95 | i.link_url == '/' and current_path == '/' | ||
240 | 96 | ) | ||
241 | 97 | if ( | ||
242 | 98 | menu.base_url and i.link_url == menu.base_url | ||
243 | 99 | ) and ( | ||
244 | 100 | current_path != i.link_url | ||
245 | 101 | ): | ||
246 | 82 | current = False | 102 | current = False |
247 | 83 | show_anonymous = i.anonymous_only and user.is_anonymous() | 103 | show_anonymous = i.anonymous_only and user.is_anonymous() |
248 | 84 | show_auth = i.login_required and user.is_authenticated() | 104 | show_auth = i.login_required and user.is_authenticated() |
251 | 85 | if (not (i.login_required or i.anonymous_only)) or (i.login_required and show_auth) or (i.anonymous_only and show_anonymous): | 105 | if ( |
252 | 86 | menuitems.append({'url': i.link_url, 'title': i.title, 'current': current,}) | 106 | not (i.login_required or i.anonymous_only) |
253 | 107 | ) or ( | ||
254 | 108 | i.login_required and show_auth | ||
255 | 109 | ) or ( | ||
256 | 110 | i.anonymous_only and show_anonymous | ||
257 | 111 | ): | ||
258 | 112 | menuitems.append( | ||
259 | 113 | {'url': i.link_url, 'title': i.title, 'current': current} | ||
260 | 114 | ) | ||
261 | 87 | 115 | ||
262 | 88 | if cache_time >= 0 and not debug: | 116 | if cache_time >= 0 and not debug: |
263 | 89 | cache.set(cache_key, menuitems, cache_time) | 117 | cache.set(cache_key, menuitems, cache_time) |
264 | 90 | 118 | ||
265 | === modified file 'summit/common/templatetags/qrcode.py' | |||
266 | --- summit/common/templatetags/qrcode.py 2012-10-27 15:27:30 +0000 | |||
267 | +++ summit/common/templatetags/qrcode.py 2013-07-08 13:28:38 +0000 | |||
268 | @@ -1,14 +1,14 @@ | |||
269 | 1 | # Snippet from http://djangosnippets.org/snippets/1494/ | 1 | # Snippet from http://djangosnippets.org/snippets/1494/ |
270 | 2 | # Generate QR Code image from a string with the Google charts API | 2 | # Generate QR Code image from a string with the Google charts API |
272 | 3 | # | 3 | # |
273 | 4 | # http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes | 4 | # http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes |
277 | 5 | # | 5 | # |
278 | 6 | # Exemple usage in a template | 6 | # Example usage in a template |
279 | 7 | # | 7 | # |
280 | 8 | # {{ my_string|qrcode:"my alt" }} | 8 | # {{ my_string|qrcode:"my alt" }} |
281 | 9 | # will return the image tag with | 9 | # will return the image tag with |
284 | 10 | # | 10 | # |
285 | 11 | # src: http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=my_string&choe=UTF-8 | 11 | # src: http://goo.gl/KyAVB |
286 | 12 | # Author:johnnoone | 12 | # Author:johnnoone |
287 | 13 | # Posted:May 6, 2009 | 13 | # Posted:May 6, 2009 |
288 | 14 | # Language:Python | 14 | # Language:Python |
289 | @@ -23,34 +23,41 @@ | |||
290 | 23 | 23 | ||
291 | 24 | register = template.Library() | 24 | register = template.Library() |
292 | 25 | 25 | ||
293 | 26 | |||
294 | 26 | @register.filter | 27 | @register.filter |
295 | 27 | @stringfilter | 28 | @stringfilter |
296 | 28 | def qrcode(value, alt=None): | 29 | def qrcode(value, alt=None): |
297 | 29 | """ | 30 | """ |
298 | 30 | Generate QR Code image from a string with the Google charts API | 31 | Generate QR Code image from a string with the Google charts API |
300 | 31 | 32 | ||
301 | 32 | http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes | 33 | http://code.google.com/intl/fr-FR/apis/chart/types.html#qrcodes |
304 | 33 | 34 | ||
305 | 34 | Exemple usage -- | 35 | Example usage -- |
306 | 35 | {{ my_string|qrcode:"my alt" }} | 36 | {{ my_string|qrcode:"my alt" }} |
309 | 36 | 37 | ||
308 | 37 | <img src="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=my_string&choe=UTF-8" alt="my alt" /> | ||
310 | 38 | """ | 38 | """ |
314 | 39 | 39 | ||
315 | 40 | url = conditional_escape("http://chart.apis.google.com/chart?%s" % \ | 40 | url = conditional_escape( |
316 | 41 | urllib.urlencode({'chs':'150x150', 'cht':'qr', 'chl':value, 'choe':'UTF-8'})) | 41 | "http://chart.apis.google.com/chart?%s" % urllib.urlencode( |
317 | 42 | {'chs': '150x150', 'cht': 'qr', 'chl': value, 'choe': 'UTF-8'} | ||
318 | 43 | ) | ||
319 | 44 | ) | ||
320 | 42 | alt = conditional_escape(alt or value) | 45 | alt = conditional_escape(alt or value) |
323 | 43 | 46 | ||
324 | 44 | return mark_safe(u"""<img class="qrcode" src="%s" width="150" height="150" alt="%s" />""" % (url, alt)) | 47 | return mark_safe( |
325 | 48 | u"""<img class="qrcode" src="%s" width="150" height="150" alt="%s" />""" % (url, alt) | ||
326 | 49 | ) | ||
327 | 50 | |||
328 | 45 | 51 | ||
329 | 46 | def build_qrhere(parser, token): | 52 | def build_qrhere(parser, token): |
330 | 47 | """ | 53 | """ |
331 | 48 | {% qrhere %} | 54 | {% qrhere %} |
333 | 49 | 55 | ||
334 | 50 | Returns an <img> with a QR Code pointing to the current URL | 56 | Returns an <img> with a QR Code pointing to the current URL |
335 | 51 | """ | 57 | """ |
336 | 52 | return QRHere() | 58 | return QRHere() |
337 | 53 | 59 | ||
338 | 60 | |||
339 | 54 | class QRHere(template.Node): | 61 | class QRHere(template.Node): |
340 | 55 | def __init__(self): | 62 | def __init__(self): |
341 | 56 | pass | 63 | pass |
342 | @@ -59,8 +66,18 @@ | |||
343 | 59 | if 'request' not in context: | 66 | if 'request' not in context: |
344 | 60 | return '' | 67 | return '' |
345 | 61 | current_url = '%s/%s' % (settings.SITE_ROOT, context['request'].path) | 68 | current_url = '%s/%s' % (settings.SITE_ROOT, context['request'].path) |
349 | 62 | url = conditional_escape("http://chart.apis.google.com/chart?%s" % \ | 69 | url = conditional_escape( |
350 | 63 | urllib.urlencode({'chs':'150x150', 'cht':'qr', 'chl':current_url, 'choe':'UTF-8'})) | 70 | "http://chart.apis.google.com/chart?%s" % urllib.urlencode( |
351 | 64 | return mark_safe(u"""<img class="qrcode" src="%s" width="150" height="150" />""" % url) | 71 | { |
352 | 72 | 'chs': '150x150', | ||
353 | 73 | 'cht': 'qr', | ||
354 | 74 | 'chl': current_url, | ||
355 | 75 | 'choe': 'UTF-8', | ||
356 | 76 | } | ||
357 | 77 | ) | ||
358 | 78 | ) | ||
359 | 79 | return mark_safe( | ||
360 | 80 | u"""<img class="qrcode" src="%s" width="150" height="150" />""" % url | ||
361 | 81 | ) | ||
362 | 65 | 82 | ||
363 | 66 | register.tag('qrhere', build_qrhere) | 83 | register.tag('qrhere', build_qrhere) |
364 | 67 | 84 | ||
365 | === modified file 'summit/common/utils.py' | |||
366 | --- summit/common/utils.py 2013-01-19 22:29:21 +0000 | |||
367 | +++ summit/common/utils.py 2013-07-08 13:28:38 +0000 | |||
368 | @@ -7,7 +7,9 @@ | |||
369 | 7 | """ | 7 | """ |
370 | 8 | value = value.lstrip('#') | 8 | value = value.lstrip('#') |
371 | 9 | lv = len(value) | 9 | lv = len(value) |
373 | 10 | return tuple(int(value[i:i + lv / 3], 16) for i in range(0, lv, lv / 3)) + (0.5,) | 10 | return tuple( |
374 | 11 | int(value[i:i + lv / 3], 16) for i in range(0, lv, lv / 3) | ||
375 | 12 | ) + (0.5,) | ||
376 | 11 | 13 | ||
377 | 12 | 14 | ||
378 | 13 | def redirect(to, *args, **kwargs): | 15 | def redirect(to, *args, **kwargs): |
379 | 14 | 16 | ||
380 | === modified file 'summit/common/views.py' | |||
381 | --- summit/common/views.py 2013-05-10 16:36:27 +0000 | |||
382 | +++ summit/common/views.py 2013-07-08 13:28:38 +0000 | |||
383 | @@ -47,9 +47,13 @@ | |||
384 | 47 | return render_to_response("common/no_summit.html") | 47 | return render_to_response("common/no_summit.html") |
385 | 48 | 48 | ||
386 | 49 | 49 | ||
390 | 50 | def login_failure(request, message, status=403, | 50 | def login_failure( |
391 | 51 | template_name='login_failure.html', | 51 | request, |
392 | 52 | exception=None): | 52 | message, |
393 | 53 | status=403, | ||
394 | 54 | template_name='login_failure.html', | ||
395 | 55 | exception=None, | ||
396 | 56 | ): | ||
397 | 53 | """Render an error page to the user.""" | 57 | """Render an error page to the user.""" |
398 | 54 | context = { | 58 | context = { |
399 | 55 | 'message': message, | 59 | 'message': message, |
400 | @@ -60,6 +64,9 @@ | |||
401 | 60 | elif isinstance(exception, MissingUsernameViolation): | 64 | elif isinstance(exception, MissingUsernameViolation): |
402 | 61 | context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use The Summit Scheduler' | 65 | context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use The Summit Scheduler' |
403 | 62 | 66 | ||
406 | 63 | data = render_to_string(template_name, context, | 67 | data = render_to_string( |
407 | 64 | context_instance=RequestContext(request)) | 68 | template_name, |
408 | 69 | context, | ||
409 | 70 | context_instance=RequestContext(request), | ||
410 | 71 | ) | ||
411 | 65 | return HttpResponse(data, status=status) | 72 | return HttpResponse(data, status=status) |
412 | 66 | 73 | ||
413 | === modified file 'summit/common/widgets.py' | |||
414 | --- summit/common/widgets.py 2013-04-08 20:50:49 +0000 | |||
415 | +++ summit/common/widgets.py 2013-07-08 13:28:38 +0000 | |||
416 | @@ -99,9 +99,7 @@ | |||
417 | 99 | """ | 99 | """ |
418 | 100 | A more-friendly date/time widget. | 100 | A more-friendly date/time widget. |
419 | 101 | 101 | ||
423 | 102 | Inspired by: | 102 | Inspired by: http://goo.gl/bul3W |
421 | 103 | |||
422 | 104 | http://copiesofcopies.org/webl/2010/04/26/a-better-datetime-widget-for-django/ | ||
424 | 105 | """ | 103 | """ |
425 | 106 | def __init__(self, attrs=None, date_format=None, time_format=None): | 104 | def __init__(self, attrs=None, date_format=None, time_format=None): |
426 | 107 | super(DateTimeWidget, self).__init__(attrs, date_format, time_format) | 105 | super(DateTimeWidget, self).__init__(attrs, date_format, time_format) |