[saem-devel] [PATCH 07 of 10 sherpa] Add application message to the main template

Sylvain Thenault sylvain.thenault at logilab.fr
Thu Feb 23 09:32:56 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1487798810 -3600
#      Wed Feb 22 22:26:50 2017 +0100
# Node ID 4d69e4c3c881985b045270cc48ff21f3e6cf6bf6
# Parent  44f2f21e5e96f856780132ffa8be9d946a37e576
Add application message to the main template

so we get error messages and other information.

diff --git a/views/templates.py b/views/templates.py
--- a/views/templates.py
+++ b/views/templates.py
@@ -66,10 +66,14 @@ class SherpaMainTemplate(basetemplates.T
                 w(u'<li>')
                 component.render(w=w)
                 w(u'</li>')
             w(u'</ul>')
         right_header_component = stream.getvalue()
+        # application message
+        msgcomp = self._cw.vreg['components'].select_or_none(
+            'applmessages', self._cw, rset=self.cw_rset)
+        application_message = msgcomp.render() if msgcomp else u''
         # breadcrumbs
         stream = UStringIO()
         w = stream.write
         components = self.get_components(view, context='header-center')
         if components:
@@ -81,10 +85,11 @@ class SherpaMainTemplate(basetemplates.T
         url = self._cw.build_url
         ctx.update({
             'title': view.page_title(),
             'page_content': view.render(),
             'breadcrumbs': breadcrumbs,
+            'application_message': application_message,
             'right_header_component': right_header_component,
             'left_boxes': left_boxes_html,
             'side_box': {
                 'goTo_links': [
                     {'url': url('sedalib'),
diff --git a/views/templates/maintemplate.jinja2 b/views/templates/maintemplate.jinja2
--- a/views/templates/maintemplate.jinja2
+++ b/views/templates/maintemplate.jinja2
@@ -41,10 +41,11 @@
           </ul>
         </div>
       </div>
     </aside>
     <div class="col-md-10 page-content" id="pageContent">
+      {{ application_message }}
       {{ page_content }}
     </div>
   </div>
   <div class="container-fluid">
     <footer role="contentinfo" id="pagefooter">


More information about the saem-devel mailing list