--- a/src/pyams_security/views/login.py Thu Oct 08 09:28:33 2015 +0200
+++ b/src/pyams_security/views/login.py Thu Oct 08 09:29:17 2015 +0200
@@ -16,9 +16,13 @@
# import standard library
# import interfaces
+from pyams_form.interfaces.form import IFormHeaderViewletsManager, IFormPrefixViewletsManager, \
+ IFormSuffixViewletsManager
from pyams_security.interfaces import ILoginView, ISecurityManager, LOGIN_REFERER_KEY
from pyams_skin.interfaces import IModalFullPage
+from pyams_skin.interfaces.configuration import IBackOfficeConfiguration
from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces.site import IConfigurationManager
from z3c.form.interfaces import IDataExtractedEvent
# import packages
@@ -26,7 +30,11 @@
from pyams_form.schema import ResetButton, CloseButton
from pyams_pagelet.pagelet import pagelet_config
from pyams_security.credential import Credentials
+from pyams_template.template import template_config
from pyams_utils.registry import query_utility
+from pyams_utils.text import text_to_html
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import viewlet_config, Viewlet
from pyramid.events import subscriber
from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
@@ -129,6 +137,50 @@
return status
+@viewlet_config(name='header', context=Interface, layer=IPyAMSLayer, view=LoginForm, manager=IFormHeaderViewletsManager)
+@template_config(template='templates/login-header.pt', layer=IPyAMSLayer)
+class LoginFormHeaderViewlet(Viewlet):
+ """Login form header viewlet"""
+
+
+@viewlet_config(name='form_prefix', context=Interface, layer=IPyAMSLayer, view=LoginForm,
+ manager=IFormPrefixViewletsManager)
+class LoginFormPrefixViewlet(Viewlet):
+ """Login form prefix viewlet"""
+
+ def __new__(cls, context, request, view, manager):
+ manager = get_parent(context, IConfigurationManager)
+ if manager is not None:
+ config = IBackOfficeConfiguration(manager)
+ if not config.login_header:
+ return None
+ return Viewlet.__new__(cls)
+
+ def render(self):
+ manager = get_parent(self.context, IConfigurationManager)
+ config = IBackOfficeConfiguration(manager)
+ return text_to_html(config.login_header, renderer='rest')
+
+
+@viewlet_config(name='form_suffix', context=Interface, layer=IPyAMSLayer, view=LoginForm,
+ manager=IFormSuffixViewletsManager)
+class LoginFormSuffixViewlet(Viewlet):
+ """Login form suffix viewlet"""
+
+ def __new__(cls, context, request, view, manager):
+ manager = get_parent(context, IConfigurationManager)
+ if manager is not None:
+ config = IBackOfficeConfiguration(manager)
+ if not config.login_footer:
+ return None
+ return Viewlet.__new__(cls)
+
+ def render(self):
+ manager = get_parent(self.context, IConfigurationManager)
+ config = IBackOfficeConfiguration(manager)
+ return text_to_html(config.login_footer, renderer='rest')
+
+
@forbidden_view_config(request_type=IPyAMSLayer, renderer='json', xhr=True)
def ForbiddenAJAXView(request):
"""AJAX call forbidden view"""
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_security/views/templates/login-header.pt Thu Oct 08 09:29:17 2015 +0200
@@ -0,0 +1,11 @@
+<tal:var i18n:domain="pyams_security">
+ <h3 class="modal-title"
+ tal:define="config extension:configuration;
+ back_config extension:back_configuration;">
+ <tal:if condition="config.logo">
+ <img tal:define="href extension:absolute_url(config.logo)"
+ tal:attributes="src string:${href}/++thumb++200x70.png;">
+ </tal:if>
+ <span class="title" tal:content="i18n:back_config.title">Title</span>
+ </h3>
+</tal:var>