From patchwork Thu Nov 15 16:58:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 12873 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E949823E02 for ; Thu, 15 Nov 2012 16:58:17 +0000 (UTC) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by fiordland.canonical.com (Postfix) with ESMTP id 576DEA181ED for ; Thu, 15 Nov 2012 16:58:17 +0000 (UTC) Received: by mail-pa0-f52.google.com with SMTP id bj1so1158507pad.11 for ; Thu, 15 Nov 2012 08:58:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=cy1Q68TNC0pDF0E7imGr6VSRs3HylCFYfZbfVr38nsc=; b=oCUYILm1vbuqq4VixVD6/5UK8ShHgD5I3BiJxvFE4hqoeTQ3HRsZBRHCAC+O4djI55 99CeHyFlmOfi9aoh627mj5KGsnTzpCODoEUX5U3dD97EnlBo7uSME178bA3zpC+qGZ48 Ukn2d6N48L+ZHhTkkG6T/kagc31vUQKhg4+RBX/eBVYo8oXi2giXkpcukBNe8/RU1LAN FPdQnAQsVt2mgdKfbX+q0u9pjHZ3h1yX7UBwgje50P3SwRZv60mmN6sUY84P9Rm6mLer qZcaMwo/bZfO5rsnyIZrAf2LJNqF0HP5g66FGm/AhclX6n0BTkhsqig4XyeDjjX3UJ4Z FbfA== Received: by 10.66.88.133 with SMTP id bg5mr4703288pab.80.1352998696511; Thu, 15 Nov 2012 08:58:16 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.68.34.137 with SMTP id z9csp103437pbi; Thu, 15 Nov 2012 08:58:15 -0800 (PST) Received: by 10.180.80.131 with SMTP id r3mr921196wix.0.1352998694566; Thu, 15 Nov 2012 08:58:14 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id i54si8634144wea.117.2012.11.15.08.58.13 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 08:58:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TZ2lZ-0003xz-Pj for ; Thu, 15 Nov 2012 16:58:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id B268FE028C for ; Thu, 15 Nov 2012 16:58:13 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-server X-Launchpad-Branch: ~linaro-validation/lava-server/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 403 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-server/trunk] Rev 403: improve user experience for 403 errors Message-Id: <20121115165813.4515.70136.launchpad@ackee.canonical.com> Date: Thu, 15 Nov 2012 16:58:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16272"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: fe7c41395f847d1a7cfa18c87f1e23fbc8c234f2 X-Gm-Message-State: ALoCoQmHAgkUUZfZSkBZlsDJhz9YKvp4cZVNzwWurYP00abmIJSiendkQRrmCTf5RH7ZUOTv1rYQ Merge authors: Andy Doan (doanac) Related merge proposals: https://code.launchpad.net/~doanac/lava-server/403-improvements/+merge/133766 proposed by: Andy Doan (doanac) ------------------------------------------------------------ revno: 403 [merge] committer: Andy Doan branch nick: lava-server timestamp: Thu 2012-11-15 10:57:24 -0600 message: improve user experience for 403 errors modified: doc/changes.rst lava_server/templates/403.html lava_server/templates/layouts/content.html 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 === modified file 'doc/changes.rst' --- doc/changes.rst 2012-09-24 02:58:45 +0000 +++ doc/changes.rst 2012-11-15 16:57:24 +0000 @@ -6,6 +6,7 @@ Version 0.19 ============ * Unreleased. +* Improve user experience for 403 errors .. _version_0_18_1: @@ -21,7 +22,7 @@ * Make token page clearer about what the token actually is. * Enable devserver if it is available (i.e. if an instance is using buildout-development.cfg) -* If a table is queryset backed but not ajax enabled, render all the +* If a table is queryset backed but not ajax enabled, render all the data. * Load font css over https. === modified file 'lava_server/templates/403.html' --- lava_server/templates/403.html 2011-07-08 02:56:22 +0000 +++ lava_server/templates/403.html 2012-11-09 22:40:16 +0000 @@ -3,7 +3,15 @@ {% block title %} | HTTP 403 {% endblock %} - {% block content %}

403 Forbidden

+ +{% if user.is_authenticated %} +You do not have permission to view this resource. +{% else %} +

The requested resource is only for authorized users. You don't appear to be +logged into the system. Please log in to view this. +

+{% endif %} + {% endblock %} === modified file 'lava_server/templates/layouts/content.html' --- lava_server/templates/layouts/content.html 2012-06-04 03:32:24 +0000 +++ lava_server/templates/layouts/content.html 2012-11-09 22:40:16 +0000 @@ -70,8 +70,13 @@ {% if user.is_authenticated %} {{user.get_full_name|default:user.username}} ▾ {% else %} - {% trans "Guest" %} + {% if request.get_full_path == "/accounts/logout/" %} + {% trans "Guest" %} + {% else %} + {% trans "Guest" %} + {% endif %} {% endif %} {% if user.is_authenticated %} === modified file 'lava_server/urls.py' --- lava_server/urls.py 2012-02-15 21:53:07 +0000 +++ lava_server/urls.py 2012-11-09 22:40:16 +0000 @@ -27,6 +27,7 @@ from lava_server.views import index, me, version +handler403 = 'lava_server.views.permission_error' handler500 = 'lava_server.views.server_error' # Enable admin stuff === modified file 'lava_server/views.py' --- lava_server/views.py 2012-08-05 21:58:27 +0000 +++ lava_server/views.py 2012-11-09 22:40:16 +0000 @@ -86,3 +86,9 @@ 'user':request.user, 'request':request, }))) + +@requires_csrf_token +def permission_error(request, template_name='403.html'): + t = loader.get_template(template_name) + context = RequestContext(request) + return HttpResponse(t.render(context))