move pdf icon component with it's template so we don't see it when the template isn't available due to missing dependancies stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 18 Mar 2010 09:05:49 +0100
branchstable
changeset 4935 f710770e6e90
parent 4932 dce5ebe5d598
child 4936 a4b772a0d801
move pdf icon component with it's template so we don't see it when the template isn't available due to missing dependancies
web/views/basecomponents.py
web/views/basetemplates.py
--- a/web/views/basecomponents.py	Wed Mar 17 11:30:39 2010 +0100
+++ b/web/views/basecomponents.py	Thu Mar 18 09:05:49 2010 +0100
@@ -216,20 +216,6 @@
         self.w(u'</div>')
 
 
-class PdfViewComponent(component.EntityVComponent):
-    __regid__ = 'pdfview'
-
-    context = 'ctxtoolbar'
-
-    def cell_call(self, row, col, view):
-        entity = self.cw_rset.get_entity(row, col)
-        url = entity.absolute_url(vid=view.__regid__, __template='pdf-main-template')
-        iconurl = self._cw.build_url('data/pdf_icon.gif')
-        label = self._cw._('Download page as pdf')
-        self.w(u'<a href="%s" title="%s" class="toolbarButton"><img src="%s" alt="%s"/></a>' %
-               (xml_escape(url), label, iconurl, label))
-
-
 class MetaDataComponent(component.EntityVComponent):
     __regid__ = 'metadata'
     context = 'navbottom'
--- a/web/views/basetemplates.py	Wed Mar 17 11:30:39 2010 +0100
+++ b/web/views/basetemplates.py	Thu Mar 18 09:05:49 2010 +0100
@@ -16,7 +16,7 @@
 from cubicweb.view import View, MainTemplate, NOINDEX, NOFOLLOW
 from cubicweb.utils import UStringIO, can_do_pdf_conversion
 from cubicweb.schema import display_name
-from cubicweb.web import formfields as ff, formwidgets as fw
+from cubicweb.web import component, formfields as ff, formwidgets as fw
 from cubicweb.web.views import forms
 
 # main templates ##############################################################
@@ -278,6 +278,20 @@
     from tempfile import NamedTemporaryFile
     from cubicweb.ext.xhtml2fo import ReportTransformer
 
+
+    class PdfViewComponent(component.EntityVComponent):
+        __regid__ = 'pdfview'
+
+        context = 'ctxtoolbar'
+
+        def cell_call(self, row, col, view):
+            entity = self.cw_rset.get_entity(row, col)
+            url = entity.absolute_url(vid=view.__regid__, __template='pdf-main-template')
+            iconurl = self._cw.build_url('data/pdf_icon.gif')
+            label = self._cw._('Download page as pdf')
+            self.w(u'<a href="%s" title="%s" class="toolbarButton"><img src="%s" alt="%s"/></a>' %
+                   (xml_escape(url), label, xml_escape(iconurl), label))
+
     class PdfMainTemplate(TheMainTemplate):
         __regid__ = 'pdf-main-template'