Changeset 12266
- Timestamp:
- 19 Dec 2014, 16:17:17 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/documents
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/export.py
r12249 r12266 27 27 28 28 29 class PDFDocumentExporter(grok.GlobalUtility, ExporterBase):29 class DocumentExporterBase(grok.GlobalUtility, ExporterBase): 30 30 """Exporter for documents. 31 31 """ 32 32 grok.implements(ICSVExporter) 33 grok.name('pdfdocuments') 33 grok.baseclass() 34 class_name = None 35 iface = None 36 title = None 34 37 35 #: Fieldnames considered by this exporter 36 fields = tuple(sorted(iface_names(IPDFDocument))) + ( 38 @property 39 def fields(self): 40 return tuple(sorted(iface_names(self.iface))) + ( 37 41 'users_with_local_roles',) 38 39 #: The title under which this exporter will be displayed40 title = _(u'Public PDF Documents')41 42 42 43 def mangle_value(self, value, name, context=None): … … 48 49 for local_role, user_name, setting in role_map.getPrincipalsAndRoles(): 49 50 value.append({'user_name':user_name,'local_role':local_role}) 50 return super( PDFDocumentExporter, self).mangle_value(51 return super(DocumentExporterBase, self).mangle_value( 51 52 value, name, context) 52 53 … … 66 67 If `filepath` is ``None``, a raw string with CSV data is returned. 67 68 """ 68 documents = site.get('documents', {}) 69 return self.export(documents.values(), filepath) 69 documents = site.get('documents', {}).values() 70 documents = [doc for doc in documents 71 if doc.class_name == self.class_name] 72 return self.export(documents, filepath) 70 73 71 74 72 class HTMLDocumentExporter(PDFDocumentExporter): 75 class PDFDocumentExporter(DocumentExporterBase): 76 """Exporter for documents. 77 """ 78 grok.name('pdfdocuments') 79 iface = IPDFDocument 80 class_name = 'PDFDocument' 81 title = _(u'Public PDF Documents') 82 83 84 class HTMLDocumentExporter(DocumentExporterBase): 73 85 """Exporter for documents. 74 86 """ 75 87 grok.name('htmldocuments') 76 77 #: Fieldnames considered by this exporter 78 fields = tuple(sorted(iface_names(IHTMLDocument))) + ( 79 'users_with_local_roles',) 80 81 #: The title under which this exporter will be displayed 88 iface = IHTMLDocument 89 class_name = 'HTMLDocument' 82 90 title = _(u'Public HTML Documents') -
main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_batching.py
r12257 r12266 79 79 80 80 def setup_for_export(self): 81 document = PDFDocument() 82 self.app['documents'][document.document_id] = self.document = document 81 document1 = PDFDocument() 82 document1.document_id = u'DOC1' 83 self.app['documents'].addDocument(document1) 84 self.pdfdocument = document1 83 85 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 84 role_manager = IPrincipalRoleManager(document) 86 role_manager = IPrincipalRoleManager(document1) 87 role_manager.assignRoleToPrincipal(u'johnsrole', u'john') 88 89 document2 = HTMLDocument() 90 document2.document_id = u'DOC2' 91 self.app['documents'].addDocument(document2) 92 self.htmldocument = document2 93 self.outfile = os.path.join(self.workdir, 'myoutput.csv') 94 role_manager = IPrincipalRoleManager(document2) 85 95 role_manager.assignRoleToPrincipal(u'johnsrole', u'john') 86 96 return
Note: See TracChangeset for help on using the changeset viewer.