diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 273: Add personal user page, breadcrumbify lava-server views

Message ID 20111109192614.3833.80687.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Zygmunt Krynicki Nov. 9, 2011, 7:26 p.m. UTC
------------------------------------------------------------
revno: 273
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
branch nick: lava-server
timestamp: Fri 2011-10-28 01:25:01 +0200
message:
  Add personal user page, breadcrumbify lava-server views
added:
  lava_server/templates/me.html
modified:
  lava_server/urls.py
  lava_server/views.py


--
lp:lava-server
https://code.launchpad.net/~linaro-validation/lava-server/trunk

You are subscribed to branch lp:lava-server.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-server/trunk/+edit-subscription
diff mbox

Patch

=== added file 'lava_server/templates/me.html'
--- lava_server/templates/me.html	1970-01-01 00:00:00 +0000
+++ lava_server/templates/me.html	2011-10-27 23:25:01 +0000
@@ -0,0 +1,17 @@ 
+{% extends "layouts/content_with_sidebar.html" %}
+{% load i18n %}
+
+{% block sidebar %}
+<h3>{% trans "Actions" %}</h3>
+<ul>
+  <li><a href="{% url django.contrib.auth.views.logout %}"
+    >{% trans "Sign out" %}</a></li>
+  <li><a href="{% url django.contrib.auth.views.password_change %}"
+    >{% trans "Change your password" %}</a></li>
+</ul>
+{% endblock %}
+
+{% block content %}
+<h2>Welcome</h2>
+<p>This is a placeholder for more interesting content</p>
+{% endblock %}

=== modified file 'lava_server/urls.py'
--- lava_server/urls.py	2011-10-11 09:58:00 +0000
+++ lava_server/urls.py	2011-10-27 23:25:01 +0000
@@ -24,7 +24,7 @@ 
 from linaro_django_xmlrpc import urls as api_urls
 
 from lava_server.extension import loader
-from lava_server.views import index, version
+from lava_server.views import index, me, version
 
 
 # Enable admin stuff
@@ -37,6 +37,9 @@ 
     url(r'^' + settings.APP_URL_PREFIX + r'$',
         index,
         name='lava.home'),
+    url(r'^' + settings.APP_URL_PREFIX + r'me/$',
+        me,
+        name='lava.me'),
     url(r'^' + settings.APP_URL_PREFIX + r'version/$',
         version,
         name='lava.version_details'),

=== modified file 'lava_server/views.py'
--- lava_server/views.py	2011-10-11 09:20:14 +0000
+++ lava_server/views.py	2011-10-27 23:25:01 +0000
@@ -16,16 +16,26 @@ 
 # You should have received a copy of the GNU Affero General Public License
 # along with LAVA Server.  If not, see <http://www.gnu.org/licenses/>.
 
+from django.contrib.auth.decorators import login_required
 from django.http import HttpResponse
 from django.template import loader, RequestContext
+from django.utils.translation import ugettext as _
 from django.views.generic.simple import direct_to_template
 
+from lava_server.bread_crumbs import (
+    BreadCrumb,
+    BreadCrumbTrail,
+)
 from lava_server.extension import loader as extension_loader
 
 
+@BreadCrumb(_("LAVA"))
 def index(request):
     # Start with a list of extensions
-    data = {'extension_list': extension_loader.extensions}
+    data = {
+        'extension_list': extension_loader.extensions,
+        'bread_crumb_trail': BreadCrumbTrail.leading_to(index),
+    }
     # Append each extension context data
     for extension in extension_loader.extensions:
         data.update(extension.get_front_page_context())
@@ -35,5 +45,24 @@ 
     return HttpResponse(template.render(context))
 
 
+@BreadCrumb(_("About you ({you})"),
+            parent=index)
+@login_required
+def me(request):
+    data = {
+        'bread_crumb_trail': BreadCrumbTrail.leading_to(me, you=request.user.get_full_name())
+    }
+    context = RequestContext(request, data)
+    template = loader.get_template('me.html')
+    return HttpResponse(template.render(context))
+
+
+@BreadCrumb(_("Version details"),
+            parent=index)
 def version(request):
-    return direct_to_template(request, 'version_details.html')
+    data = {
+        'bread_crumb_trail': BreadCrumbTrail.leading_to(version)
+    }
+    context = RequestContext(request, data)
+    template = loader.get_template('version_details.html')
+    return HttpResponse(template.render(context))