incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1307966 [3/3] - in /incubator/bloodhound/trunk/bloodhound_dashboard: ./ bhdashboard/ bhdashboard/htdocs/ bhdashboard/templates/ bhdashboard/tests/ bhdashboard/widgets/ bhdashboard/widgets/templates/
Date Sun, 01 Apr 2012 00:48:57 GMT
Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html?rev=1307966&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html
(added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html
Sun Apr  1 00:48:56 2012
@@ -0,0 +1,35 @@
+<!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:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="layout.html" />
+  <head>
+    <title>$title</title>
+  </head>
+  <body class="yui-skin-sam">
+    <div id="doc3" class="yui-t7">
+      <div id="hd" role="banner"><h1>$title</h1></div>
+      <div id="bd" role="main">
+        <div role="application" 
+            class="yui-g ui-box ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"
+            py:for="w in widgets">
+          <div class="ui-box-header ui-widget-header ui-helper-clearfix ui-corner-all">
+            <div class="ui-box-title">${w.title}</div>
+          </div>
+          <div class="ui-box-panel ui-widget-content ui-corner-bottom">
+            ${w.content}
+          </div>
+        </div>
+      </div>
+      <div id="ft" role="contentinfo">
+        <div id="help">
+          <strong>Note:</strong> See 
+          <a href="${href.wiki('BloodhoundDashboard')}">BloodhoundDashboard</a>
+          for help on using the dashboard.
+        </div>
+      </div>
+    </div>
+  </body>  
+</html>

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_one_col.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html?rev=1307966&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html
(added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html
Sun Apr  1 00:48:56 2012
@@ -0,0 +1,30 @@
+<!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:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+  <xi:include href="layout.html" />
+  <head>
+    <title>$title</title>
+  </head>
+
+  <body class="yui-skin-sam">
+    <div id="content" class="dashboard">
+      <div id="doc3" class="yui-t7">  
+        <div id="hd" role="banner"><h1>Header</h1></div>  
+        <div id="bd" role="main">  
+          <div class="yui-g">  
+            <div class="yui-u first">  
+              
+            </div>  
+            <div class="yui-u">  
+              
+            </div>  
+          </div>  
+        </div>  
+        <div id="ft" role="contentinfo"><p>Footer</p></div>  
+      </div>  
+    </div>
+  </body>
+</html>

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/templates/bhdb_two_col.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py?rev=1307966&r1=1307965&r2=1307966&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_report.py Sun Apr
 1 00:48:56 2012
@@ -35,6 +35,10 @@ are loaded. Besides the following values
 made available in the global namespace (i.e. provided that 
 the test name be written like `|widget_name: Descriptive message`):
 
+  - __tester__  An instance of `unittest.TestCase` representing the 
+                test case for the statement under test. Useful 
+                when specific assertions (e.g. `assertEquals`) 
+                are needed.
   - req         A dummy request object setup for anonymous access.
   - auth_req    A dummy request object setup like if user `murphy` was  
                 accessing the site.
@@ -89,7 +93,7 @@ from datetime import datetime, time, dat
 from itertools import izip
 from pprint import pprint
 
-from __init__ import clear_perm_cache
+from bhdashboard.tests import clear_perm_cache
 
 def print_report_metadata(report_desc):
   for attrnm in ('id', 'title', 'description', 'query'):
@@ -211,12 +215,13 @@ __test__ = {
       ...     'args' : {'id' : 7}
       ...   }))
       ...
-      ('widget_grid.html', [], <...Context >)
+      ('widget_grid.html', {'data': [], 'title': <Element "a">}, <...Context >)
 
       >>> template, data, rptctx = widget.render_widget('TicketReport', auth_ctx,
{
       ...     'args' : {'id' : 7}
       ...   })
       ...
+      >>> data = data['data']
       >>> template
       'widget_grid.html'
       >>> rptctx is auth_ctx
