From 820d3ef241408b15e44603e73b76624eed3f5dcb Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Fri, 10 May 2013 12:16:57 +0200 Subject: [PATCH] [gen] Added Config.discreetLogin allowing to put a discreet link on the main page for logging in, instead of the login form in the central strip, for sites where logged users do not represent the majority of visitors (only some admins). --- __init__.py | 1 + gen/__init__.py | 4 ++ gen/generator.py | 1 + gen/mixins/ToolMixin.py | 8 ++- gen/templates/config.pyt | 1 + gen/ui/appy.css | 10 +-- gen/ui/appy.js | 9 +++ gen/ui/appyrtl.css | 1 + gen/ui/icons.pt | 3 +- gen/ui/template.pt | 139 ++++++++++++++++-------------------- gen/wrappers/UserWrapper.py | 3 +- 11 files changed, 94 insertions(+), 86 deletions(-) diff --git a/__init__.py b/__init__.py index f759e96..f769dc6 100644 --- a/__init__.py +++ b/__init__.py @@ -38,4 +38,5 @@ class Object: return res.encode('utf-8') def __nonzero__(self): return bool(self.__dict__) + def get(self, name, default=None): return getattr(self, name, default) # ------------------------------------------------------------------------------ diff --git a/gen/__init__.py b/gen/__init__.py index 006121d..07a3d58 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -3013,6 +3013,10 @@ class Config: self.activateForgotPassword = True # Enable session timeout? self.enableSessionTimeout = False + # If the following field is True, the login/password widget will be + # discreet. This is for sites where authentication is not foreseen for + # the majority of visitors (just for some administrators). + self.discreetLogin = False # When using Ogone, place an instance of appy.gen.ogone.OgoneConfig in # the field below. self.ogone = None diff --git a/gen/generator.py b/gen/generator.py index 863a8c4..0fa414b 100644 --- a/gen/generator.py +++ b/gen/generator.py @@ -604,6 +604,7 @@ class ZopeGenerator(Generator): repls['languageSelector'] = self.config.languageSelector repls['sourceLanguage'] = self.config.sourceLanguage repls['enableSessionTimeout'] = self.config.enableSessionTimeout + repls['discreetLogin'] = self.config.discreetLogin repls['ogone'] = repr(self.config.ogone) repls['googleAnalyticsId'] = repr(self.config.googleAnalyticsId) repls['activateForgotPassword'] = self.config.activateForgotPassword diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index 66208b7..558de41 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -89,9 +89,13 @@ class ToolMixin(BaseMixin): 'inline;filename="%s"' % res.name) return res.content - def getAttr(self, name): + def getAttr(self, name, source='appy'): '''Gets attribute named p_name.''' - return getattr(self.appy(), name, None) + if source == 'config': + obj = self.getProductConfig() + else: + obj = self.appy() + return getattr(obj, name, None) def getAppName(self): '''Returns the name of the application.''' diff --git a/gen/templates/config.pyt b/gen/templates/config.pyt index e0cb77e..6d1296c 100644 --- a/gen/templates/config.pyt +++ b/gen/templates/config.pyt @@ -49,6 +49,7 @@ languageSelector = sourceLanguage = '' activateForgotPassword = enableSessionTimeout = +discreetLogin = ogone = googleAnalyticsId = diff --git a/gen/ui/appy.css b/gen/ui/appy.css index a0b8753..08b570d 100644 --- a/gen/ui/appy.css +++ b/gen/ui/appy.css @@ -55,15 +55,15 @@ img { border: 0; vertical-align: middle } border-style: solid; border-width: 1px; border-color: grey } .top { height: 89px; margin-left: 3em; vertical-align: top } .lang { margin-right: 6px } -.userStrip { background-color: #6282B3; height: 35px; - border-top: 3px solid #034984; border-bottom: 2px solid #034984 } +.userStrip { background-color: #6282B3; border-top: 3px solid #034984; + border-bottom: 2px solid #034984 } .userStripText { padding: 0 0.3em 0 0.3em; color: white } .userStrip a { color: #e7e7e7 } .userStrip a:visited { color: #e7e7e7 } .navigate { border-bottom: 1px solid #5F7983; background-color: #dbdde1; font-weight: bold } .navigate td { padding: 4px 9px } -.login { margin-top: 2px; margin-bottom: 2px; color: black } +.login { margin: 3px; color: black } .buttons { margin-left: 4px } .fakeButton { border: 1px solid #D7DEE4; background-color: #fde8e0; padding: 0px 8px 2px; @@ -79,7 +79,7 @@ img { border: 0; vertical-align: middle } .discreet { font-size: 90%; color: grey } .title { color: #BA9440 } .breadcrumb { color: #BA9440; font-size: 13px } -.lostPassword a { font-size: 90%; color: white; padding-left: 1em } +.lostPassword { font-size: 90%; color: white; padding-left: 1em } .portlet { width: 150px; border-right: 1px solid #5F7983; background-color: #ededed } .portletContent { margin: 4px 9px } @@ -133,7 +133,7 @@ img { border: 0; vertical-align: middle } .history th { font-style: italic; text-align: left; padding: 0 5px 0 5px } .topSpace { margin-top: 15px } .bottomSpace { margin-bottom: 15px } -.pageLink { padding-left: 8px } +.pageLink { margin-right: 8px } .footer { font-size: 95% } .footer td { background-color: #CBCBC9; border-top: 1px solid grey; padding: 0.4em 1em 0.5em } diff --git a/gen/ui/appy.js b/gen/ui/appy.js index a8fe372..776adec 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -32,6 +32,15 @@ function setLoginVars() { else emptyPassword.value = '0'; } +function showLoginForm() { + // Hide the login link. + var loginLink = document.getElementById('loginLink'); + loginLink.style.display = "none"; + // Displays the login form. + var loginFields = document.getElementById('loginFields'); + loginFields.style.display = "inline"; +} + var isIe = (navigator.appName == "Microsoft Internet Explorer"); function getElementsHavingName(tag, name) { diff --git a/gen/ui/appyrtl.css b/gen/ui/appyrtl.css index fa1d7df..1a2efa9 100644 --- a/gen/ui/appyrtl.css +++ b/gen/ui/appyrtl.css @@ -5,3 +5,4 @@ ul li { background-image: url("ui/lirtl.gif"); .portlet { border-right: none; border-left: 1px solid #5F7983 } .lang { margin-right: 0px; margin-left: 6px; } .cellGap { padding-left: 0.4em; padding-right: 0;} +.pageLink { margin-right: 0px; margin-left: 8px } diff --git a/gen/ui/icons.pt b/gen/ui/icons.pt index dbf8d58..23416d9 100644 --- a/gen/ui/icons.pt +++ b/gen/ui/icons.pt @@ -1 +1,2 @@ - + + diff --git a/gen/ui/template.pt b/gen/ui/template.pt index 0724446..4ba932a 100644 --- a/gen/ui/template.pt +++ b/gen/ui/template.pt @@ -15,6 +15,7 @@ layoutType tool/getLayoutType; contextObj python: tool.getPublishedObject(layoutType); dir python: tool.getLanguageDirection(lang); + discreetLogin python: tool.getAttr('discreetLogin', source='config'); dleft python: (dir == 'ltr') and 'left' or 'right'; dright python: (dir == 'ltr') and 'right' or 'left'; x python: resp.setHeader('Content-type', 'text/html;;charset=UTF-8'); @@ -39,7 +40,6 @@ type="text/javascript" tal:content="gaCode"> Grey background shown when popups are shown
- Popup for confirming an action