Merge lp:~deeptik/linaro-ci-dashboard/django-openid-changes into lp:linaro-ci-dashboard

Proposed by Deepti B. Kalakeri
Status: Merged
Merged at revision: 4
Proposed branch: lp:~deeptik/linaro-ci-dashboard/django-openid-changes
Merge into: lp:linaro-ci-dashboard
Diff against target: 191 lines (+98/-1)
9 files modified
dashboard/frontend/models.py (+3/-0)
dashboard/frontend/tests.py (+16/-0)
dashboard/frontend/urls.py (+12/-0)
dashboard/frontend/views/home_page_view.py (+10/-0)
dashboard/frontend/views/index_view.py (+16/-0)
dashboard/settings.py (+23/-1)
dashboard/templates/frontend/home.html (+8/-0)
dashboard/templates/frontend/index.html (+4/-0)
dashboard/urls.py (+6/-0)
To merge this branch: bzr merge lp:~deeptik/linaro-ci-dashboard/django-openid-changes
Reviewer Review Type Date Requested Status
Stevan Radaković Pending
Review via email: mp+113504@code.launchpad.net

Description of the change

Adding open id authencation changes and a welcome page.

To post a comment you must log in.
12. By Stevan Radaković

Add local urls.py file. Change views to be Class-based.

13. By Stevan Radaković

Add local urls.py file. Change views to be Class-based. Add missing files.

14. By Deepti B. Kalakeri

Adding changes to views and templates

15. By Deepti B. Kalakeri

