Example #1
0
    def render(self):
        if is_officeconnector_checkout_feature_enabled():
            payload = {'action': 'checkout'}

            return self.create_officeconnector_url_json(payload)

        # Fail per default
        raise NotFound
Example #2
0
    def render(self):
        if is_officeconnector_checkout_feature_enabled():
            payload = {'action': 'checkout'}

            return self.create_officeconnector_url_json(payload)

        # Fail per default
        raise NotFound
Example #3
0
    def render(self):
        # Feature disabled or used wrong
        if not is_officeconnector_checkout_feature_enabled():
            raise NotFound

        payload = {'action': 'checkout'}

        return self.create_officeconnector_url_json(payload)
Example #4
0
    def test_if_registry_entries_are_false(self):
        api.portal.set_registry_record(
            'attach_to_outlook_enabled',
            False,
            interface=IOfficeConnectorSettings)

        api.portal.set_registry_record(
            'direct_checkout_and_edit_enabled',
            False,
            interface=IOfficeConnectorSettings)

        self.assertFalse(is_officeconnector_attach_feature_enabled())
        self.assertFalse(is_officeconnector_checkout_feature_enabled())
    def checkout_and_external_edit(self, document):
        """Checkout the document and invoke an external editing session.
        """

        # When the officeconnector checkout feature is enabled,
        # office connector will checkout the document before opening the
        # document in word, so there is no need to checkout the document
        # at this point.
        if not is_officeconnector_checkout_feature_enabled():
            getMultiAdapter((document, self.request),
                            ICheckinCheckoutManager).checkout()

        document.setup_external_edit_redirect(self.request)
Example #6
0
 def setup_external_edit_redirect(self, request):
     redirector = IRedirector(request)
     if is_officeconnector_checkout_feature_enabled():
         redirector.redirect(create_oc_url(
             request,
             self,
             dict(action='checkout'),
         ))
     else:
         redirector.redirect(
             '%s/external_edit' % self.absolute_url(),
             target='_self',
             timeout=1000)
    def checkout_and_external_edit(self, document):
        """Checkout the document and invoke an external editing session.
        """

        # When the officeconnector checkout feature is enabled,
        # office connector will checkout the document before opening the
        # document in word, so there is no need to checkout the document
        # at this point.
        if not is_officeconnector_checkout_feature_enabled():
            getMultiAdapter((document, self.request),
                            ICheckinCheckoutManager).checkout()

        document.setup_external_edit_redirect(self.request)
Example #8
0
    def checkout_and_get_office_connector_url(self):
        """Checkout the document and return an office connector url.
        With the officeconnector checkout feature enabled, the checkout
        happens when the link is used.
        """
        if is_officeconnector_checkout_feature_enabled():
            return create_oc_url(self.REQUEST, self, {'action': 'checkout'})

        else:
            checkout_manager = getMultiAdapter((self, self.REQUEST),
                                               ICheckinCheckoutManager)
            if not checkout_manager.is_checked_out_by_current_user():
                checkout_manager.checkout()

            return '{}/external_edit'.format(self.absolute_url())
Example #9
0
    def checkout_and_get_office_connector_url(self):
        """Checkout the document and return an office connector url.
        With the officeconnector checkout feature enabled, the checkout
        happens when the link is used.
        """
        if is_officeconnector_checkout_feature_enabled():
            return create_oc_url(self.REQUEST, self, {'action': 'checkout'})

        else:
            checkout_manager = getMultiAdapter((self, self.REQUEST),
                                               ICheckinCheckoutManager)
            if not checkout_manager.is_checked_out_by_current_user():
                checkout_manager.checkout()

            return '{}/external_edit'.format(self.absolute_url())
