Mercurial > hg > bts-webui
changeset 19:9724f1833add draft
Added bug page.
Fixed sorting in tables
author | marga |
---|---|
date | Mon, 16 Jul 2007 23:43:47 +0000 |
parents | be9653cc4931 |
children | bdac3aa9ee4b |
files | bts_webui/amancay/bts_queries.py bts_webui/amancay/static/amancay.css bts_webui/amancay/tables.py bts_webui/amancay/templates/bug.html bts_webui/amancay/urls.py bts_webui/amancay/views.py |
diffstat | 6 files changed, 114 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/bts_webui/amancay/bts_queries.py +++ b/bts_webui/amancay/bts_queries.py @@ -59,6 +59,10 @@ result = self.server.get_bugs("maint",emails) return result + def get_bug_log(self, bug): + result = self.server.get_bug_log(bug) + return result + def get_tagged_bugs(self, users): # TODO: ask Don to allow many users at the same time result = {} @@ -68,6 +72,15 @@ # ************************ LDAP Queries ***************************** +# Is it worth it? + +# ************************ Sorting Functions ************************ + +class bug_sort: + + def cmp_log_modified (x, y): + return cmp(x["log_modified"], y["log_modified"]) + + cmp_log_modified = staticmethod(cmp_log_modified) -
--- a/bts_webui/amancay/static/amancay.css +++ b/bts_webui/amancay/static/amancay.css @@ -397,6 +397,37 @@ font-weight: normal; } +/* Bug Page */ +div.bug_log { + + +} +span.bug_log_title { + font-size: medium; + font-weight: bold; + color: #047F54; +} +div.bug_log_item { + margin-top: 1em; + border: 1px solid #a3b8a7; + margin-right: 2em; + font-size: 0.9em; +} +div.bug_log_header { + background: #c8e5d6; + padding: 0.4em; +} +span.bug_log_from { +} +span.bug_log_date { +} +span.bug_log_subject { +} +div.bug_log_body { + padding: 0.4em; +} + + /* Registration */ div.account_form {
--- a/bts_webui/amancay/tables.py +++ b/bts_webui/amancay/tables.py @@ -15,7 +15,7 @@ from django.utils import simplejson # Needed for SOAP -from bts_queries import soap_queries +from bts_queries import soap_queries, bug_sort queries = soap_queries() # Toolboxes @@ -25,6 +25,7 @@ def render_bug_table(request, queries, title, bugs, amount, current_view): if (bugs != None and len(bugs) > 0): bug_list = queries.get_bugs_status(bugs[:amount]) + bug_list.sort(bug_sort.cmp_log_modified, reverse=True) else: bug_list = None if (request.GET.has_key('xhr')): @@ -62,6 +63,9 @@ submitter_emails = request.session.get('submitter_emails') if (submitter_emails): bugs = queries.get_submitters_bugs(submitter_emails) + print bugs + bugs.sort(reverse=True) + print bugs return render_bug_table(request, queries, "Latest submitted bugs", bugs, 15, "submitted_bugs")
--- a/bts_webui/amancay/templates/bug.html +++ b/bts_webui/amancay/templates/bug.html @@ -1,10 +1,30 @@ +{% load template_filters %} {% extends "base.html" %} -{% block title %}Amancay BTS interface - Bug view{% endblock %} +{% block title %}Amancay BTS interface - Bug View{% endblock %} {% block main_content %} +<div class="bug_log"> +<span class="bug_log_title">Bug {{ bug_number }}</span> +{% if bug_messages %} +{% for message in bug_messages %} +<div class="bug_log_item"> + <div class="bug_log_header"> + <span class="bug_log_from"><a + href="mailto:{{ message.from.1 }}">{{ message.from.0 }}</a></span> + <span class="bug_log_date">said on {{ message.date|tstodate }}:<br/></span> + <span class="bug_log_subject">{{ message.subject }}</span> + </div> + <div class="bug_log_body"> + <pre>{{ message.body }}</pre> + </div> +</div> + {% endfor %} +{% endif %} +</div> {% endblock %} + {% block footer %} <p align="right"> {% if current_user.is_authenticated %}
--- a/bts_webui/amancay/urls.py +++ b/bts_webui/amancay/urls.py @@ -19,6 +19,7 @@ # Inside pages (r'^package/(?P<package_name>\w+)', 'bts_webui.amancay.views.package',), + (r'^bug/(?P<bug_number>\d+)', 'bts_webui.amancay.views.bug',), # Small pieces (r'^add_package', 'bts_webui.amancay.views.add_package',),
--- a/bts_webui/amancay/views.py +++ b/bts_webui/amancay/views.py @@ -54,3 +54,45 @@ 'current_user': user} ) +# The bug page uses regular expresions to parse the log +import re +# The bug page uses rfc822 to parse emails, dates, etc. +import rfc822 + +def bug(request, bug_number): + + user = request.user + queries = soap_queries() + bug_log = queries.get_bug_log(bug_number) + + # Regular expressions to parse the mails + from_re = re.compile('^From: ?(.+)$', re.MULTILINE) + subject_re = re.compile('^Subject: ?(.+)$', re.MULTILINE) + date_re = re.compile('^Date: ?(.+)$', re.MULTILINE) + + bug_messages = [] + for item in bug_log: + message = {} + # Parse the header + from_value = from_re.findall(item["header"]) + subject_value = subject_re.findall(item["header"]) + date_value = date_re.findall(item["header"]) + # Filter the values + if (len(from_value) > 0): + message["from"] = rfc822.parseaddr(from_value[0]) + if (len(subject_value) > 0): + message["subject"] = subject_value[0] + if (len(date_value) > 0): + message["date"] = rfc822.mktime_tz(rfc822.parsedate_tz( + date_value[0])) + + # Get the body + message["body"] = item["body"] + bug_messages.append(message) + + return render_to_response('bug.html', + {'bug_number': bug_number, + 'bug_messages': bug_messages, + 'current_user': user} + ) +