adapt login box message to allow-email-login configuration tls-sprint
authorFlorent <florent@secondweb.fr>
Wed, 13 May 2009 10:38:18 +0200
branchtls-sprint
changeset 1776 4be367276874
parent 1772 21d1db460cdb
child 1777 7bd776052e2b
adapt login box message to allow-email-login configuration
web/data/cubicweb.login.css
web/test/unittest_views_basetemplates.py
web/views/basetemplates.py
--- a/web/data/cubicweb.login.css	Wed May 13 09:13:26 2009 +0200
+++ b/web/data/cubicweb.login.css	Wed May 13 10:38:18 2009 +0200
@@ -24,8 +24,8 @@
   position : absolute;
   top: 15%;
   left : 50%;
-  margin-left: -11em;
-  width: 24em;
+  margin-left: -14em;
+  width: 28em;
   background: #fff;
   border: 2px solid #cfceb7;
   padding-bottom: 0.5em;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/unittest_views_basetemplates.py	Wed May 13 10:38:18 2009 +0200
@@ -0,0 +1,16 @@
+from cubicweb.devtools.testlib import WebTest
+from cubicweb.devtools.htmlparser import DTDValidator
+
+
+class LogFormTemplateTC(WebTest):
+
+    def _login_labels(self):
+        valid = self.content_type_validators.get('text/html', DTDValidator)()
+        page = valid.parse_string(self.vreg.main_template(self.request(), 'login'))
+        return page.find_tag('label')
+
+    def test_label(self):
+        self.set_option('allow-email-login', 'yes')
+        self.assertEquals(self._login_labels(), ['login or email', 'password'])
+        self.set_option('allow-email-login', 'no')
+        self.assertEquals(self._login_labels(), ['login', 'password'])
--- a/web/views/basetemplates.py	Wed May 13 09:13:26 2009 +0200
+++ b/web/views/basetemplates.py	Wed May 13 10:38:18 2009 +0200
@@ -455,7 +455,8 @@
                % html_escape(login_form_url(self.config, self.req)))
         self.w(u'<table>\n')
         self.w(u'<tr>\n')
-        self.w(u'<td><label for="__login">%s</label></td>' % _('login or email'))
+        msg = (self.config['allow-email-login'] and _('login or email')) or _('login')
+        self.w(u'<td><label for="__login">%s</label></td>' % msg)
         self.w(u'<td><input name="__login" id="__login" class="data" type="text" /></td>')
         self.w(u'</tr><tr>\n')
         self.w(u'<td><label for="__password" >%s</label></td>' % _('password'))