# HG changeset patch # User Thierry Florac # Date 1505133939 -7200 # Node ID a27c1887736f9039337090bd184ee7342b11e0aa # Parent 5b02c3b2eaf2a4227da2a444e859f23802c46fef Sort items in top links menus diff -r 5b02c3b2eaf2 -r a27c1887736f src/pyams_content/zmi/viewlet/toplinks/__init__.py --- a/src/pyams_content/zmi/viewlet/toplinks/__init__.py Mon Sep 11 14:44:49 2017 +0200 +++ b/src/pyams_content/zmi/viewlet/toplinks/__init__.py Mon Sep 11 14:45:39 2017 +0200 @@ -49,7 +49,8 @@ def update(self): super(SharedSitesMenu, self).update() registry = get_local_registry() - for site in registry.getAllUtilitiesRegisteredFor(ISharedSite): + for site in sorted(registry.getAllUtilitiesRegisteredFor(ISharedSite), + key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''): menu = TopLinksMenu(self.context, self.request, self.__parent__, self) menu.label = II18n(site).query_attribute('title', request=self.request) or site.__name__ menu.url = absolute_url(site, self.request, 'admin#dashboard.html') @@ -67,7 +68,8 @@ def update(self): super(SharedToolsMenu, self).update() registry = get_local_registry() - for tool in registry.getAllUtilitiesRegisteredFor(ISharedTool): + for tool in sorted(registry.getAllUtilitiesRegisteredFor(ISharedTool), + key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''): if ISharedSite.providedBy(tool): continue menu = TopLinksMenu(self.context, self.request, self.__parent__, self) @@ -92,7 +94,7 @@ Any(catalog['role:pilot'], {self.request.principal.id})), NotEq(catalog['content_type'], None)) for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))), - key=lambda x: II18n(x).query_attribute('title', request=self.request)): + key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''): menu = TopLinksMenu(self.context, self.request, self.__parent__, self) menu.label = II18n(tool).query_attribute('title', request=self.request) or tool.__name__ menu.url = absolute_url(tool, self.request, 'admin#dashboard.html') @@ -115,7 +117,7 @@ params = And(Any(catalog['role:contributor'], {self.request.principal.id}), NotEq(catalog['content_type'], None)) for tool in sorted(unique(CatalogResultSet(CatalogQuery(catalog).query(params))), - key=lambda x: II18n(x).query_attribute('title', request=self.request)): + key=lambda x: II18n(x).query_attribute('title', request=self.request) or ''): menu = TopLinksMenu(self.context, self.request, self.__parent__, self) adapter = registry.queryMultiAdapter((tool, self.request), IUserAddingsMenuLabel) if adapter is None: