Add application message to the main template
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 22 Feb 2017 22:26:50 +0100
changeset 137 4d69e4c3c881
parent 136 44f2f21e5e96
child 138 b596d5cf6585
Add application message to the main template so we get error messages and other information.
views/templates.py
views/templates/maintemplate.jinja2
--- a/views/templates.py	Wed Feb 22 22:26:12 2017 +0100
+++ b/views/templates.py	Wed Feb 22 22:26:50 2017 +0100
@@ -68,6 +68,10 @@
                 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
@@ -83,6 +87,7 @@
             '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': {
--- a/views/templates/maintemplate.jinja2	Wed Feb 22 22:26:12 2017 +0100
+++ b/views/templates/maintemplate.jinja2	Wed Feb 22 22:26:50 2017 +0100
@@ -43,6 +43,7 @@
       </div>
     </aside>
     <div class="col-md-10 page-content" id="pageContent">
+      {{ application_message }}
       {{ page_content }}
     </div>
   </div>