Add tag filter on the web interface
authorIsrael Basurto <ibasurto@gmail.com>
Sat, 24 Mar 2012 12:22:11 +0000 (13:22 +0100)
committerW. Trevor King <wking@drexel.edu>
Sun, 25 Mar 2012 15:37:16 +0000 (11:37 -0400)
interfaces/web/static/style/cfbe.css
interfaces/web/templates/base.html
interfaces/web/web.py

index c5f726eaa978066e21b69acf0b1673fad3585e84..2d7b90b65835297fd98320775b2a2e91b5885a48 100644 (file)
@@ -106,7 +106,7 @@ tr.stripe {
     background-color: #fcecf8;
 }
 
-div#assignees, div#targets {
+div#assignees, div#targets, div#tags {
     display: none;
 }
 
index 9666d3e23bdfffd2703995d1991c47fccd017b06..9c7c7edae33a740e776fc02f0df838129d9d1316 100644 (file)
                     e.preventDefault();
                 });
                 
+                $('#filter-tag').click(function(e) {
+                    $('#filter-pane').html($('#tags').html());
+                    $('#filter-pane').fadeIn('fast');
+                    e.preventDefault();
+                });
+                
                 $('#create-bug').click(function(e) {
                     $('#create-bug').hide();
                     $('#create-form').fadeIn('fast');
@@ -56,6 +62,7 @@
                     <a href="/?status=closed">Closed</a>
                     <a href="" id="filter-assignee">Assigned to...</a>
                     <a href="" id="filter-target">Scheduled for...</a>
+                    <a href="" id="filter-tag">Tags...</a>
                 </span>
                 <span id="create">
                     <a href="" id="create-bug">&#43; Create a new bug</a>
                 {% endfor %}
             </ul>
         </div>
-    </body>
+        <div id="tags">
+            <ul class="filter-items">
+                <li><a href="/?tag=None">All</a></li>
+               {% for tag in tags %}
+                    <li><a href="/?tag={{ tag }}">{{ tag }}</a></li>
+                {% endfor %}
+            </ul>
+        </div>        
+   </body>
 </html>
index a99758cd174de6dc42c7cf9cf3500fb469d528ac..e50c0b15aaac7774074b878e9dec28f91aa18d31 100644 (file)
@@ -11,7 +11,7 @@ from libbe.command.target import add_target, remove_target
 from libbe.command.target import bug_from_target_summary, bug_target
 from libbe.command.util import bug_comment_from_user_id
 from libbe.storage.util import settings_object
-
+import libbe.command.tag
 
 EMPTY = settings_object.EMPTY
 
@@ -57,15 +57,19 @@ class WebInterface:
                 'possible_targets': possible_targets,
                 'possible_statuses': possible_statuses,
                 'possible_severities': possible_severities,
+                'tags': libbe.command.tag.get_all_tags(self.bd),
                 'repository_name': self.repository_name,}
     
-    def filter_bugs(self, status, assignee, target):
+    def filter_bugs(self, status, assignee, target, tag):
         """Filter the list of bugs to return only those desired."""
         bugs = [bug for bug in self.bd if bug.status in status]
         
         if assignee != '':
             assignee = None if assignee == 'None' else assignee
             bugs = [bug for bug in bugs if bug.assigned == assignee]
+
+        if tag != '' and tag!= 'None':
+            bugs = [bug for bug in bugs if tag in libbe.command.tag.get_tags(bug)]
         
         if target != '':
             target = None if target == 'None' else target
@@ -79,11 +83,12 @@ class WebInterface:
                     return []
                 bugs = [bug for bug in get_blocked_by(self.bd, targetbug) if
                         bug.active]
+        
         return bugs
     
     
     @cherrypy.expose
-    def index(self, status='open', assignee='', target=''):
+    def index(self, status='open', assignee='', target='', tag=''):
         """The main bug page.
         Bugs can be filtered by assignee or target.
         The bug database will be reloaded on each visit."""
@@ -102,9 +107,11 @@ class WebInterface:
                 else ' Assigned to %s' % (assignee,)
         if target != '':
             label += ' Currently Unscheduled' if target == 'None' \
-                else ' Scheduled for %s' % (target,)
+                else ' Scheduled for %s' % (target,)        
+        if tag != '' and tag != 'None':
+            label += ' Tagged %s' % (tag,)
         
-        bugs = self.filter_bugs(status, assignee, target)
+        bugs = self.filter_bugs(status, assignee, target, tag)
         if len(bugs) == 0:
             template = self.env.get_template('empty-list.html')
         else:
@@ -117,6 +124,7 @@ class WebInterface:
                                statuses=common_info['possible_statuses'],
                                severities=common_info['possible_severities'],
                                repository_name=common_info['repository_name'],
+                               tags=common_info['tags'],
                                urlencode=urlencode)