Merge lp:~nigelbabu/summit/common-app into lp:summit

Proposed by Nigel Babu
Status: Merged
Approved by: Chris Johnston
Approved revision: 218
Merged at revision: 219
Proposed branch: lp:~nigelbabu/summit/common-app
Merge into: lp:summit
Diff against target: 132 lines (+52/-27)
4 files modified
summit/common/views.py (+50/-0)
summit/schedule/views.py (+0/-26)
summit/settings.py (+1/-0)
summit/urls.py (+1/-1)
To merge this branch: bzr merge lp:~nigelbabu/summit/common-app
Reviewer Review Type Date Requested Status
Chris Johnston Approve
Review via email: mp+81630@code.launchpad.net

Commit message

Created a common app and moved login_failure into it

Description of the change

Created a common app and moved login_failure into it

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=== added directory 'summit/common'
2=== added file 'summit/common/__init__.py'
3=== added file 'summit/common/views.py'
4--- summit/common/views.py 1970-01-01 00:00:00 +0000
5+++ summit/common/views.py 2011-11-08 19:19:26 +0000
6@@ -0,0 +1,50 @@
7+# Ubuntu Developer Summit web application
8+# Copyright (C) 2008, 2009, 2010 Canonical Ltd
9+#
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU Affero General Public License as
12+# published by the Free Software Foundation, either version 3 of the
13+# License, or (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU Affero General Public License for more details.
19+#
20+# You should have received a copy of the GNU Affero General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
23+from django.shortcuts import render_to_response
24+from django.template.loader import render_to_string
25+from django.template import RequestContext
26+from django.http import HttpResponse, HttpResponseRedirect
27+
28+try:
29+ from django_openid_auth.exceptions import (
30+ MissingPhysicalMultiFactor,
31+ MissingUsernameViolation,
32+ )
33+
34+except ImportError:
35+ MissingPhysicalMultiFactor = None
36+ MissingUsernameViolation = None
37+
38+
39+
40+def login_failure(request, message, status=403,
41+ template_name='login_failure.html',
42+ exception=None):
43+ """Render an error page to the user."""
44+ context = {
45+ 'message': message,
46+ 'exception': exception,
47+ }
48+ if isinstance(exception, MissingPhysicalMultiFactor):
49+ context['solution'] = 'Try logging in again using your Yubikey'
50+ elif isinstance(exception, MissingUsernameViolation):
51+ context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use Summit'
52+
53+ data = render_to_string(template_name, context,
54+ context_instance=RequestContext(request))
55+ return HttpResponse(data, status=status)
56+
57
58=== modified file 'summit/schedule/views.py'
59--- summit/schedule/views.py 2011-10-31 16:17:02 +0000
60+++ summit/schedule/views.py 2011-11-08 19:19:26 +0000
61@@ -23,7 +23,6 @@
62 from django.http import HttpResponse, HttpResponseRedirect
63 from django.shortcuts import render_to_response, get_object_or_404
64 from django.template import RequestContext
65-from django.template.loader import render_to_string
66
67 from summit.schedule.decorators import (summit_required,
68 summit_only_required,
69@@ -45,15 +44,6 @@
70 'today_view',
71 )
72
73-try:
74- from django_openid_auth.exceptions import (
75- MissingPhysicalMultiFactor,
76- MissingUsernameViolation,
77- )
78-
79-except ImportError:
80- MissingPhysicalMultiFactor = None
81- MissingUsernameViolation = None
82
83 def index(request):
84 summit = Summit.objects.next()
85@@ -64,22 +54,6 @@
86 return render_to_response("schedule/index.html", context,
87 context_instance=RequestContext(request))
88
89-def login_failure(request, message, status=403,
90- template_name='login_failure.html',
91- exception=None):
92- """Render an error page to the user."""
93- context = {
94- 'message': message,
95- 'exception': exception,
96- }
97- if isinstance(exception, MissingPhysicalMultiFactor):
98- context['solution'] = 'Try logging in again using your Yubikey'
99- elif isinstance(exception, MissingUsernameViolation):
100- context['solution'] = 'You will need to create a <a href="https://launchpad.net/people/+me">Launchpad profile</a> to use Summit'
101-
102- data = render_to_string(template_name, context,
103- context_instance=RequestContext(request))
104- return HttpResponse(data, status=status)
105
106 @summit_required
107 def summit(request, summit, attendee):
108
109=== modified file 'summit/settings.py'
110--- summit/settings.py 2011-11-06 22:06:57 +0000
111+++ summit/settings.py 2011-11-08 19:19:26 +0000
112@@ -148,6 +148,7 @@
113 'django.contrib.admin',
114 'summit.schedule',
115 'summit.sponsor',
116+ 'summit.common',
117 'south',
118 ]
119
120
121=== modified file 'summit/urls.py'
122--- summit/urls.py 2011-11-08 16:42:45 +0000
123+++ summit/urls.py 2011-11-08 19:19:26 +0000
124@@ -18,7 +18,7 @@
125 from django.conf import settings
126 import ubuntu_website
127
128-from schedule.views import login_failure
129+from common.views import login_failure
130
131 from django.contrib import admin
132 admin.autodiscover()

Subscribers

People subscribed via source and target branches