merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Jul 2009 18:02:24 +0200
branchstable
changeset 2262 d0cec91ff4c5
parent 2259 5d90bd26af8b (current diff)
parent 2261 7e635be2c4b2 (diff)
child 2263 1f59cd5b710f
merge
--- a/web/views/facets.py	Fri Jul 03 18:00:13 2009 +0200
+++ b/web/views/facets.py	Fri Jul 03 18:02:24 2009 +0200
@@ -41,6 +41,8 @@
     needs_css = 'cubicweb.facets.css'
     needs_js = ('cubicweb.ajax.js', 'cubicweb.formfilter.js')
 
+    bkLinkBox_template = u'<div class="facetTitle">%s</div>'
+    
     def facetargs(self):
         """this method returns the list of extra arguments that should
         be used by the facet
@@ -80,18 +82,8 @@
                         widgets.append(wdg)
             if not widgets:
                 return
+            self.displayBookmarkLink(rset)
             w = self.w
-            eschema = self.schema.eschema('Bookmark')
-            if eschema.has_perm(req, 'add'):
-                bk_path = 'view?rql=%s' % rset.printable_rql()
-                bk_title = req._('my custom search')
-                linkto = 'bookmarked_by:%s:subject' % self.req.user.eid
-                bk_add_url = self.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto)
-                bk_base_url = self.build_url('add/Bookmark', title=bk_title, __linkto=linkto)
-                w(u'<div class="facetTitle"><a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a></div>' % (
-                    html_escape(bk_base_url),
-                    html_escape(bk_add_url),
-                    req._('bookmark this search')))
             w(u'<form method="post" id="%sForm" cubicweb:facetargs="%s" action="">'  % (
                 divid, html_escape(dumps([divid, vid, paginate, self.facetargs()]))))
             w(u'<fieldset>')
@@ -109,6 +101,20 @@
             import cubicweb
             cubicweb.info('after facets with rql: %s' % repr(rqlst))
 
+    def displayBookmarkLink(self, rset):
+        eschema = self.schema.eschema('Bookmark')
+        if eschema.has_perm(self.req, 'add'):
+            bk_path = 'view?rql=%s' % rset.printable_rql()
+            bk_title = self.req._('my custom search')
+            linkto = 'bookmarked_by:%s:subject' % self.req.user.eid
+            bk_add_url = self.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto)
+            bk_base_url = self.build_url('add/Bookmark', title=bk_title, __linkto=linkto)
+            bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % (
+                    html_escape(bk_base_url),
+                    html_escape(bk_add_url),
+                    self.req._('bookmark this search'))
+            self.w(self.bkLinkBox_template % bk_link)
+
     def get_facets(self, rset, mainvar):
         return self.vreg.possible_vobjects('facets', self.req, rset,
                                            context='facetbox',