Hi guys,

I'm having trouble writing a dashboard sidebar extension that adds custom 
filters to the datagrid.

ie. I would like to make a few different links, but an example of one would 
be 'Needs More Reviews', which would filter the reviews by:

   - less than 2 Ship-its (2 is our internal rule)
   - has no open reviews
   - not yours


Here is what I have currently:

*extension.py:*

class MySidebarSection(BaseSidebarSection):
    label = 'My Dashboard'

    def get_items(self):
        yield SidebarNavItem(self, 'My Requests to Push', view_id='push')
        yield SidebarNavItem(self, 'My Requests to Fix', view_id='fix')
        yield SidebarNavItem(self, 'Involved Reviews', view_id='involved')
        yield SidebarNavItem(self, 'Needs More Reviews', 
view_id='outstanding')
        yield SidebarNavItem(self, 'All Requests to Push', 
view_id='approved')

class MyDashboard(Extension):
    metadata = {
        'Name': 'My Dashboard',
        'Summary': 'Summary here',
    }
    is_configurable = True

    def initialize(self):
        # Your extension initialization is done here.
        DataGridSidebarItemsHook(self, MyDashboardDataGrid, 
[MySidebarSection])


*datagrids.py*

class MyDashboardDataGrid(DashboardDataGrid):
    def load_extra_state(self, profile):
        # pass custom queryset and change title
        user = self.request.user
        fullPath = self.request.get_full_path()
        view = self.request.GET.get('view', self.default_view)

        q = Q(repository__name='MyRepo', target_groups__name='internal', 
status='P')

        if view == 'outstanding':
                q = q & Q(shipit_count__lt=2, issue_open_count=0)  # TODO: 
make sure the review isn't yours
                self.queryset = ReviewRequest.objects.filter(q)
                self.title = _('Requests That Need Reviews (Reviews with # 
ship-its < 2, no open issues, not yours)')

        return super(MyDashboardDataGrid, self).load_extra_state(profile)



I assume this is all I need to do, but I keep getting this error when I 
click on the 'Needs More Reviews' link.

Page not found (404)
Request Method: GET
Request URL: http://0.0.0.0:8080/dashboard/?view=outstanding

This 404 is being raised by DashboardDataGrid.load_extra_state().

It seems as if DataGridSidebarItemsHook isn't using MyDashboardDataGrid but 
instead using DashboardDataGrid.

Is there anything I am missing?

Thanks for your help.

Marc

-- 
Get the Review Board Power Pack at http://www.reviewboard.org/powerpack/
---
Sign up for Review Board hosting at RBCommons: https://rbcommons.com/
---
Happy user? Let us know at http://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"reviewboard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to reviewboard+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to