from moksha.lib.base import Controller
from moksha.lib.helpers import Category, MokshaApp, Not, not_anonymous, MokshaWidget
from moksha.api.widgets.containers import DashboardContainer
from moksha.api.widgets import ContextAwareWidget

from tg import expose, tmpl_context, require, request

class BugsDashboard(DashboardContainer, ContextAwareWidget):
    template = 'mako:fedoracommunity.mokshaapps.packages.templates.single_col_dashboard'
    layout = [Category('content-col-apps',[])]

bugs_dashboard = BugsDashboard

class BugsController(Controller):
    @expose('mako:moksha.templates.widget')
    def index(self, package):
        tmpl_context.widget = bugs_dashboard
        return {'package': package}

@@ -1,24 +1,87 @@
+from tw.api import Widget as TWWidget%0Afrom pylons import cache%0A
 from moksha.lib.base imp
@@ -176,24 +176,62 @@
 okshaWidget%0A
+from moksha.lib.helpers import Widget%0A
 from moksha.
@@ -328,16 +328,70 @@
 reWidget
+, Grid%0Afrom moksha.api.connectors import get_connector
 %0A%0Afrom t
@@ -452,195 +452,1444 @@
  Bug
-sDashboard(DashboardContainer, ContextAwareWidget):%0A    template = 'mako:fedoracommunity.mokshaapps.packages.templates.single_col_dashboard'%0A    layout = %5BCategory('content-col-apps',%5B%5D)%5D
+StatsWidget(TWWidget):%0A    template='mako:fedoracommunity.mokshaapps.packages.templates.bugs_stats_widget'%0A    params = %5B'id', 'product', 'component', 'version', 'num_closed', 'num_open', 'num_new'%5D%0A    product = 'Fedora'%0A    version = 'rawhide'%0A    component = None%0A%0A    num_closed = num_open = num_new = '-'%0A%0A%0Abug_stats_widget = BugStatsWidget('bug_stats')%0A%0A%0Aclass BugsGrid(Grid):%0A    template='mako:fedoracommunity.mokshaapps.packages.templates.bugs_table_widget'%0A%0A    def update_params(self, d):%0A        d%5B'resource'%5D = 'bugzilla'%0A        d%5B'resource_path'%5D = 'query_bugs'%0A        super(BugsGrid, self).update_params(d)%0A%0Abugs_grid = BugsGrid('bugs_grid')%0A%0A%0Aclass BugsDashboard(DashboardContainer, ContextAwareWidget):%0A    template = 'mako:fedoracommunity.mokshaapps.packages.templates.single_col_dashboard'%0A    layout = %5BCategory('content-col-apps',%5B%0A                         Widget('Dashboard', bug_stats_widget,%0A                                params=%7B'filters':%7B'package': ''%7D%7D),%0A                         Widget('Recently Filed Bugs',%0A                                bugs_grid,%0A                                params=%7B'filters':%7B'package': ''%7D%7D),%0A                         %5D)%5D%0A%0A    def update_params(self, d):%0A        package = d.get('package')%0A        conn = get_connector('pkgdb')%0A        info = conn.get_basic_package_info(package)%0A        d%5B'pkg_summary'%5D = info%5B'summary'%5D%0A        super(BugsDashboard, self).update_params(d)%0A
 %0A%0Abu
@@ -1916,16 +1916,34 @@
 ashboard
+('bugs_dashboard')
 %0A%0Aclass 
@@ -1970,16 +1970,17 @@
 oller):%0A
+%0A
     @exp
@@ -2104,16 +2104,28 @@
   return
+ %7B'options':
  %7B'packa
@@ -2137,9 +2137,10 @@
 package%7D
+%7D
 %0A

Add BugStats and BugsGrid widgets