--- a/web/views/__init__.py Fri Sep 16 17:10:33 2011 +0200
+++ b/web/views/__init__.py Fri Sep 16 16:42:42 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -22,7 +22,9 @@
import os
import sys
import tempfile
+
from rql import nodes
+from logilab.mtconverter import xml_escape
def need_table_view(rset, schema):
@@ -113,6 +115,16 @@
return "javascript: selectForAssociation('%s', '%s');" % (triplets, eid)
+def add_etype_button(req, etype, csscls='addButton right', **urlkwargs):
+ vreg = req.vreg
+ eschema = vreg.schema.eschema(etype)
+ if eschema.has_perm(req, 'add'):
+ url = vreg['etypes'].etype_class(etype).cw_create_url(req, **urlkwargs)
+ return u'<a href="%s" class="%s">%s</a>' % (
+ xml_escape(url), csscls, req.__('New %s' % etype))
+ return u''
+
+
class TmpFileViewMixin(object):
binary = True
content_type = 'application/octet-stream'