Author: matevz Date: Tue Apr 30 10:58:59 2013 New Revision: 1477551 URL: http://svn.apache.org/r1477551 Log: Ticket relations widget - initial implementation
Added: bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html Modified: bloodhound/trunk/bloodhound_dashboard/setup.py bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html Added: bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py?rev=1477551&view=auto ============================================================================== --- bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py (added) +++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py Tue Apr 30 10:58:59 2013 @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +r"""Project dashboard for Apache(TM) Bloodhound + +Widgets displaying ticket relations. +""" + +from trac.resource import get_resource_url +from trac.util.translation import _ +from trac.ticket.model import Ticket + +from bhdashboard.util import WidgetBase, check_widget_name, pretty_wrapper + +from bhrelations.api import RelationsSystem + + +__metaclass__ = type + +class TicketRelationsWidget(WidgetBase): + """Display ticket relations. + """ + def get_widget_params(self, name): + """Return a dictionary containing arguments specification for + the widget with specified name. + """ + return { + 'tid' : { + 'desc' : """Source ticket id""", + 'type' : int + }, + + 'max' : { + 'desc' : """Limit the number of relations displayed""", + 'type' : int + }, + } + + get_widget_params = pretty_wrapper(get_widget_params, check_widget_name) + + def render_widget(self, name, context, options): + """Gather list of relations and render data in compact view + """ + data = {} + req = context.req + title = None + params = ('tid', 'max') + tid, max_ = self.bind_params(name, options, *params) + + ticket = Ticket(self.env, tid) + relations = RelationsSystem(self.env).get_relations(ticket) + grouped_relations = {} + if relations: + title = _('Related tickets') + for r in relations: + r['desthref'] = get_resource_url(self.env, r['destination'], + context.href) + grouped_relations.setdefault(r['type'], []).append(r) + + data['relations'] = grouped_relations + + return 'widget_relations.html', \ + { 'title': title, 'data': data, }, context + + render_widget = pretty_wrapper(render_widget, check_widget_name) + Added: bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html?rev=1477551&view=auto ============================================================================== --- bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html (added) +++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html Tue Apr 30 10:58:59 2013 @@ -0,0 +1,32 @@ +<!--! + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +<div + xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/" + xmlns:xi="http://www.w3.org/2001/XInclude"> + + <py:for each="relgroup,items in relations.iteritems()"> + <h4>$relgroup</h4> + <div py:for="item in items"> + <a href="${item['desthref']}">#${item['destination'].id}</a> - $item.comment + </div> + </py:for> +</div> + Modified: bloodhound/trunk/bloodhound_dashboard/setup.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/setup.py?rev=1477551&r1=1477550&r2=1477551&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_dashboard/setup.py (original) +++ bloodhound/trunk/bloodhound_dashboard/setup.py Tue Apr 30 10:58:59 2013 @@ -125,6 +125,7 @@ ENTRY_POINTS = r""" bhdashboard.widgets.product = bhdashboard.widgets.product bhdashboard.widgets.query = bhdashboard.widgets.query bhdashboard.widgets.report = bhdashboard.widgets.report + bhdashboard.widgets.ticketrelations = bhdashboard.widgets.relations bhdashboard.widgets.ticket = bhdashboard.widgets.ticket bhdashboard.widgets.timeline = bhdashboard.widgets.timeline bhdashboard.wiki = bhdashboard.wiki Modified: bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css?rev=1477551&r1=1477550&r2=1477551&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css (original) +++ bloodhound/trunk/bloodhound_theme/bhtheme/htdocs/bloodhound.css Tue Apr 30 10:58:59 2013 @@ -288,6 +288,11 @@ pre { width: 100%; } +.relations { + margin-top: 30px; + margin-bottom: 30px; +} + /* @end */ /* @group Quick Create Ticket popup */ Modified: bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html?rev=1477551&r1=1477550&r2=1477551&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html (original) +++ bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_ticket.html Tue Apr 30 10:58:59 2013 @@ -408,6 +408,14 @@ </div> <div id="dummy-vc-summary" style="display: none"/> + <div py:if="ticket.exists" class="relations"> + <bh:widget urn="TicketRelations"> + <bh:args> + <bh:arg name="tid">$ticket.id</bh:arg> + <bh:arg name="max">20</bh:arg> + </bh:args> + </bh:widget> + </div> </div> </div> </form>