コード例 #1
0
    def test_supports_additional_metadata_from_contentlisting_object(
            self, browser):
        self.activate_feature('bumblebee')

        self.login(self.regular_user, browser)

        view = ('@search?path={}&metadata_fields=preview_pdf_url'
                '&metadata_fields=preview_image_url'.format('/'.join(
                    self.document.getPhysicalPath())))

        browser.open(self.dossier, view=view, headers=self.api_headers)

        items = browser.json['items']
        self.assertItemsEqual([
            u'@id', u'@type', u'title', u'description', u'review_state',
            u'preview_image_url', u'preview_pdf_url'
        ], items[0].keys())

        # Use same bumble_id to compare the urls.
        parsed = urlparse.urlparse(items[0]['preview_pdf_url'])
        self.request['bid'] = urlparse.parse_qs(parsed.query)['bid'][0]

        self.assertEqual(
            get_service_v3().get_representation_url(self.document, 'pdf'),
            items[0]['preview_pdf_url'])
        self.assertEqual(
            get_service_v3().get_representation_url(self.document,
                                                    'thumbnail'),
            items[0]['preview_image_url'])
コード例 #2
0
    def __call__(self):
        self.install_upgrade_profile()
        catalog = api.portal.get_tool('portal_catalog')
        query = {'portal_type': 'opengever.meeting.sablontemplate'}
        msg = 'Add bumblebee-previews for sablontemplates.'

        for obj in self.objects(query, msg):
            IBumblebeeDocument(obj).update_checksum()
            catalog.reindexObject(obj, idxs=['object_provides'],
                                  update_metadata=False)

            if is_bumblebee_feature_enabled():
                get_service_v3().trigger_storing(obj, deferred=True)
コード例 #3
0
    def get_preview_frame_url(self):
        """Return the url to fetch the bumblebee preview HTML frame."""
        if not self.is_bumblebeeable():
            return None

        return bumblebee.get_service_v3().get_representation_url(
            self.getDataOrigin(), 'preview')
コード例 #4
0
    def get_preview_image_url(self):
        """Return the url to fetch the bumblebee preview thumbnail."""
        if not self.is_bumblebeeable():
            return None

        return bumblebee.get_service_v3().get_representation_url(
            self.getDataOrigin(), 'thumbnail')
コード例 #5
0
    def get_preview_pdf_url(self):
        """Return the url to fetch the bumblebee preview pdf."""
        if not self.is_bumblebeeable():
            return None

        return bumblebee.get_service_v3().get_representation_url(
            self.getDataOrigin(), 'pdf')
コード例 #6
0
    def __call__(self, *args, **kwargs):
        result = super(SerializeDocumentToJson, self).__call__(*args, **kwargs)

        ref_num = IReferenceNumber(self.context)
        result[u'reference_number'] = ref_num.get_number()

        bumblebee_service = bumblebee.get_service_v3()
        result[u'thumbnail_url'] = bumblebee_service.get_representation_url(
            self.context, 'thumbnail')
        result[u'preview_url'] = bumblebee_service.get_representation_url(
            self.context, 'preview')
        result[u'pdf_url'] = bumblebee_service.get_representation_url(
            self.context, 'pdf')
        result[u'file_extension'] = self.context.get_file_extension()

        additional_metadata = {
            'checked_out':
            self.context.checked_out_by(),
            'is_locked':
            self.context.is_locked(),
            'containing_dossier':
            self.context.containing_dossier_title(),
            'containing_subdossier':
            self.context.containing_subdossier_title(),
            'trashed':
            self.context.is_trashed,
            'is_shadow_document':
            self.context.is_shadow_document(),
            'current_version_id':
            self.context.get_current_version_id(missing_as_zero=True),
        }

        result.update(additional_metadata)
        return result
コード例 #7
0
    def preview_pdf_url(self):
        """Return the url to fetch the bumblebee preview pdf."""
        if not self.is_bumblebeeable():
            return None

        return bumblebee.get_service_v3().get_representation_url(
            self.getDataOrigin(), 'pdf')
コード例 #8
0
    def get_preview_image_url(self):
        """Return the url to fetch the bumblebee preview thumbnail."""
        if not self.is_bumblebeeable():
            return None

        return bumblebee.get_service_v3().get_representation_url(
            self.getDataOrigin(), 'thumbnail')
コード例 #9
0
    def test_returns_not_digitally_available_placeholder_image_if_no_ckecksum_is_available(self):
        document = create(Builder('document'))

        brain = obj2brain(document)

        self.assertIn(
            'fallback_not_digitally_available.svg',
            bumblebee.get_service_v3().get_representation_url(brain, 'thumbnail'))
コード例 #10
0
    def test_returns_not_digitally_available_placeholder_image_if_no_ckecksum_is_available(
            self):
        document = create(Builder('document'))

        self.assertIn(
            'fallback_not_digitally_available.svg',
            bumblebee.get_service_v3().get_representation_url(
                document, 'thumbnail'))