Example #10
0
    def test_creating_proposal_from_proposal_template(self, browser):
        self.login(self.dossier_responsible, browser)
        browser.open(self.dossier)
        factoriesmenu.add('Proposal')
        browser.fill(
            {'Title': u'Baugesuch Kreuzachkreisel',
             'Committee': u'Rechnungspr\xfcfungskommission',
             'Proposal template': u'Geb\xfchren',
             'Edit after creation': True}).save()
        statusmessages.assert_no_error_messages()
        self.assertIn('external_edit', browser.css('.redirector').first.text,
                      'External editor should have been triggered.')

        proposal = browser.context
        browser.open(proposal, view='tabbedview_view-overview')
        self.assertEquals(
            [['Title', u'Baugesuch Kreuzachkreisel'],
             ['Committee', u'Rechnungspr\xfcfungskommission'],
             ['Meeting', ''],
             ['Proposal document',
              'Baugesuch Kreuzachkreisel'],
             ['State', 'Pending'],
             ['Decision number', '']],
            browser.css('table.listing').first.lists())

        browser.click_on('Baugesuch Kreuzachkreisel')
        browser.open(browser.context, view='tabbedview_view-overview')
        self.assertDictContainsSubset(
            {'Title': u'Baugesuch Kreuzachkreisel'},
            dict(browser.css('table.listing').first.lists()))

        self.assertEquals(
            self.proposal_template.file.data,
            proposal.get_proposal_document().file.data)

        self.assertFalse(
            is_officeconnector_checkout_feature_enabled(),
            'Office connector checkout feature is now active: this means'
            ' that the document will no longer be checked out in the proposal'
            ' creation wizard and therefore the assertion "document is checked'
            ' out" will therefore fail.')
        self.assertEquals(
            self.dossier_responsible.getId(),
            self.get_checkout_manager(
                proposal.get_proposal_document()).get_checked_out_by())
Example #11
0
 def setup_external_edit_redirect(self, request, action='checkout'):
     redirector = IRedirector(request)
     if action == "checkout":
         if is_officeconnector_checkout_feature_enabled():
             redirector.redirect(create_oc_url(
                 request,
                 self,
                 dict(action=action),
             ))
         else:
             redirector.redirect(
                 '%s/external_edit' % self.absolute_url(),
                 target='_self',
                 timeout=1000)
     elif action == "oneoffixx" and is_oneoffixx_feature_enabled():
         redirector.redirect(create_oc_url(
                 request,
                 self,
                 dict(action=action),
             ))
 def is_oc_zem_edit_action_available(self):
     return (self.is_any_checkout_or_edit_available()
             and self.context.is_office_connector_editable()
             and self.context.is_checked_out()
             and not is_officeconnector_checkout_feature_enabled())
Example #13
0
 def test_if_registry_entries_are_false_per_default(self):
     self.assertFalse(is_officeconnector_attach_feature_enabled())
     self.assertFalse(is_officeconnector_checkout_feature_enabled())
Example #14
0
 def is_checkout_enabled(self):
     return is_officeconnector_checkout_feature_enabled()
