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)
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 )
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
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)
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)
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
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, )
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_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_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)')
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.')
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)
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.')
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)
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)
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']))
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()
def download_link(self): dc_helper = DownloadConfirmationHelper() return dc_helper.get_html_tag(self.get_url())