Using the login_required decorator to for openid login

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'dashboard/frontend'
2=== added file 'dashboard/frontend/__init__.py'
3=== added file 'dashboard/frontend/models.py'
4--- dashboard/frontend/models.py 1970-01-01 00:00:00 +0000
5+++ dashboard/frontend/models.py 2012-07-05 15:26:20 +0000
6@@ -0,0 +1,3 @@
7+from django.db import models
8+
9+# Create your models here.
10
11=== added file 'dashboard/frontend/tests.py'
12--- dashboard/frontend/tests.py 1970-01-01 00:00:00 +0000
13+++ dashboard/frontend/tests.py 2012-07-05 15:26:20 +0000
14@@ -0,0 +1,16 @@
15+"""
16+This file demonstrates writing tests using the unittest module. These will pass
17+when you run "manage.py test".
18+
19+Replace this with more appropriate tests for your application.
20+"""
21+
22+from django.test import TestCase
23+
24+
25+class SimpleTest(TestCase):
26+ def test_basic_addition(self):
27+ """
28+ Tests that 1 + 1 always equals 2.
29+ """
30+ self.assertEqual(1 + 1, 2)
31
32=== added file 'dashboard/frontend/urls.py'
33--- dashboard/frontend/urls.py 1970-01-01 00:00:00 +0000
34+++ dashboard/frontend/urls.py 2012-07-05 15:26:20 +0000
35@@ -0,0 +1,12 @@
36+from django.conf.urls.defaults import patterns, include, url
37+from frontend.views.home_page_view import HomePageView
38+from frontend.views.index_view import IndexView
39+
40+urlpatterns = patterns('',
41+ # url(r'^$', 'dashboard.frontend.views.index'),
42+ #url(r'^index$', 'dashboard.frontend.views.index'),
43+ # url(r'^accounts/profile/$', 'dashboard.frontend.views.home_page'),
44+ url(r'^$', IndexView.as_view(), name='Index'),
45+ url(r'^index/$', IndexView.as_view(), name='Index'),
46+ url(r'^accounts/profile/$', HomePageView.as_view(), name='Home'),
47+)
48
49=== added directory 'dashboard/frontend/views'
50=== added file 'dashboard/frontend/views/__init__.py'
51=== added file 'dashboard/frontend/views/home_page_view.py'
52--- dashboard/frontend/views/home_page_view.py 1970-01-01 00:00:00 +0000
53+++ dashboard/frontend/views/home_page_view.py 2012-07-05 15:26:20 +0000
54@@ -0,0 +1,10 @@
55+from django.views.generic.base import TemplateView
56+
57+class HomePageView(TemplateView):
58+
59+ template_name = "home.html"
60+
61+ def get_context_data(self, **kwargs):
62+ context = super(HomePageView, self).get_context_data(**kwargs)
63+ context['request'] = self.request
64+ return context
65
66=== added file 'dashboard/frontend/views/index_view.py'
67--- dashboard/frontend/views/index_view.py 1970-01-01 00:00:00 +0000
68+++ dashboard/frontend/views/index_view.py 2012-07-05 15:26:20 +0000
69@@ -0,0 +1,16 @@
70+from django.views.generic.base import TemplateView
71+from django.utils.decorators import method_decorator
72+from django.contrib.auth.decorators import login_required
73+
74+class IndexView(TemplateView):
75+
76+ template_name = "index.html"
77+
78+ @method_decorator(login_required)
79+ def dispatch(self, *args, **kwargs):
80+ return super(IndexView, self).dispatch(*args, **kwargs)
81+
82+ def get_context_data(self, **kwargs):
83+ context = super(IndexView, self).get_context_data(**kwargs)
84+ context['request'] = self.request
85+ return context
86
87=== modified file 'dashboard/settings.py'
88--- dashboard/settings.py 2012-07-04 13:43:22 +0000
89+++ dashboard/settings.py 2012-07-05 15:26:20 +0000
90@@ -1,8 +1,11 @@
91 # Django settings for dashboard project.
92+import os
93
94 DEBUG = True
95 TEMPLATE_DEBUG = DEBUG
96
97+PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
98+
99 ADMINS = (
100 # ('Your Name', 'your_email@example.com'),
101 )
102@@ -12,7 +15,7 @@
103 DATABASES = {
104 'default': {
105 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
106- 'NAME': 'dashboard.sqlite3', # Or path to database file if using sqlite3.
107+ 'NAME': os.path.join(PROJECT_ROOT, 'dashboard.db'), # Or path to database file if using sqlite3.
108 'USER': '', # Not used with sqlite3.
109 'PASSWORD': '', # Not used with sqlite3.
110 'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
111@@ -106,8 +109,10 @@
112 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
113 # Always use forward slashes, even on Windows.
114 # Don't forget to use absolute paths, not relative paths.
115+ os.path.join(PROJECT_ROOT, "templates/frontend" ),
116 )
117
118+
119 INSTALLED_APPS = (
120 'django.contrib.admin',
121 'django.contrib.auth',
122@@ -116,12 +121,29 @@
123 'django.contrib.sites',
124 'django.contrib.messages',
125 'django.contrib.staticfiles',
126+ 'django_openid_auth',
127+ 'frontend',
128 # Uncomment the next line to enable the admin:
129 # 'django.contrib.admin',
130 # Uncomment the next line to enable admin documentation:
131 # 'django.contrib.admindocs',
132 )
133
134+AUTHENTICATION_BACKENDS = (
135+ 'django_openid_auth.auth.OpenIDBackend',
136+ 'django.contrib.auth.backends.ModelBackend',
137+)
138+
139+#MEDIA_URL = '/static/'
140+
141+OPENID_CREATE_USERS = True
142+LOGIN_URL = '/openid/login/'
143+OPENID_SSO_SERVER_URL = 'https://login.launchpad.net/'
144+OPENID_LAUNCHPAD_TEAMS_MAPPING = {
145+ 'linaro': 'linaro',
146+}
147+
148+
149 # A sample logging configuration. The only tangible logging
150 # performed by this configuration is to send an email to
151 # the site admins on every HTTP 500 error.
152
153=== added directory 'dashboard/templates'
154=== added directory 'dashboard/templates/frontend'
155=== added file 'dashboard/templates/frontend/home.html'
156--- dashboard/templates/frontend/home.html 1970-01-01 00:00:00 +0000
157+++ dashboard/templates/frontend/home.html 2012-07-05 15:26:20 +0000
158@@ -0,0 +1,8 @@
159+{% if request.user.username %}
160+ <ul>
161+ <li>Welcome <b>{{ request.user.username }}!!!</b></li>
162+ <p><a href="/logout">Sign out</a></p>
163+ </ul>
164+{% else %}
165+ <p>No Profile information available</p>
166+{% endif %}
167
168=== added file 'dashboard/templates/frontend/index.html'
169--- dashboard/templates/frontend/index.html 1970-01-01 00:00:00 +0000
170+++ dashboard/templates/frontend/index.html 2012-07-05 15:26:20 +0000
171@@ -0,0 +1,4 @@
172+{% block content %}
173+<p>You are signed in as <strong>{{request.user.username}}</strong> ({{request.user.get_full_name}}) </p>
174+<a href="/logout">Sign out</a>
175+{% endblock %}
176
177=== modified file 'dashboard/urls.py'
178--- dashboard/urls.py 2012-07-04 13:43:22 +0000
179+++ dashboard/urls.py 2012-07-05 15:26:20 +0000
180@@ -13,5 +13,11 @@
181 # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
182
183 # Uncomment the next line to enable the admin:
184+ # url(r'^$', 'dashboard.frontend.views.index'),
185+ #url(r'^index$', 'dashboard.frontend.views.index'),
186+ # url(r'^accounts/profile/$', 'dashboard.frontend.views.home_page'),
187 url(r'^admin/', include(admin.site.urls)),
188+ url(r'^openid/', include('django_openid_auth.urls')),
189+ url(r'^logout/$', 'django.contrib.auth.views.logout'),
190+ url(r'^', include('dashboard.frontend.urls')),
191 )

Subscribers

People subscribed via source and target branches