Example #15
0
    def test_creating_proposal_from_proposal_template(self, browser):
        self.login(self.dossier_responsible, browser)
        browser.open(self.dossier)
        factoriesmenu.add('Proposal')
        browser.fill(
            {'Title': u'Baugesuch Kreuzachkreisel',
             'Description': u'Ein n\xf6tiger Bau',
             'Committee': u'Rechnungspr\xfcfungskommission',
             'Proposal template': u'Geb\xfchren',
             'Edit after creation': True,
             'Attachments': [self.document]},
             ).save()

        statusmessages.assert_no_error_messages()
        self.assertIn('external_edit', browser.css('.redirector').first.text,
                      'External editor should have been triggered.')

        proposal = browser.context
        browser.open(proposal, view='tabbedview_view-overview')
        self.assertEquals(
            [['Title', u'Baugesuch Kreuzachkreisel'],
             ['Description', u'Ein n\xf6tiger Bau'],
             ['Committee', u'Rechnungspr\xfcfungskommission'],
             ['Meeting', ''],
             ['Issuer', 'Ziegler Robert (robert.ziegler)'],
             ['Proposal document', 'Baugesuch Kreuzachkreisel'],
             ['State', 'Pending'],
             ['Decision number', ''],
             ['Attachments', u'Vertr\xe4gsentwurf'],
             ['Excerpt', '']],
            browser.css('table.listing').first.lists())
        self.assertEqual(u'en', proposal.language)
        self.assertEqual(self.document, proposal.relatedItems[0].to_object)
        self.assert_workflow_state('proposal-state-active', proposal)

        model = proposal.load_model()
        self.assertEqual(u'Baugesuch Kreuzachkreisel', model.title)
        self.assertEqual(u'Ein n\xf6tiger Bau', model.description)
        self.assertIsNone(model.submitted_title)
        self.assertIsNone(model.submitted_description)
        self.assertEqual(Oguid.for_object(proposal), model.oguid)
        self.assertEqual('robert.ziegler', model.issuer)
        self.assertEqual(u'Vertr\xe4ge und Vereinbarungen',
                         model.repository_folder_title)
        self.assertEqual(u'en', model.language)
        self.assertEqual(u'Client1 1.1 / 1', model.dossier_reference_number)

        self.assertTrue(set(['baugesuch', 'kreuzachkreisel',
                             'ein', 'notiger', 'bau']).issubset(
            set(index_data_for(proposal)['SearchableText'])))

        browser.click_on('Baugesuch Kreuzachkreisel')
        browser.open(browser.context, view='tabbedview_view-overview')
        self.assertDictContainsSubset(
            {'Title': u'Baugesuch Kreuzachkreisel'},
            dict(browser.css('table.listing').first.lists()))

        self.assertEquals(
            self.proposal_template.file.data,
            proposal.get_proposal_document().file.data)

        self.assertFalse(
            is_officeconnector_checkout_feature_enabled(),
            'Office connector checkout feature is now active: this means'
            ' that the document will no longer be checked out in the proposal'
            ' creation wizard and therefore the assertion "document is checked'
            ' out" will therefore fail.')
        self.assertEquals(
            self.dossier_responsible.getId(),
            self.get_checkout_manager(
                proposal.get_proposal_document()).get_checked_out_by())
Example #16
0
    def render(self):
        # check whether we have paths or not
        paths = self.request.get('paths')

        # using "paths" is mandantory on any objects except for a document
        if not paths and not IDocumentSchema.providedBy(self.context):
            msg = _(u'You have not selected any documents.')
            IStatusMessage(self.request).addStatusMessage(
                msg, type='error')

            # we assume the request came from the tabbed_view "documents"
            # tab on the dossier
            return self.request.RESPONSE.redirect(
                '%s#documents' % self.context.absolute_url())

        elif paths:
            # lookup the objects to be handled using the catalog
            catalog = getToolByName(self.context, 'portal_catalog')
            objects = []
            for path in paths:
                query = dict(path={'query': path, 'depth': 0})
                obj = catalog(query)[0].getObject()
                objects.append(obj)

        else:
            # the context is the document
            objects = [self.context]

        # now, lets checkout every document
        for obj in objects:
            if not IDocumentSchema.providedBy(obj):
                # notify the user. we have a no-checkoutable object
                msg = _(
                    u'Could not check out object: ${title}, '
                    'it is not a document.',
                    mapping={'title': obj.Title().decode('utf-8')})
                IStatusMessage(
                    self.request).addStatusMessage(msg, type='error')
                continue

            self.checkout(obj)

        # lets register a redirector for starting external
        # editor - if requested
        external_edit = self.request.get('mode') == 'external'
        if len(objects) == 1 and external_edit:
            redirector = IRedirector(self.request)
            if not is_officeconnector_checkout_feature_enabled():
                redirector.redirect(
                    '%s/external_edit' % objects[0].absolute_url(),
                    target='_self',
                    timeout=1000)
            else:
                redirector.redirect(create_oc_url(
                    self.request,
                    self.context,
                    dict(action='checkout'),
                    ))
        # now lets redirect to an appropriate target..
        if len(objects) == 1:
            return self.request.RESPONSE.redirect(
                objects[0].absolute_url())

        else:
            return self.request.RESPONSE.redirect(
                '%s#documents' % self.context.absolute_url())
Example #17
0
 def test_registry_entry_defaults(self):
     self.assertTrue(is_officeconnector_attach_feature_enabled())
     self.assertTrue(is_officeconnector_checkout_feature_enabled())
     self.assertFalse(is_officeconnector_restapi_feature_enabled())