コード例 #11
0
    def test_returns_representation_url_if_checksum_is_available(self):
        document = create(Builder('document')
                          .attach_file_containing(
                              bumblebee_asset('example.docx').bytes(),
                              u'example.docx'))

        self.assertIn(
            '/YnVtYmxlYmVl/api/v3/resource/',
            bumblebee.get_service_v3().get_representation_url(document, 'thumbnail'))
コード例 #12
0
 def get_infos_for(self, obj):
     return {
         'title': obj.Title(),
         'overlay_url': obj.absolute_url() + '/@@bumblebee-overlay-listing',
         'uid': IUUID(obj),
         'checksum': IBumblebeeDocument(obj).get_checksum(),
         'mime_type_css_class': get_css_class(obj),
         'preview_image_url': bumblebee.get_service_v3().get_representation_url(
             obj, 'thumbnail')}
コード例 #13
0
 def get_infos_for(self, brain):
     return {
         'title': brain.Title,
         'overlay_url': brain.getURL() + '/@@bumblebee-overlay-listing',
         'uid': brain.UID,
         'checksum': brain.bumblebee_checksum,
         'mime_type_css_class': get_css_class(brain),
         'preview_image_url': bumblebee.get_service_v3().get_representation_url(
             brain, 'thumbnail')}
コード例 #14
0
    def test_returns_representation_url_if_checksum_is_available(self):
        document = create(
            Builder('document').attach_file_containing(
                bumblebee_asset('example.docx').bytes(), u'example.docx'))

        self.assertIn(
            '/YnVtYmxlYmVl/api/v3/resource/',
            bumblebee.get_service_v3().get_representation_url(
                document, 'thumbnail'))
コード例 #15
0
    def __call__(self, *args, **kwargs):
        other_vars = super(GeverJSVariables, self).__call__(*args, **kwargs)
        notification_url = bumblebee.get_service_v3().get_notifications_url()

        if not is_auto_refresh_enabled():
            return other_vars

        return TEMPLATE.format(
            other_vars=other_vars,
            bumblebee_notification_url=notification_url)
コード例 #16
0
ファイル: zipexport.py プロジェクト: 4teamwork/opengever.core
    def _queue_demand_job(self, document):
        callback_url = self.meeting.get_url(view='receive_meeting_zip_pdf')
        doc_in_job_id = self.zip_job._get_doc_in_job_id(document)

        if get_service_v3().queue_demand(
                document, PROCESSING_QUEUE, callback_url,
                opaque_id=doc_in_job_id):
            return 'converting'
        else:
            return 'skipped'
コード例 #17
0
ファイル: upgrade.py プロジェクト: 4teamwork/opengever.core
    def __call__(self):
        self.install_upgrade_profile()
        service = get_service_v3()

        msg = 'Reindex checksum for documents having one of the following ' \
              'file-extensions: {}.'.format(', '.join(self.additional_mimetypes))

        for obj in ProgressLogger(msg, self.objs_to_perform()):
            IBumblebeeDocument(obj).update_checksum()
            service.trigger_storing(obj, deferred=True)
コード例 #18
0
    def __call__(self):
        self.install_upgrade_profile()
        service = get_service_v3()

        msg = 'Reindex checksum for documents having one of the following ' \
              'file-extensions: {}.'.format(', '.join(self.additional_mimetypes))

        for obj in ProgressLogger(msg, self.objs_to_perform()):
            IBumblebeeDocument(obj).update_checksum()
            service.trigger_storing(obj, deferred=True)
コード例 #19
0
    def _queue_demand_job(self, document):
        callback_url = self.meeting.get_url(view='receive_meeting_zip_pdf')
        doc_in_job_id = self.zip_job._get_doc_in_job_id(document)

        if get_service_v3().queue_demand(document,
                                         PROCESSING_QUEUE,
                                         callback_url,
                                         opaque_id=doc_in_job_id):
            return 'converting'
        else:
            return 'skipped'
コード例 #20
0
    def __call__(self):
        if not is_bumblebee_feature_enabled():
            raise NotFound

        filename = self.request.get('filename')
        if not filename:
            raise NotFound

        notify(PDFDownloadedEvent(self.context))

        url = bumblebee.get_service_v3().get_representation_url(
            self.context, 'pdf', filename=filename)
        return self.request.RESPONSE.redirect(url)
コード例 #21
0
ファイル: open_pdf.py プロジェクト: 4teamwork/opengever.core
    def __call__(self):
        if not is_bumblebee_feature_enabled():
            raise NotFound

        filename = self.request.get('filename')
        if not filename:
            raise NotFound

        notify(PDFDownloadedEvent(self.context))

        url = bumblebee.get_service_v3().get_representation_url(
            self.context, 'pdf', filename=filename)
        return self.request.RESPONSE.redirect(url)
