def test_get_all_panels(self): panels = site.get_panels() self.assertEquals(len(panels), 3) # panels is sorted by panel title -- order matters with these for i, panel in enumerate((TestPanelWithMeta, TestPanel, TestPanelWithDimensions)): data = panels[i] self.assertEquals(panel._meta.title, data['title']) self.assertEquals(panel._meta.event_type, data['type'])
def index(request, event_type=None, sub_call=None): panels = site.get_panels() if event_type: try: panel = site.get_panel(event_type) except exceptions.PanelDoesNotExist: raise Http404 else: panel = site.get_panel(panels[0]['type']) try: return panel.get_response(request, sub_call) except exceptions.PanelMethodDoesNotExist: raise Http404
def get_response(self, request, sub_call=None): """ Dispatches a subcall to the panel instance. Returns a template name and dictionary of context to render """ if not sub_call: sub_call = 'index' method = 'call_%s' % sub_call.replace('-', '_') if not hasattr(self, method): raise exceptions.PanelMethodDoesNotExist("Missing method %s on panel: %s" % \ (method, self.__class__.__name__)) request._new_cookies = [] context = { 'panels': site.get_panels(), 'current_panel': site.make_meta(self), } response = getattr(self, method)(request, context) for name, value in request._new_cookies: response.set_cookie(name, value=value, max_age=60*60*24*365) return response