You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by ma...@apache.org on 2013/04/30 14:57:51 UTC

svn commit: r1477605 - in /bloodhound/trunk: bloodhound_dashboard/bhdashboard/widgets/ bloodhound_dashboard/bhdashboard/widgets/templates/ bloodhound_relations/ bloodhound_relations/bhrelations/ bloodhound_relations/bhrelations/templates/ bloodhound_th...

Author: matevz
Date: Tue Apr 30 12:57:50 2013
New Revision: 1477605

URL: http://svn.apache.org/r1477605
Log:
Skeleton for ticket relation management

Added:
    bloodhound/trunk/bloodhound_relations/bhrelations/templates/manage.html
    bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py
Modified:
    bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py
    bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html
    bloodhound/trunk/bloodhound_relations/setup.py
    bloodhound/trunk/bloodhound_theme/bhtheme/theme.py

Modified: bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py?rev=1477605&r1=1477604&r2=1477605&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py (original)
+++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/relations.py Tue Apr 30 12:57:50 2013
@@ -24,17 +24,15 @@ r"""Project dashboard for Apache(TM) Blo
 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
-
+from bhrelations.web_ui import RelationManagementModule
 
 __metaclass__ = type
 
+
 class TicketRelationsWidget(WidgetBase):
     """Display ticket relations.
     """
@@ -59,24 +57,17 @@ class TicketRelationsWidget(WidgetBase):
     def render_widget(self, name, context, options):
         """Gather list of relations and render data in compact view
         """
-        data = {}
         req = context.req
-        title = None
+        title = _('Related tickets')
         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
-
+        data = {
+            'ticket': ticket,
+            'relations': \
+                RelationManagementModule(self.env).get_ticket_relations(ticket),
+        }
         return 'widget_relations.html', \
             { 'title': title, 'data': data, }, context
 

Modified: 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=1477605&r1=1477604&r2=1477605&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html (original)
+++ bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_relations.html Tue Apr 30 12:57:50 2013
@@ -22,11 +22,24 @@
   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>
+  <py:choose test="">
+    <py:when test="relations">
+      <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>
+    </py:when>
+    <py:otherwise>
+      <div class="alert alert-info">
+        No defined relations for this ticket.
+      </div>
+    </py:otherwise>
+  </py:choose>
+
+  <div class="btn-group">
+    <a class="btn" href="${href.ticket(ticket.id, 'relations')}">Manage relations</a>
+  </div>
 </div>
 

Added: bloodhound/trunk/bloodhound_relations/bhrelations/templates/manage.html
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/templates/manage.html?rev=1477605&view=auto
==============================================================================
--- bloodhound/trunk/bloodhound_relations/bhrelations/templates/manage.html (added)
+++ bloodhound/trunk/bloodhound_relations/bhrelations/templates/manage.html Tue Apr 30 12:57:50 2013
@@ -0,0 +1,55 @@
+<!--!
+  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.
+-->
+
+<!DOCTYPE html
+    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:xi="http://www.w3.org/2001/XInclude"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:i18n="http://genshi.edgewall.org/i18n"
+      xmlns:bh="http://issues.apache.org/bloodhound/wiki/Ui/Dashboard">
+  <xi:include href="layout.html" />
+  <xi:include href="widget_macros.html" />
+
+  <head>
+    <title py:choose="">Ticket relations for #${ticket.id}</title>
+  </head>
+
+  <body>
+    <h1>Manage relations for ticket <a href="${href.ticket(ticket.id)}">#$ticket.id</a></h1>
+
+    <div class="row">
+      <div class="span8">
+        <div class="well">
+          <h4>Add relation</h4>
+        </div>
+      </div>
+    </div>
+
+    <div class="row">
+      <div class="span8">
+        <div class="well">
+          <h4>Remove relations</h4>
+        </div>
+      </div>
+    </div>
+  </body>
+</html>
+

Added: bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py?rev=1477605&view=auto
==============================================================================
--- bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py (added)
+++ bloodhound/trunk/bloodhound_relations/bhrelations/web_ui.py Tue Apr 30 12:57:50 2013
@@ -0,0 +1,81 @@
+#!/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"""Ticket relations for Apache(TM) Bloodhound
+
+Ticket relations user interface.
+"""
+
+import re
+import pkg_resources
+
+from trac.core import Component, implements, TracError
+from trac.resource import get_resource_url
+from trac.ticket.model import Ticket
+from trac.web import IRequestHandler
+from trac.web.chrome import ITemplateProvider
+
+from bhrelations.api import RelationsSystem
+
+
+class RelationManagementModule(Component):
+    implements(IRequestHandler, ITemplateProvider)
+
+    # IRequestHandler methods
+    def match_request(self, req):
+        match = re.match(r'/ticket/([0-9]+)/relations/*$', req.path_info)
+        if not match:
+            return False
+
+        req.args['id'] = match.group(1)
+        return True
+
+    def process_request(self, req):
+        tid = req.args.get('id')
+        if not tid:
+            raise TracError('No ticket id provided.')
+
+        req.perm.require('TICKET_VIEW')
+        ticket = Ticket(self.env, tid)
+        data = {
+            'ticket': ticket,
+            'relations': self.get_ticket_relations(ticket),
+        }
+        return 'manage.html', data, None
+
+    # ITemplateProvider methods
+    def get_htdocs_dirs(self):
+        resource_filename = pkg_resources.resource_filename
+        return [resource_filename('bhrelations', 'htdocs'), ]
+
+    def get_templates_dirs(self):
+        resource_filename = pkg_resources.resource_filename
+        return [resource_filename('bhrelations', 'templates'), ]
+
+    # utility functions
+    def get_ticket_relations(self, ticket):
+        grouped_relations = {}
+        for r in RelationsSystem(self.env).get_relations(ticket):
+            r['desthref'] = get_resource_url(self.env, r['destination'],
+                self.env.href)
+            grouped_relations.setdefault(r['type'], []).append(r)
+        return grouped_relations
+

Modified: bloodhound/trunk/bloodhound_relations/setup.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/setup.py?rev=1477605&r1=1477604&r2=1477605&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_relations/setup.py (original)
+++ bloodhound/trunk/bloodhound_relations/setup.py Tue Apr 30 12:57:50 2013
@@ -104,6 +104,7 @@ PKG_INFO = {'bhrelations': ('bhrelations
 ENTRY_POINTS = {
     'trac.plugins': [
         'bhrelations.api = bhrelations.api',
+        'bhrelations.web_ui = bhrelations.web_ui',
     ],
     }
 setup(

Modified: bloodhound/trunk/bloodhound_theme/bhtheme/theme.py
URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_theme/bhtheme/theme.py?rev=1477605&r1=1477604&r2=1477605&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_theme/bhtheme/theme.py (original)
+++ bloodhound/trunk/bloodhound_theme/bhtheme/theme.py Tue Apr 30 12:57:50 2013
@@ -108,6 +108,7 @@ class BloodhoundTheme(ThemeBase):
         'wiki_view.html' : ('bh_wiki_view.html', '_modify_wiki_page_path'),
 
         # Ticket
+        'manage.html' : ('manage.html', '_add_products_general_breadcrumb'),
         'milestone_edit.html' : ('bh_milestone_edit.html', '_modify_roadmap_page'),
         'milestone_delete.html' : ('bh_milestone_delete.html', '_modify_roadmap_page'),
         'milestone_view.html' : ('bh_milestone_view.html', '_modify_roadmap_page'),