@@ -334,7 +339,7 @@ __test__ = {
       ...   }))
       ...
       ('widget_grid.html',
-       [{u'__color__': u'3',
+       {'data': [{u'__color__': u'3',
          u'__group__': u'Accepted',
          u'_changetime': ...,
          u'_description': u'Description 1',
@@ -360,6 +365,7 @@ __test__ = {
          u'ticket': 2,
          u'type': u'task',
          u'version': None}],
+        'title': <Element "a">},
        <...Context >)
       """,
     '|TicketReport: Invalid widget name' : r"""
@@ -451,7 +457,7 @@ __test__ = {
       ...   }))
       ...
       ('widget_grid.html',
-       [{u'__color__': u'3',
+       {'data': [{u'__color__': u'3',
          u'__group__': u'Accepted',
          u'_changetime': ...,
          u'_description': u'Description 1',
@@ -464,6 +470,7 @@ __test__ = {
          u'ticket': 1,
          u'type': u'defect',
          u'version': u'1.0'}],
+        'title': <Element "a">},
        <...Context >)
       """,
     '|TicketReport: Invalid report definition' : r"""

Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_webui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_webui.py?rev=1307966&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_webui.py (added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_webui.py Sun Apr
 1 00:48:56 2012
@@ -0,0 +1,126 @@
+#!/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
+
+In this file you'll find part of the tests written to ensure that
+dashboard web module works as expected.
+
+Only the tests requiring minimal setup effort are included below. 
+This means that the environment used to run these tests contains the 
+barely minimal information included in an environment (i.e. only the 
+data specified by `trac.db_default.get_data`.).
+
+Once the tests are started all built-in components (except 
+trac.versioncontrol.* ) as well as widget system and extensions
+are loaded. Besides the following values are (auto-magically)
+made available in the global namespace (i.e. provided that 
+the test name be written like `|widget_name: Descriptive message`):
+
+  - __tester__  An instance of `unittest.TestCase` representing the 
+                test case for the statement under test. Useful 
+                when specific assertions (e.g. `assertEquals`) 
+                are needed.
+  - req         A dummy request object setup for anonymous access.
+  - auth_req    A dummy request object setup like if user `murphy` was  
+                accessing the site.
+  - env         the Trac environment used as a stub for testing purposes.
+                This object is an instance of 
+                `bhdashboard.tests.EnvironmentStub`.
+  - ticket_data A set of tickets used for testing purposes.
+"""
+
+#------------------------------------------------------
+#    Test artifacts
+#------------------------------------------------------
+
+from bhdashboard.tests import trac_version, trac_tags
+
+def test_suite():
+  from doctest import NORMALIZE_WHITESPACE, ELLIPSIS, REPORT_UDIFF
+  from dutest import MultiTestLoader
+  from unittest import defaultTestLoader
+
+  from bhdashboard.tests import DocTestTracLoader, ticket_data
+
+  magic_vars = dict(ticket_data=ticket_data)
+  if trac_version < (0, 13): # FIXME: Should it be (0, 12) ?
+    kwargs = {'enable': ['trac.[a-uw-z]*', 'tracrpc.*', 'bhdashboard.*']}
+  else:
+    kwargs = {
+            'enable': ['trac.*', 'tracrpc.*', 'bhdashboard.*'],
+            'disable': ['trac.versioncontrol.*']
+        }
+
+  l = MultiTestLoader(
+        [defaultTestLoader, \
+          DocTestTracLoader(extraglobs=magic_vars, \
+                            default_data=True, \
+                            optionflags=ELLIPSIS | REPORT_UDIFF | \
+                                        NORMALIZE_WHITESPACE, \
+                            **kwargs) \
+        ])
+
+  import sys
+  return l.loadTestsFromModule(sys.modules[__name__])
+
+#------------------------------------------------------
+#    Helper functions
+#------------------------------------------------------
+
+from datetime import datetime, time, date
+from itertools import izip
+from pprint import pprint
+
+from bhdashboard.tests import clear_perm_cache
+
+def prepare_ticket_workflow(tcktrpc, ticket_data, auth_req):
+  r"""Set ticket status considering the actions defined in standard 
+  ticket workflow. Needed for TracRpc>=1.0.6
+  """
+  from time import sleep
+
+  TICKET_ACTIONS = {'accepted': 'accept', 'closed' : 'resolve',
+                    'assigned': 'reassign'}
+  sleep(1)
+  for idx, (_, __, td) in enumerate(ticket_data) :
+    action = TICKET_ACTIONS.get(td.get('status'))
+    if action is not None :
+      aux_attrs = {'action' : action}
+      aux_attrs.update(td)
+      tcktrpc.update(auth_req, idx + 1, "", aux_attrs)
+  sleep(1)
+  for idx, (_, __, td) in enumerate(ticket_data) :
+    tcktrpc.update(auth_req, idx + 1, "", td)
+
+from bhdashboard.web_ui import DashboardModule
+
+__test__ = {
+    'Initialization: Report widgets' : r"""
+      """,
+    'Rendering templates' : r"""
+      >>> dbm = DashboardModule(env)
+      >>> pprint(dbm.expand_widget_data(auth_req))
+      [{'content': <genshi.core.Stream object at ...>, 
+      'title': <Element "a">}]
+      """,
+  }
+

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/tests/test_webui.py
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py?rev=1307966&r1=1307965&r2=1307966&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/util.py Sun Apr  1 00:48:56
2012
@@ -53,6 +53,7 @@ def dummy_request(env, uname=None):
         'authname': rd.authenticate,
         'chrome': chrome.prepare_request,
         'hdf': getattr(rd, '_get_hdf', None),
+        'locale' : getattr(rd, '_get_locale', None),
         'perm': rd._get_perm,
         'session': rd._get_session,
         'tz': rd._get_timezone,

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py?rev=1307966&r1=1307965&r2=1307966&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/web_ui.py Sun Apr  1 00:48:56
2012
@@ -27,10 +27,14 @@ Implementing dashboard user interface.
 import pkg_resources
 import re
 
+from genshi.builder import tag
 from trac.core import Component, implements
 from trac.config import Option
+from trac.mimeview.api import Context
+from trac.util.translation import _
 from trac.web.api import IRequestHandler
-from trac.web.chrome import INavigationContributor, ITemplateProvider
+from trac.web.chrome import Chrome, INavigationContributor, \
+                            ITemplateProvider, add_stylesheet
 
 class DashboardModule(Component):
     implements(IRequestHandler, INavigationContributor, ITemplateProvider)
@@ -47,6 +51,15 @@ class DashboardModule(Component):
         """Initially this will render static widgets. With time it will be 
         more and more dynamic and flexible.
         """
+        #add_stylesheet(req, 'dashboard/reset-fonts-grids.css')
+        add_stylesheet(req, 'dashboard/grids.css')
+        add_stylesheet(req, 'dashboard/skin.css')
+        return 'bhdb_one_col.html', \
+                {
+                    'widgets' : self.expand_widget_data(req), 
+                    'title' : _('Dashboard')
+                }, \
+                None
 
     # INavigationContributor methods
     def get_active_navigation_item(self, req):
@@ -67,8 +80,9 @@ class DashboardModule(Component):
         """
         resource_filename = pkg_resources.resource_filename
         return [
-                ('dashboard', resource_filename('bhdashboard', 'htdocs')),
-                ('widgets', resource_filename('bhdashboard.widgets', 'htdocs'))]
+                 ('dashboard', resource_filename('bhdashboard', 'htdocs')),
+                 #('widgets', resource_filename('bhdashboard.widgets', 'htdocs'))
+                 ]
 
     def get_templates_dirs(self):
         """List `templates` folders for dashboard and widgets.
@@ -77,3 +91,21 @@ class DashboardModule(Component):
         return [resource_filename('bhdashboard', 'templates'),
                 resource_filename('bhdashboard.widgets', 'templates')]
 
+    # Public API
+    def expand_widget_data(self, req):
+        """Expand raw widget data and format it for use in template
+
+        Notes: So far it only renders a single report widget and there's no
+        chance to customize this at all.
+        """
+        # TODO: Implement dynamic dashboard specification
+        from bhdashboard.widgets.report import TicketReportWidget
+        w = TicketReportWidget(self.env)
+        ctx = Context.from_request(req)
+        args = ('TicketReport', ctx, {'args' : {'id' : 7, 'limit' : 10}})
+        chrome = Chrome(self.env)
+        template, data, _ = w.render_widget(*args)
+        render = chrome.render_template
+        return [{'title' : data['title'], 
+                'content' : render(req, template, data['data'], fragment=True)}]
+

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py?rev=1307966&r1=1307965&r2=1307966&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/report.py Sun Apr
 1 00:48:56 2012
@@ -27,6 +27,7 @@ Widgets displaying report data.
 from datetime import datetime, date, time
 from itertools import imap, islice
 
+from genshi.builder import tag
 from trac.core import implements, TracError
 from trac.ticket.report import ReportModule
 from trac.util.translation import _
@@ -72,7 +73,13 @@ class TicketReportWidget(WidgetBase):
                 exc.title = 'TracReports'
             raise
         else:
-            return 'widget_grid.html', data, context
+            title = metadata.get('title', '%s #%s' % (_('Report'), rptid))
+            return 'widget_grid.html', \
+                    {
+                        'title' : tag.a(title, href=req.href('report', rptid)),
+                        'data' : data
+                    }, \
+                    context
 
     render_widget = pretty_wrapper(render_widget, check_widget_name)
 

Added: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html?rev=1307966&view=auto
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html
(added)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html
Sun Apr  1 00:48:56 2012
@@ -0,0 +1,7 @@
+
+<div xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:py="http://genshi.edgewall.org/"
+      xmlns:xi="http://www.w3.org/2001/XInclude">
+  <strong>It works</strong>
+</div>
+

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/widgets/templates/widget_grid.html
------------------------------------------------------------------------------
    svn:mime-type = text/html



Mime
View raw message