[ui api] backport create_links from forge so it may be reused stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 28 Sep 2009 11:09:40 +0200
branchstable
changeset 3500 ab10d1cb53ff
parent 3499 9161c215b954
child 3501 3ef4ce396066
[ui api] backport create_links from forge so it may be reused
web/views/startup.py
--- a/web/views/startup.py	Mon Sep 28 11:06:18 2009 +0200
+++ b/web/views/startup.py	Mon Sep 28 11:09:40 2009 +0200
@@ -21,6 +21,7 @@
     id = 'manage'
     title = _('manage')
     http_cache_manager = httpcache.EtagHTTPCacheManager
+    add_etype_links = ()
 
     @classmethod
     def vreg_initialization_completed(cls):
@@ -78,6 +79,16 @@
         self.w(u'<h4>%s</h4>\n' % self.req._('Browse by category'))
         self.vreg['views'].select('tree', self.req).render(w=self.w)
 
+    def create_links(self):
+        self.w(u'<ul class="createLink">')
+        for etype in self.add_etype_links:
+            eschema = self.schema.eschema(etype)
+            if eschema.has_perm(self.req, 'add'):
+                self.w(u'<li><a href="%s">%s</a></li>' % (
+                        self.req.build_url('add/%s' % eschema),
+                        self.req.__('add a %s' % eschema).capitalize()))
+        self.w(u'</ul>')
+
     def startup_views(self):
         self.w(u'<h4>%s</h4>\n' % self.req._('Startup views'))
         self.startupviews_table()