def test_create_document_from_template_without_file(self): expected_title = 'My title' self.login(self.regular_user) template = create(Builder('document').within(self.dossiertemplate)) command = CreateDocumentFromTemplateCommand(self.dossier, template, expected_title) document = command.execute() self.assertEqual(expected_title, document.title) self.assertIsNone(document.file)
def test_create_document_from_template(self): expected_title = 'My title' expected_data = 'Test data' self.login(self.regular_user) template = create(Builder('document').within(self.dossiertemplate).with_dummy_content()) command = CreateDocumentFromTemplateCommand(self.dossier, template, expected_title) document = command.execute() self.assertEqual(expected_title, document.title) self.assertEqual(expected_data, document.file.data)
def test_create_document_from_template(self): expected_title = 'My title' expected_data = 'Test data' self.login(self.regular_user) template = create( Builder('document').within( self.dossiertemplate).with_dummy_content()) command = CreateDocumentFromTemplateCommand(self.dossier, template, expected_title) document = command.execute() self.assertEqual(expected_title, document.title) self.assertEqual(expected_data, document.file.data)
def create_document(self, data): """Create a new document based on a template.""" recipient_data = filter(None, [ data.get('recipient'), data.get('address'), data.get('mail_address'), data.get('phonenumber'), data.get('url'), ]) command = CreateDocumentFromTemplateCommand( self.context, data['template'], data['title'], recipient_data=recipient_data) return command.execute()
def recursive_content_creation(self, template_obj, target_container): responsible = IDossier(target_container).responsible for child_obj in template_obj.listFolderContents(): if IDossierTemplateSchema.providedBy(child_obj): dossier = CreateDossierFromTemplateCommand( target_container, child_obj).execute() IDossier(dossier).responsible = responsible self.recursive_content_creation(child_obj, dossier) else: CreateDocumentFromTemplateCommand( target_container, child_obj, child_obj.title).execute()