[views] link to public url when trying https without an account stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Fri, 23 Jul 2010 17:54:18 +0200
branchstable
changeset 6005 0300fae1f7cb
parent 6004 d17d3b34bc12
child 6006 54cdc0164193
[views] link to public url when trying https without an account
web/views/basetemplates.py
--- a/web/views/basetemplates.py	Wed Jul 21 12:46:21 2010 +0200
+++ b/web/views/basetemplates.py	Fri Jul 23 17:54:18 2010 +0200
@@ -91,6 +91,7 @@
         return 0
     return view.templatable
 
+
 class NonTemplatableViewTemplate(MainTemplate):
     """main template for any non templatable views (xml, binaries, etc.)"""
     __regid__ = 'main-template'
@@ -472,10 +473,15 @@
         self.w(u'<div id="loginContent">\n')
         if showmessage and self._cw.message:
             self.w(u'<div class="loginMessage">%s</div>\n' % self._cw.message)
-        if self._cw.vreg.config['auth-mode'] != 'http':
-            # Cookie authentication
-            self.login_form(id)
-        self.w(u'</div></div>\n')
+        config = self._cw.vreg.config
+        if config['auth-mode'] != 'http':
+            self.login_form(id) # Cookie authentication
+        self.w(u'</div>')
+        if self._cw.https and config.anonymous_user()[0]:
+            path = config['base-url'] + self._cw.relative_path()
+            self.w(u'<div class="loginMessage"><a href="%s">%s</a></div>\n'
+                   % (path, self._cw._('No account? Try public access at %s') % path))
+        self.w(u'</div>\n')
 
     def login_form(self, id):
         cw = self._cw
@@ -490,6 +496,7 @@
 
 LogFormTemplate = class_renamed('LogFormTemplate', LogFormView)
 
+
 def login_form_url(req):
     if req.https:
         return req.url()