aboutsummaryrefslogtreecommitdiffstats
path: root/cfbe.py
blob: 4509bf18e4bfa4279b3f6e830250f01c931bff75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python

import cherrypy
from libbe import bugdir
from jinja2 import Environment, FileSystemLoader

bug_root = '/Users/sjl/Documents/cherryflavoredbugseverywhere/.be'
bd = bugdir.BugDir(root=bug_root)
bd.load_all_bugs()
repository_name = bd.root.split('/')[-1]

template_root = '/Users/sjl/Documents/cherryflavoredbugseverywhere/templates'
env = Environment(loader=FileSystemLoader(template_root))

class WebInterface:
    """The web interface to CFBE."""
    
    @cherrypy.expose
    def index(self, status='open', assignee='', target=''):
        bd.load_all_bugs()
        
        if status == 'open':
            status = ['open', 'assigned', 'test', 'unconfirmed', 'wishlist']
            label = 'All Open Bugs'
        elif status == 'closed':
            status = ['closed', 'disabled', 'fixed', 'wontfix']
            label = 'All Closed Bugs'
            
        if assignee != '':
            if assignee == 'None':
                label += ' Currently Unassigned'
            else:
                label += ' Assigned to %s' % (assignee,)
        
        if target != '':
            if target == 'None':
                label += ' Currently Unschdeuled'
            else:
                label += ' Scheduled for %s' % (target,)
        
        
        template = env.get_template('list.html')
        
        possible_assignees = list(set([bug.assigned for bug in bd if bug.assigned != None]))
        possible_assignees.sort(key=unicode.lower)
        
        possible_targets = list(set([bug.target for bug in bd if bug.target != None]))
        possible_targets.sort(key=unicode.lower)
        
        bugs = [bug for bug in bd if bug.status in status]
        
        if assignee != '':
            if assignee == 'None':
                assignee = None
            bugs = [bug for bug in bugs if bug.assigned == assignee]
        
        if target != '':
            if target == 'None':
                target = None
            bugs = [bug for bug in bugs if bug.target == target]
        
        return template.render(bugs=bugs, bd=bd, label=label, 
                               assignees=possible_assignees,
                               targets=possible_targets,
                               repository_name=repository_name)
    

config = '/Users/sjl/Documents/cherryflavoredbugseverywhere/cfbe.config'
cherrypy.quickstart(WebInterface(), '/', config)