def get_download_copy_tag(self):
        """Returns the DownloadConfirmationHelper tag containing
        the donwload link. For mails, containing an original_message, the tag
        links to the orginal message download view.
        """
        dc_helper = DownloadConfirmationHelper(self.context)

        kwargs = {
            'additional_classes': ['function-download-copy'],
            'viewname': self.context.get_download_view_name(),
            'include_token': True,
            }

        requested_version_id = self.request.get('version_id')

        if requested_version_id:
            requested_version_id = int(requested_version_id)
            current_version_id = self.context.get_current_version_id()

            if requested_version_id != current_version_id:
                kwargs['url_extension'] = (
                    '?version_id={}'
                    .format(requested_version_id)
                    )

        return dc_helper.get_html_tag(**kwargs)
Example #2
0
 def get_download_copy_tag(self):
     dc_helper = DownloadConfirmationHelper()
     return dc_helper.get_html_tag(
         self.context.absolute_url(),
         additional_classes=['function-download-copy'],
         include_token=True
         )
Example #3
0
 def download_link(self):
     """Returns a formatted link that allows to download a copy of this
     version (opens in an overlay).
     """
     dc_helper = DownloadConfirmationHelper(self.obj)
     link = dc_helper.get_html_tag(
         additional_classes=['standalone', 'function-download-copy'],
         viewname='download', include_token=True)
     return link
Example #4
0
    def get_download_copy_link(self):
        # Because of cyclic dependencies, we can not import
        # DownloadConfirmationHelper in the top of the file.
        from opengever.document.browser.download import DownloadConfirmationHelper

        if not self.has_file():
            return None

        dc_helper = DownloadConfirmationHelper()
        return dc_helper.get_html_tag(self.context.absolute_url(), additional_classes=[""], include_token=True)
Example #5
0
 def download_link(self):
     """Returns a formatted link that allows to download a copy of this
     version (opens in an overlay).
     """
     dc_helper = DownloadConfirmationHelper(self.obj)
     link = dc_helper.get_html_tag(
         additional_classes=['standalone', 'function-download-copy'],
         viewname='download',
         include_token=True)
     return link
Example #6
0
    def get_download_copy_link(self):
        # Because of cyclic dependencies, we can not import
        # DownloadConfirmationHelper in the top of the file.
        from opengever.document.browser.download import DownloadConfirmationHelper  # noqa

        if not self.has_file():
            return None

        dc_helper = DownloadConfirmationHelper(self.context)
        return dc_helper.get_html_tag(
            additional_classes=['function-download-copy'], include_token=True)
Example #7
0
 def download_link(self):
     """Returns a formatted link that allows to download a copy of this
     version (opens in an overlay).
     """
     dc_helper = DownloadConfirmationHelper(self._context)
     link = dc_helper.get_html_tag(
         url_extension="?version_id=%s" % self.version,
         additional_classes=['standalone', 'function-download-copy'],
         viewname='download_file_version',
         include_token=True)
     return link
Example #8
0
 def get_download_copy_tag(self):
     """Returns the DownloadConfirmationHelper tag containing
     the donwload link. For mails, containing an original_message, the tag
     links to the orginal message download view.
     """
     dc_helper = DownloadConfirmationHelper(self.context)
     return dc_helper.get_html_tag(
         additional_classes=['function-download-copy'],
         viewname=self.context.get_download_view_name(),
         include_token=True,
     )
Example #9
0
 def download_link(self):
     """Returns a formatted link that allows to download a copy of this
     version (opens in an overlay).
     """
     dc_helper = DownloadConfirmationHelper(self._context)
     link = dc_helper.get_html_tag(
         url_extension="?version_id=%s" % self.version,
         additional_classes=['standalone', 'function-download-copy'],
         viewname='download_file_version',
         include_token=True)
     return link
Example #10
0
    def test_mail_download_links_never_have_confirmation(self, browser):
        mail = create(Builder("mail").with_message(MAIL_DATA_CRLF))
        dch = DownloadConfirmationHelper(mail)

        browser.login()
        browser.open(mail, view='tabbedview_view-overview')
        self.assertNotIn(
            'confirmation',
            browser.css('a.function-download-copy').first.get('href'))

        dch.deactivate()
        browser.open(mail, view='tabbedview_view-overview')
        self.assertNotIn(
            'confirmation',
            browser.css('a.function-download-copy').first.get('href'))
    def test_mail_download_links_never_have_confirmation(self, browser):
        mail = create(Builder("mail").with_message(MAIL_DATA_CRLF))
        dch = DownloadConfirmationHelper(mail)

        browser.login()
        browser.open(mail, view='tabbedview_view-overview')
        self.assertNotIn(
            'confirmation',
            browser.css('a.function-download-copy').first.get('href'))

        dch.deactivate()
        browser.open(mail, view='tabbedview_view-overview')
        self.assertNotIn(
            'confirmation',
            browser.css('a.function-download-copy').first.get('href'))
