def init_rendering(self): super(EditBox, self).init_rendering() _ = self._cw._ self._menus_in_order = [] self._menus_by_id = {} # build list of actions actions = self._cw.vreg['actions'].possible_actions(self._cw, self.cw_rset, view=self.cw_extra_kwargs['view']) other_menu = self._get_menu('moreactions', _('more actions')) for category, defaultmenu in (('mainactions', self), ('moreactions', other_menu), ('addrelated', None)): for action in actions.get(category, ()): if action.submenu: menu = self._get_menu(action.submenu) else: menu = defaultmenu action.fill_menu(self, menu) # if we've nothing but actions in the other_menu, add them directly into the box if not self.items and len(self._menus_by_id) == 1 and not other_menu.is_empty(): self.items = other_menu.items else: # ensure 'more actions' menu appears last self._menus_in_order.remove(other_menu) self._menus_in_order.append(other_menu) for submenu in self._menus_in_order: self.add_submenu(self, submenu) if not self.items: raise component.EmptyComponent()
def init_rendering(self): super(StartupViewsBox, self).init_rendering() self.cw_rset = self._cw.execute( 'Any S,SN,count(A) GROUPBY S,SN ORDERBY SN ' 'WHERE A is Application, A in_state S, S name SN') if not self.cw_rset: raise component.EmptyComponent()
def init_rendering(self): self.views = [v for v in self._cw.vreg['views'].possible_views(self._cw, rset=self.cw_rset) if v.category != 'startupview'] if not self.views: raise component.EmptyComponent() self.items = []
def init_rendering(self): ueid = self._cw.user.eid self.bookmarks_rset = self._cw.execute(self.rql, {'x': ueid}) rschema = self._cw.vreg.schema.rschema('bookmarked_by') eschema = self._cw.vreg.schema.eschema('Bookmark') self.can_delete = rschema.has_perm(self._cw, 'delete', toeid=ueid) self.can_edit = (eschema.has_perm(self._cw, 'add') and rschema.has_perm(self._cw, 'add', toeid=ueid)) if not self.bookmarks_rset and not self.can_edit: raise component.EmptyComponent() self.items = []