import cherrypy
from libbe import bugdir
from jinja2 import Environment, FileSystemLoader
+from datetime import datetime
+def datetimeformat(value, format='%B %d, %Y at %I:%M %p'):
+ return datetime.fromtimestamp(value).strftime(format)
+
template_root = '/Users/sjl/Documents/cherryflavoredbugseverywhere/templates'
env = Environment(loader=FileSystemLoader(template_root))
+env.filters['datetimeformat'] = datetimeformat
class WebInterface:
"""The web interface to CFBE."""
self.bd = bugdir.BugDir(root=self.bug_root)
self.repository_name = self.bd.root.split('/')[-1]
- def get_common_information(self, assignee, target):
+ def get_common_information(self):
possible_assignees = list(set([bug.assigned for bug in self.bd if bug.assigned != None]))
possible_assignees.sort(key=unicode.lower)
possible_targets.sort(key=unicode.lower)
return {'possible_assignees': possible_assignees,
- 'possible_targets': possible_targets,}
+ 'possible_targets': possible_targets,
+ 'repository_name': self.repository_name,}
def filter_bugs(self, status, assignee, target):
"""Filter the list of bugs to return only those desired."""
template = env.get_template('list.html')
bugs = self.filter_bugs(status, assignee, target)
- common_info = self.get_common_information(assignee, target)
+ common_info = self.get_common_information()
return template.render(bugs=bugs, bd=self.bd, label=label,
assignees=common_info['possible_assignees'],
targets=common_info['possible_targets'],
- repository_name=self.repository_name)
+ repository_name=common_info['repository_name'])
+ @cherrypy.expose
+ def bug(self, id=''):
+ """The page for viewing a single bug."""
+
+ self.bd.load_all_bugs()
+
+ bug = self.bd.bug_from_shortname(id)
+
+ template = env.get_template('bug.html')
+ common_info = self.get_common_information()
+ return template.render(bug=bug, bd=self.bd,
+ assignees=common_info['possible_assignees'],
+ targets=common_info['possible_targets'],
+ repository_name=common_info['repository_name'])
+
config = '/Users/sjl/Documents/cherryflavoredbugseverywhere/cfbe.config'
bug_root = '/Users/sjl/Documents/cherryflavoredbugseverywhere/.be'
tr.stripe { background-color: #f5e5f0; }
div#assignees, div#targets { display: none; }
+
+p.creation-info { color: #888; }
+span.detail-field-header { font-weight: 700; width: 7.5em; padding-right: 1em; display: inline-block; text-align: right; }
+
+div.bug-comment { margin-left: 2em;}
+p.bug-comment-body { white-space: pre; margin: 0em 0em 0em 0em; }
+p.bug-comment-footer { margin: 0em 0em; color: #888; }
+h4.bug-comment-header { margin: 1.5em 0em 0em; }
\ No newline at end of file
--- /dev/null
+{% extends "base.html" %}
+
+{% block page_title %}
+ Bug {{ bd.bug_shortname(bug) }} – {{ bug.summary }}
+{% endblock %}
+
+{% block content %}
+ <p class="creation-info">Created on {{ bug.time|datetimeformat }} by {{ bug.creator|e }}</p>
+
+ <h3>Bug Details</h3>
+ <p>
+ <span class="detail-field-header">Status:</span>
+ <span class="detail-field-contents">{{ bug.status }}</span><br />
+
+ <span class="detail-field-header">Severity:</span>
+ <span class="detail-field-contents">{{ bug.severity }}</span><br />
+
+ <span class="detail-field-header">Scheduled for:</span>
+ <span class="detail-field-contents">{{ bug.target }}</span><br />
+
+ <span class="detail-field-header">Assigned to:</span>
+ <span class="detail-field-contents">{{ bug.assigned|e }}</span><br />
+
+ <span class="detail-field-header">Permanent ID:</span>
+ <span class="detail-field-contents">{{ bug.uuid }}</span><br />
+ </p>
+
+ <h3>Summary</h3>
+ <p>
+ {{ bug.summary }}
+ </p>
+
+ <h3>Comments</h3>
+ {% for comment in bug.comments() %}
+ <div class="bug-comment">
+ <h4 class="bug-comment-header">{{ comment.From|e }} said:</h4>
+ <p class="bug-comment-body">{{ comment.body|trim|e }}</p>
+ <p class="bug-comment-footer">on {{ comment.time|datetimeformat }}</p>
+ </div>
+ {% endfor %}
+{% endblock %}
\ No newline at end of file