コード例 #22
0
    def test_tooltip_contains_preview_thumbnail(self, browser):
        with freeze(datetime(2016, 1, 1)):
            document = create(Builder('document').with_dummy_content())

            self.request.form['bid'] = 'THEBID'
            browser.login().open(document, {'bid': 'THEBID'}, view='tooltip')
            thumbnail_url = bumblebee.get_service_v3().get_representation_url(
                document, 'thumbnail')

            self.assertEquals(thumbnail_url,
                              browser.css('.preview img').first.get('src'))

            self.assertEquals(['Open document preview'],
                              browser.css('.preview span').text)
コード例 #23
0
 def get_infos_for(self, obj):
     return {
         'title':
         obj.Title(),
         'overlay_url':
         obj.absolute_url() + '/@@bumblebee-overlay-listing',
         'uid':
         IUUID(obj),
         'mime_type_css_class':
         get_css_class(obj),
         'preview_image_url':
         bumblebee.get_service_v3().get_representation_url(
             obj, 'thumbnail')
     }
コード例 #24
0
 def get_infos_for(self, brain):
     return {
         'title':
         brain.Title,
         'overlay_url':
         brain.getURL() + '/@@bumblebee-overlay-listing',
         'uid':
         brain.UID,
         'mime_type_css_class':
         get_css_class(brain),
         'preview_image_url':
         bumblebee.get_service_v3().get_representation_url(
             brain, 'thumbnail')
     }
コード例 #25
0
ファイル: document.py プロジェクト: 4teamwork/opengever.core
    def __call__(self, *args, **kwargs):
        result = super(SerializeDocumentToJson, self).__call__(*args, **kwargs)

        ref_num = IReferenceNumber(self.context)
        result[u'reference_number'] = ref_num.get_number()

        bumblebee_service = bumblebee.get_service_v3()
        result[u'thumbnail_url'] = bumblebee_service.get_representation_url(
            self.context, 'thumbnail')
        result[u'preview_url'] = bumblebee_service.get_representation_url(
            self.context, 'preview')
        result[u'pdf_url'] = bumblebee_service.get_representation_url(
            self.context, 'pdf')

        return result
コード例 #26
0
    def previews(self, **kwargs):
        brains = self.get_brains()

        from_batch_id = int(self.request.get('documentPointer', 0))
        to_batch_id = from_batch_id + self.pagesize

        for brain in brains[from_batch_id:to_batch_id]:
            yield {
                'title': brain.Title,
                'overlay_url': '{}/@@bumblebee-overlay-listing'.format(brain.getURL()),
                'preview_image_url': bumblebee.get_service_v3().get_representation_url(
                    brain, 'thumbnail'),
                'uid': brain.UID,
                'mime_type_css_class': get_css_class(brain),
            }
コード例 #27
0
    def test_tooltip_contains_preview_thumbnail(self, browser):
        with freeze(datetime(2016, 1, 1)):
            document = create(Builder('document').with_dummy_content())

            self.request.form['bid'] = 'THEBID'
            browser.login().open(document, {'bid': 'THEBID'}, view='tooltip')
            thumbnail_url = bumblebee.get_service_v3().get_representation_url(
                document, 'thumbnail')

            self.assertEquals(
                thumbnail_url,
                browser.css('.preview img').first.get('src'))

            self.assertEquals(
                ['Open document preview'],
                browser.css('.preview span').text)
コード例 #28
0
    def previews(self, **kwargs):
        brains = self.get_brains()

        from_batch_id = int(self.request.get('documentPointer', 0))
        to_batch_id = from_batch_id + self.pagesize

        for brain in brains[from_batch_id:to_batch_id]:
            yield {
                'title':
                brain.Title,
                'overlay_url':
                '{}/@@bumblebee-overlay-listing'.format(brain.getURL()),
                'preview_image_url':
                bumblebee.get_service_v3().get_representation_url(
                    brain, 'thumbnail'),
                'uid':
                brain.UID,
                'mime_type_css_class':
                get_css_class(brain),
            }
コード例 #29
0
 def get_preview_pdf_url(self):
     return bumblebee.get_service_v3().get_representation_url(
         self.context, 'preview')
コード例 #30
0
 def preview_image_url(self):
     return bumblebee.get_service_v3().get_representation_url(
         self.context, 'image')
コード例 #31
0
ファイル: overlay.py プロジェクト: lukasgraf/opengever.core
 def get_preview_pdf_url(self):
     return bumblebee.get_service_v3().get_representation_url(
         self.context, 'preview')
コード例 #32
0
 def test_bumblebee_service_registration(self):
     service = get_service_v3()
     self.assertIsInstance(service, GeverBumblebeeService)
コード例 #33
0
 def get_preview_image_url(self):
     return bumblebee.get_service_v3().get_representation_url(
         self.context, 'image')
コード例 #34
0
 def get_preview_image_url(self):
     return bumblebee.get_service_v3().get_representation_url(
         self.context.get_proposal_document(), 'image')