web/views/basetemplates.py
changeset 3659 993997b4b41d
parent 3655 af86ab65a282
child 3661 12ea53a4c0da
equal deleted inserted replaced
3658:d8f2ec7e91fa 3659:993997b4b41d
    56 
    56 
    57     def content(self, w):
    57     def content(self, w):
    58         # FIXME Deprecated code ?
    58         # FIXME Deprecated code ?
    59         msg = self._cw._('you have been logged out')
    59         msg = self._cw._('you have been logged out')
    60         w(u'<h2>%s</h2>\n' % msg)
    60         w(u'<h2>%s</h2>\n' % msg)
    61         if self._cw.config['anonymous-user']:
    61         if self._cw.vreg.config['anonymous-user']:
    62             indexurl = self._cw.build_url('view', vid='index', __message=msg)
    62             indexurl = self._cw.build_url('view', vid='index', __message=msg)
    63             w(u'<p><a href="%s">%s</a><p>' % (
    63             w(u'<p><a href="%s">%s</a><p>' % (
    64                 xml_escape(indexurl),
    64                 xml_escape(indexurl),
    65                 self._cw._('go back to the index page')))
    65                 self._cw._('go back to the index page')))
    66 
    66 
   487             self.w(u'<div id="loginTitle">%s</div>' % stitle)
   487             self.w(u'<div id="loginTitle">%s</div>' % stitle)
   488         self.w(u'<div id="loginContent">\n')
   488         self.w(u'<div id="loginContent">\n')
   489 
   489 
   490         if message:
   490         if message:
   491             self.display_message()
   491             self.display_message()
   492         if self._cw.config['auth-mode'] == 'http':
   492         if self._cw.vreg.config['auth-mode'] == 'http':
   493             # HTTP authentication
   493             # HTTP authentication
   494             pass
   494             pass
   495         else:
   495         else:
   496             # Cookie authentication
   496             # Cookie authentication
   497             self.login_form(id)
   497             self.login_form(id)
   503             self.w(u'<div class="simpleMessage">%s</div>\n' % message)
   503             self.w(u'<div class="simpleMessage">%s</div>\n' % message)
   504 
   504 
   505     def login_form(self, id):
   505     def login_form(self, id):
   506         _ = self._cw._
   506         _ = self._cw._
   507         self.w(u'<form method="post" action="%s" id="login_form">\n'
   507         self.w(u'<form method="post" action="%s" id="login_form">\n'
   508                % xml_escape(login_form_url(self._cw.config, self._cw)))
   508                % xml_escape(login_form_url(self._cw.vreg.config, self._cw)))
   509         self.w(u'<table>\n')
   509         self.w(u'<table>\n')
       
   510         self.add_fields()
   510         self.w(u'<tr>\n')
   511         self.w(u'<tr>\n')
   511         msg = (self._cw.config['allow-email-login'] and _('login or email')) or _('login')
       
   512         self.w(u'<td><label for="__login">%s</label></td>' % msg)
       
   513         self.w(u'<td><input name="__login" id="__login" class="data" type="text" /></td>')
       
   514         self.w(u'</tr><tr>\n')
       
   515         self.w(u'<td><label for="__password" >%s</label></td>' % _('password'))
       
   516         self.w(u'<td><input name="__password" id="__password" class="data" type="password" /></td>\n')
       
   517         self.w(u'</tr><tr>\n')
       
   518         self.w(u'<td>&#160;</td><td><input type="submit" class="loginButton right" value="%s" />\n</td>' % _('log in'))
   512         self.w(u'<td>&#160;</td><td><input type="submit" class="loginButton right" value="%s" />\n</td>' % _('log in'))
   519         self.w(u'</tr>\n')
   513         self.w(u'</tr>\n')
   520         self.w(u'</table>\n')
   514         self.w(u'</table>\n')
   521         self.w(u'</form>\n')
   515         self.w(u'</form>\n')
   522         self._cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
   516         self._cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
       
   517 
       
   518     def add_fields(self):
       
   519         msg = (self._cw.vreg.config['allow-email-login'] and _('login or email')) or _('login')
       
   520         self.add_field('__login', msg, 'text')
       
   521         self.add_field('__password', self._cw._('password'), 'password')
       
   522 
       
   523     def add_field(self, name, label, inputtype):
       
   524         self.w(u'<tr>\n')
       
   525         self.w(u'<td><label for="%s" >%s</label></td>' % (name, label))
       
   526         self.w(u'<td><input name="%s" id="%s" class="data" type="%s" /></td>\n' %
       
   527                (name, name, inputtype))
       
   528         self.w(u'</tr>\n')
   523 
   529 
   524 
   530 
   525 def login_form_url(config, req):
   531 def login_form_url(config, req):
   526     if req.https:
   532     if req.https:
   527         return req.url()
   533         return req.url()