예제 #1
0
    def __call__(self, filename, title, description, content_type, data,
                 portal_type):
        """Quickupload description inputs are hidden in gever
        therefore we skip the description.
        """
        if self.is_email_upload(filename):
            command = CreateEmailCommand(
                self.context,
                filename,
                data,
                message_source=MESSAGE_SOURCE_DRAG_DROP_UPLOAD)
        else:
            command = CreateDocumentCommand(self.context, filename, data)

        try:
            obj = command.execute()
        except ForbiddenByQuota as exc:
            # this is an error, we must not commit
            transaction.abort()
            return {
                'error': translate(exc.message, context=self.context.REQUEST),
                'success': None
            }

        result = {'success': obj}
        return result
예제 #2
0
    def test_download_copy_delivers_msg_if_available(self, browser):
        msg_data = 'mock-msg-body'

        dossier = create(Builder('dossier'))

        class MockMsg2MimeTransform(object):
            def transform(self, data):
                return 'mock-eml-body'

        command = CreateEmailCommand(dossier,
                                     'testm\xc3\xa4il.msg',
                                     msg_data,
                                     transform=MockMsg2MimeTransform())
        mail = command.execute()
        transaction.commit()

        DownloadConfirmationHelper(mail).deactivate()
        browser.login().visit(mail, view='tabbedview_view-overview')
        browser.find('Download copy').click()

        self.assertDictContainsSubset(
            {
                'status':
                '200 Ok',
                'content-length':
                str(len(browser.contents)),
                'content-type':
                'application/vnd.ms-outlook',
                'content-disposition':
                'attachment; filename="testm\xc3\xa4il.msg"',
            }, browser.headers)

        self.assertEquals(msg_data, browser.contents)
    def test_download_copy_delivers_msg_if_available(self, browser):
        msg_data = 'mock-msg-body'

        dossier = create(Builder('dossier'))

        class MockMsg2MimeTransform(object):

            def transform(self, data):
                return 'mock-eml-body'

        command = CreateEmailCommand(dossier,
                                     'testm\xc3\xa4il.msg',
                                     msg_data,
                                     transform=MockMsg2MimeTransform())
        mail = command.execute()
        transaction.commit()

        DownloadConfirmationHelper(mail).deactivate()
        browser.login().visit(mail, view='tabbedview_view-overview')
        browser.find('Download copy').click()

        self.assertDictContainsSubset({
            'status': '200 Ok',
            'content-length': str(len(browser.contents)),
            'content-type': 'application/vnd.ms-outlook',
            'content-disposition': 'attachment; filename="testm\xc3\xa4il.msg"',
            },
            browser.headers)

        self.assertEquals(msg_data, browser.contents)
예제 #4
0
    def create_mail(self, message):
        """Use `CreateEmailCommand` to create the mailed-in mail."""

        self.check_permission()
        self.check_addable_types()

        command = CreateEmailCommand(self.context, 'message.eml', message,
                                     message_source=MESSAGE_SOURCE_MAILIN)
        return command.execute()
예제 #5
0
    def test_converted_msg_is_created_correctly(self):
        self.login(self.regular_user)
        command = CreateEmailCommand(
            self.dossier, 'testm\xc3\xa4il.msg', 'mock-msg-body',
            transform=MockMsg2MimeTransform())
        mail = command.execute()

        self.assertEqual('message/rfc822', mail.message.contentType)
        self.assertEqual('no-subject.eml', mail.message.filename)

        self.assertEqual(u'testm\xe4il.msg', mail.original_message.filename)
        self.assertEqual('mock-msg-body', mail.original_message.data)
예제 #6
0
    def test_converted_msg_is_created_correctly(self):
        command = CreateEmailCommand(self.dossier,
                                     'testm\xc3\xa4il.msg',
                                     'mock-msg-body',
                                     transform=MockMsg2MimeTransform())
        mail = command.execute()

        self.assertEqual('message/rfc822', mail.message.contentType)
        self.assertEqual('no-subject.eml', mail.message.filename)

        self.assertEqual(u'testm\xe4il.msg', mail.original_message.filename)
        self.assertEqual('mock-msg-body', mail.original_message.data)
예제 #7
0
    def create_emails(self):
        self.mail_eml = self.register('mail_eml', create(
            Builder("mail")
            .with_message(MAIL_DATA)
            .within(self.dossier)))
        self.register('mail', self.mail_eml)

        class MockMsg2MimeTransform(object):

            def transform(self, data):
                return 'mock-eml-body'

        command = CreateEmailCommand(self.dossier,
                                     'testm\xc3\xa4il.msg',
                                     'mock-msg-body',
                                     transform=MockMsg2MimeTransform())
        self.mail_msg = self.register('mail_msg', command.execute())
예제 #8
0
    def __call__(self,
                 filename,
                 title,
                 description,
                 content_type,
                 data, portal_type):

        if self.is_email_upload(filename):
            command = CreateEmailCommand(
                self.context, filename, data, description=description)
        else:
            command = CreateDocumentCommand(
                self.context, filename, data, description=description)

        obj = command.execute()

        result = {'success': obj}
        return result
예제 #9
0
    def create_mail(self, message):
        """Use `CreateEmailCommand` to create the mailed-in mail."""

        self.check_permission()
        self.check_addable_types()

        # we don't set the content-type directly here but choose it with a
        # roundtrip via mimetype registry.
        if self.is_application_pkcs7_mime(message):
            filename = 'message.p7m'
        else:
            filename = 'message.eml'

        command = CreateEmailCommand(self.context,
                                     filename,
                                     message,
                                     message_source=MESSAGE_SOURCE_MAILIN)
        return command.execute()
예제 #10
0
    def __call__(self, filename, title, description, content_type,
                 data, portal_type):
        """Quickupload description inputs are hidden in gever
        therefore we skip the description.
        """
        if self.is_email_upload(filename):
            command = CreateEmailCommand(
                self.context, filename, data,
                message_source=MESSAGE_SOURCE_DRAG_DROP_UPLOAD)
        else:
            command = CreateDocumentCommand(self.context, filename, data)

        try:
            obj = command.execute()
        except ForbiddenByQuota as exc:
            # this is an error, we must not commit
            transaction.abort()
            return {'error': translate(exc.message,
                                       context=self.context.REQUEST),
                    'success': None}

        result = {'success': obj}
        return result