web/views/basetemplates.py
changeset 8311 76a44a0d7f4b
parent 8310 87f2f18a77ef
child 8324 75694a61f089
equal deleted inserted replaced
8310:87f2f18a77ef 8311:76a44a0d7f4b
   445         # cls.__dict__['form_buttons'] = form_buttons
   445         # cls.__dict__['form_buttons'] = form_buttons
   446         return form_buttons
   446         return form_buttons
   447 
   447 
   448     def form_action(self):
   448     def form_action(self):
   449         if self.action is None:
   449         if self.action is None:
   450             return login_form_url(self._cw)
   450             # reuse existing redirection if it exist
       
   451             target = self._cw.form.get('postlogin_path',
       
   452                                        self._cw.relative_path())
       
   453             return self._cw.build_url('login', __secure__=True,
       
   454                                       postlogin_path=target)
   451         return super(LogForm, self).form_action()
   455         return super(LogForm, self).form_action()
   452 
   456 
   453 class LogForm(BaseLogForm):
   457 class LogForm(BaseLogForm):
   454     """Simple login form that send username and password
   458     """Simple login form that send username and password
   455     """
   459     """
   505         form.field_by_name('__login').label = label
   509         form.field_by_name('__login').label = label
   506         form.render(w=self.w, table_class='', display_progress_div=False)
   510         form.render(w=self.w, table_class='', display_progress_div=False)
   507         cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
   511         cw.html_headers.add_onload('jQuery("#__login:visible").focus()')
   508 
   512 
   509 LogFormTemplate = class_renamed('LogFormTemplate', LogFormView)
   513 LogFormTemplate = class_renamed('LogFormTemplate', LogFormView)
   510 
       
   511 
       
   512 def login_form_url(req):
       
   513     if req.https:
       
   514         return req.url()
       
   515     httpsurl = req.vreg.config.get('https-url')
       
   516     if httpsurl:
       
   517         return req.url().replace(req.base_url(), httpsurl)
       
   518     return req.url()