nakamura avatar nakamura committed 60f4ae1

tai.service.web: add notification system

Comments (0)

Files changed (3)

tai/service/templates/base_logged_in.html

       </div>
     </div>
 
+    <div class="row-fluid fixed-size">
+        <div id="alert-container" class="span10 offset1">
+            {% for notification in handler.get_notifications() %}
+            <div class="alert alert-info">
+                <button type="button" class="close" data-dismiss="alert">&times;</button>
+                {{ notification }}
+            </div>
+            {% end %}
+        </div>
+    </div>
+
 {% block contents %}{% end %}
 
     <script src="{{ static_url('js/jquery.min.js') }}"></script>

tai/service/templates/chat.html

 
 {% block contents %}
     {% include "mustach-templates.html" %}
-    <div class="row-fluid fixed-size">
-        <div id="alert-container" class="span10 offset1">
-        </div>
-    </div>
 
     <div class="container-fluid" id="app-container">
         <div class="row-fluid">

tai/service/web.py

 
         return sess
 
+    def set_notifications(self, *notifications):
+        if self.current_session is None:
+            return
+
+        self.current_session.setdefault('notifications', []).extend(notifications)
+
+    def get_notifications(self):
+        if self.current_session is None:
+            return
+
+        return self.current_session.pop('notifications', [])
+
     def render_string(self, template, *args, **kwargs):
         if 'escape' not in kwargs:
             kwargs['escape'] = escape
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.