Example #12
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)
Example #13
0
 def test_download_copy_without_overlay_creates_journal_entry(self, browser):
     self.login(self.regular_user, browser)
     versioner = Versioner(self.document)
     versioner.create_version('Initial version.')
     DownloadConfirmationHelper(self.document).deactivate()
     browser.open(self.document, view='tabbed_view/listing', data={'view_name': 'overview'})
     browser.find('Download copy').click()
     self.assert_journal_entry(self.document, 'File copy downloaded', 'Download copy current version (0)')
Example #14
0
    def test_mail_download_converts_lf_to_crlf(self, browser):
        mail = create(Builder("mail").with_message(MAIL_DATA_LF))
        DownloadConfirmationHelper(mail).deactivate()
        browser.login().visit(mail, view='tabbedview_view-overview')
        browser.find('Download copy').click()

        self.assertTrue(
            browser.contents.startswith(
                'Return-Path: <*****@*****.**>\r\n'),
            'Lineendings are not converted correctly.')
Example #15
0
    def test_download_copy_without_overlay_creates_journal_entry(self, browser):  # noqa
        DownloadConfirmationHelper(self.document).deactivate()
        transaction.commit()

        browser.login().open(self.document,
                             view='tabbed_view/listing',
                             data={'view_name': 'overview'})

        browser.find('Download copy').click()

        self.assert_download_journal_entry_created(self.document)
Example #16
0
    def test_mail_download_handles_crlf_correctly(self, browser):
        """Mails with already CRLF, should not be converted or changed.
        """
        mail = create(Builder("mail").with_message(MAIL_DATA_CRLF))
        DownloadConfirmationHelper(mail).deactivate()
        browser.login().visit(mail, view='tabbedview_view-overview')
        browser.find('Download copy').click()

        self.assertTrue(
            browser.contents.startswith(
                'Return-Path: <*****@*****.**>\r\n'),
            'Lineendings are not converted correctly.')
Example #17
0
    def test_mail_download_copy_yields_correct_headers(self, browser):
        mail = create(Builder("mail").with_message(MAIL_DATA))
        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': 'message/rfc822',
                'content-disposition':
                'attachment; filename="die-burgschaft.eml"',
            }, browser.headers)
Example #18
0
    def render_download_copy_link(self):
        """Returns the DownloadConfirmationHelper tag containing
        the donwload link. For mails, containing an original_message, the tag
        links to the orginal message download view.
        """
        dc_helper = DownloadConfirmationHelper(self.context)

        kwargs = {
            'additional_classes': ['function-download-copy'],
            'viewname': self.context.get_download_view_name(),
            'include_token': True,
        }

        requested_version_id = self.request.get('version_id')

        if requested_version_id:
            requested_version_id = int(requested_version_id)
            current_version_id = self.context.get_current_version_id()

            if requested_version_id != current_version_id:
                kwargs['url_extension'] = (
                    '?version_id={}'.format(requested_version_id))

        return dc_helper.get_html_tag(**kwargs)
Example #19
0
    def test_mail_download_copy_causes_journal_entry(self, browser):
        mail = create(Builder("mail").with_message(MAIL_DATA))
        DownloadConfirmationHelper(mail).deactivate()
        browser.login().visit(mail, view='tabbedview_view-overview')
        browser.find('Download copy').click()

        def get_journal(obj):
            annotations = IAnnotations(mail)
            return annotations.get(JOURNAL_ENTRIES_ANNOTATIONS_KEY, {})

        journal = get_journal(mail)
        last_entry = journal[-1]

        self.assertEquals(TEST_USER_ID, last_entry['actor'])

        action = last_entry['action']
        self.assertDictContainsSubset(
            {
                'type': 'File copy downloaded',
                'title': u'label_file_copy_downloaded'
            }, action)

        self.assertEquals(u'Download copy', translate(action['title']))
Example #20
0
 def get_download_copy_tag(self):
     dc_helper = DownloadConfirmationHelper(self.context)
     return dc_helper.get_html_tag(
         additional_classes=['function-download-copy'],
         include_token=True,
         )
 def tearDown(self):
     DownloadConfirmationHelper(self.document).activate()
     super(TestDocumentDownloadConfirmation, self).tearDown()
Example #22
0
 def download_link(self):
     dc_helper = DownloadConfirmationHelper()
     return dc_helper.get_html_tag(self.get_url())