diff mbox

[Branch,~linaro-validation/lava-server/trunk] Rev 368: Display OpenID login forms only if OpenID auth is enabled (Jean-François Fortin Tam)

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

Commit Message

Michael-Doyle Hudson May 14, 2012, 12:40 a.m. UTC
Merge authors:
  Jean-François Fortin Tam (kiddo)
Related merge proposals:
  https://code.launchpad.net/~kiddo/lava-server/optional-openid/+merge/105533
  proposed by: Jean-François Fortin Tam (kiddo)
  review: Approve - Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 368 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Mon 2012-05-14 12:38:01 +1200
message:
  Display OpenID login forms only if OpenID auth is enabled (Jean-François Fortin Tam)
modified:
  lava_server/context_processors.py
  lava_server/settings/common.py
  lava_server/templates/registration/login.html


--
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

=== modified file 'lava_server/context_processors.py'
--- lava_server/context_processors.py	2011-11-22 17:57:17 +0000
+++ lava_server/context_processors.py	2012-05-11 20:11:09 +0000
@@ -44,3 +44,7 @@ 
             'extension_list': loader.extensions,
             'version': versiontools.format_version(
                 lava_server.__version__, hint=lava_server)}}
+
+def openid_available(request):
+    openid_enabled = "django_openid_auth.auth.OpenIDBackend" in lava_server.settings.common.AUTHENTICATION_BACKENDS
+    return {"openid_available": openid_enabled}

=== modified file 'lava_server/settings/common.py'
--- lava_server/settings/common.py	2012-05-07 03:45:39 +0000
+++ lava_server/settings/common.py	2012-05-11 20:11:09 +0000
@@ -130,6 +130,7 @@ 
     "django.core.context_processors.request",
     "staticfiles.context_processors.static_url",
     "lava_server.context_processors.lava",
+    "lava_server.context_processors.openid_available",
 ]
 
 

=== modified file 'lava_server/templates/registration/login.html'
--- lava_server/templates/registration/login.html	2011-03-14 14:03:42 +0000
+++ lava_server/templates/registration/login.html	2012-05-11 20:11:09 +0000
@@ -38,12 +38,15 @@ 
 <form method="post" action="{% url django.contrib.auth.views.login %}">
   {% csrf_token %} 
   <table>
+    {% if openid_available %}
     <tr>
       <th id="lp_net_column">{% trans "Use Launchpad.net account" %}</th>
       <th id="or_column" rowspan="3">&ge;</th>
       <th id="local_account_column">{% trans "Use custom account" %}</th>
     </tr>
+    {% endif %}
     <tr>
+      {% if openid_available %}
       <td>
         {% blocktrans %}
         <p>Thanks to the <a
@@ -55,6 +58,7 @@ 
         having to maintain another account just for this website.</p>
         {% endblocktrans %}
       </td>
+      {% endif %}
       <td>
         {% blocktrans %}
         <p>If you already have a local account you can sign-in with your user
@@ -72,10 +76,12 @@ 
       </td>
     </tr>
     <tr>
+      {% if openid_available %}
       <th>
         <a class="button" href="{% url django_openid_auth.views.login_begin %}?next={{next|escape}}"
           >{% trans "Sign in with Launchpad.net" %}</a>
       </th>
+      {% endif %}
       <th>
         <input id="id_submit" type="submit" value="{% trans "Sign in with username and password" %}" />
         <input type="hidden" name="next" value="{{ next }}" />