Ignore:
Timestamp:
21 Dec 2014, 17:00:10 (10 years ago)
Author:
Henrik Bettermann
Message:

Extend DocumentExporterBase?. We need to know more about exported documents.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/documents
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/export.py

    r12266 r12287  
    3838    @property
    3939    def fields(self):
    40         return tuple(sorted(iface_names(self.iface))) + (
    41         'users_with_local_roles',)
     40        return tuple(sorted(iface_names(self.iface, exclude_attribs=False,
     41            omit=['is_verifiable',
     42                  'translated_state',
     43                  'user_id',
     44                  'formatted_transition_date',
     45                  'translated_class_name',
     46                  'connected_files',   # Could be used to export file URLs
     47                  ]
     48            ))) + (
     49            'users_with_local_roles',)
    4250
    4351    def mangle_value(self, value, name, context=None):
     
    4957            for local_role, user_name, setting in role_map.getPrincipalsAndRoles():
    5058                value.append({'user_name':user_name,'local_role':local_role})
     59        if name == 'history':
     60            value = value.messages
    5161        return super(DocumentExporterBase, self).mangle_value(
    5262            value, name, context)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/documents/tests/test_export.py

    r12266 r12287  
    6262        exporter.export([self.pdfdocument], self.outfile)
    6363        result = open(self.outfile, 'rb').read()
    64         self.assertTrue(
    65             'description,document_id,title,users_with_local_roles\r\n'
    66             ',DOC1,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"'
    67             in result
     64        self.assertMatches(
     65            'class_name,description,document_id,history,state,title,users_with_local_roles\r\n'
     66            'PDFDocument,,DOC1,'
     67            '[u\'2014-12-21 16:55:16 UTC - Document created by system\'],'
     68            'created,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"',
     69            result
    6870            )
    6971        return
     
    7476        exporter.export_all(self.app, self.outfile)
    7577        result = open(self.outfile, 'rb').read()
    76         self.assertTrue(
    77             'description,document_id,title,users_with_local_roles\r\n'
    78             ',DOC1,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"'
    79             in result
     78        self.assertMatches(
     79            'class_name,description,document_id,history,state,title,users_with_local_roles\r\n'
     80            'PDFDocument,,DOC1,'
     81            '[u\'2014-12-21 16:55:16 UTC - Document created by system\'],'
     82            'created,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"',
     83            result
    8084            )
    8185        return
     
    109113        exporter.export([self.htmldocument], self.outfile)
    110114        result = open(self.outfile, 'rb').read()
    111         self.assertTrue(
    112             'description,document_id,html_multilingual,title,'
    113             'users_with_local_roles\r\n,DOC2,'
    114             ',,'
    115             '"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"\r\n'
    116             in result
     115        self.assertMatches(
     116            'class_name,description,document_id,history,html_dict,'
     117            'html_multilingual,state,title,users_with_local_roles\r\n'
     118            'HTMLDocument,,DOC2,'
     119            '[u\'2014-12-21 16:50:28 UTC - Document created by system\'],'
     120            '{},,created,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"',
     121            result
    117122            )
    118123        return
     
    123128        exporter.export_all(self.app, self.outfile)
    124129        result = open(self.outfile, 'rb').read()
    125         self.assertTrue(
    126             'description,document_id,html_multilingual,title,'
    127             'users_with_local_roles\r\n,DOC2,'
    128             ',,'
    129             '"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"\r\n'
    130             in result
     130        self.assertMatches(
     131            'class_name,description,document_id,history,html_dict,'
     132            'html_multilingual,state,title,users_with_local_roles\r\n'
     133            'HTMLDocument,,DOC2,'
     134            '[u\'2014-12-21 16:50:28 UTC - Document created by system\'],'
     135            '{},,created,,"[{\'user_name\': u\'john\', \'local_role\': u\'johnsrole\'}]"',
     136            result
    131137            )
    132138        return
Note: See TracChangeset for help on using the changeset viewer.