def setUp(self):
        omitted_values = IDocumentSchema.getTaggedValue(OMITTED_KEY)
        self.org_omitted_values = list(omitted_values)
        omitted_values.append((Interface, 'document_type', 'true'))
        IDocumentSchema.setTaggedValue(OMITTED_KEY, omitted_values)

        self.document = create(Builder('document'))
    def setUp(self):
        omitted_values = IDocumentSchema.getTaggedValue(OMITTED_KEY)
        self.org_omitted_values = list(omitted_values)
        omitted_values.append((Interface, 'document_type', 'true'))
        IDocumentSchema.setTaggedValue(OMITTED_KEY, omitted_values)

        self.document = create(Builder('document'))
Exemple #3
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)
            redirector.redirect('%s/external_edit' % objects[0].absolute_url(),
                                target='_self',
                                timeout=1000)

        # 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())
Exemple #4
0
    def __call__(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
        if not self.request.get('reauth') == '1':
            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'

        # now lets redirect to an appropriate target..
        if len(objects) == 1:
            if external_edit:
                objects[0].setup_external_edit_redirect(self.request)
            return self.request.RESPONSE.redirect(
                objects[0].absolute_url())

        else:
            return self.request.RESPONSE.redirect(
                '%s#documents' % self.context.absolute_url())
Exemple #5
0
def file_copy_downloaded(context, event):

    title_unversioned = _(u'label_file_copy_downloaded',
                          default=u'Download copy')

    if IDocumentSchema.providedBy(context):
        version_id = getattr(event, 'version_id')

        if version_id is not None:
            version_string = _(u'label_file_copy_downloaded_version',
                               default=u'version ${version_id}',
                               mapping={'version_id': version_id})
        else:
            version_string = _(
                u'label_file_copy_downloaded_actual_version',
                default=u'current version (${version_id})',
                mapping={'version_id': getattr(context, 'version_id', 0)})

        title = _(u'label_file_copy_downloaded_with_version',
                  default=u'${title} ${version_string}',
                  mapping={'title': title_unversioned,
                           'version_string': version_string})
    else:
        title = title_unversioned

    journal_entry_factory(context, FILE_COPY_DOWNLOADED, title)
    def render(self):
        parent = aq_parent(aq_inner(self.context))

        # not allowed for anonymous users
        mtool = getToolByName(self.context, 'portal_membership')
        if mtool.isAnonymousUser():
            return False

        # if webdav is not allowed, we cannot externally edit
        if not webdav_enabled(self.context, parent):
            return False

        # only allowed on documents
        if not IDocumentSchema.providedBy(self.context):
            return False

        # only allowed, when there already is a file
        if not self.context.file:
            return False

        # only allowed when the current user has checked out the document
        current_user_id = getSecurityManager().getUser().getId()
        manager = queryMultiAdapter((self.context, self.request),
                                    ICheckinCheckoutManager)

        if not manager or manager.checked_out() != current_user_id:
            return False

        # Content may provide data to the external editor ?
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        return not not portal.externalEditLink_(self.context)
    def __call__(self):
        parent = aq_parent(aq_inner(self.context))

        # not allowed for anonymous users
        mtool = getToolByName(self.context, 'portal_membership')
        if mtool.isAnonymousUser():
            return False

        # if webdav is not allowed, we cannot externally edit
        if not webdav_enabled(self.context, parent):
            return False

        # only allowed on documents
        if not IDocumentSchema.providedBy(self.context):
            return False

        # only allowed, when there already is a file
        if not self.context.file:
            return False

        # only allowed when the current user has checked out the document
        current_user_id = getSecurityManager().getUser().getId()
        manager = queryMultiAdapter((self.context, self.request),
                                    ICheckinCheckoutManager)

        if not manager or manager.get_checked_out_by() != current_user_id:
            return False

        # Content may provide data to the external editor ?
        portal = getToolByName(self.context, 'portal_url').getPortalObject()
        return not not portal.externalEditLink_(self.context)
Exemple #8
0
 def _add_descendants(self):
     objs = self.obj.objectValues()
     for obj in objs:
         if IDossierMarker.providedBy(obj):
             self.dossiers[obj.UID()] = Dossier(obj)
         elif IDocumentSchema.providedBy(obj):
             self.documents[obj.UID()] = Document(obj)
Exemple #9
0
 def _add_descendants(self):
     objs = self.obj.objectValues()
     for obj in objs:
         if IDossierMarker.providedBy(obj):
             self.dossiers[obj.UID()] = Dossier(obj)
         elif IDocumentSchema.providedBy(obj):
             self.documents[obj.UID()] = Document(obj)
Exemple #10
0
 def is_download_pdfpreview_available(self):
     """PDF Preview link is only available for documents and
     opengever.pdfconverter is installed.
     """
     if self.is_preview_supported():
         return IDocumentSchema.providedBy(self.context)
     return False
Exemple #11
0
    def cancel(self, action):
        # on a document? go back to the document
        if IDocumentSchema.providedBy(self.context):
            return self.request.RESPONSE.redirect(self.context.absolute_url())

        # otherwise to the dossier or task
        return get_containg_document_tab_url(self.context)
 def is_download_pdfpreview_available(self):
     """PDF Preview link is only available for documents and
     opengever.pdfconverter is installed.
     """
     if self.is_preview_supported():
         return IDocumentSchema.providedBy(self.context)
     return False
Exemple #13
0
 def _add_descendants(self):
     objs = self.obj.objectValues()
     for obj in objs:
         if IDossierMarker.providedBy(obj):
             self.dossiers.append(Dossier(obj, self.path))
         elif IDocumentSchema.providedBy(obj):
             self.documents.append(Document(obj, self.path))
def file_copy_downloaded(context, event):

    title_unversioned = _(u'label_file_copy_downloaded',
                          default=u'Download copy')

    if IDocumentSchema.providedBy(context):
        version_id = getattr(event, 'version_id')

        if version_id is not None:
            version_string = _(u'label_file_copy_downloaded_version',
                               default=u'version ${version_id}',
                               mapping={'version_id': version_id})
        else:
            version_string = _(u'label_file_copy_downloaded_actual_version',
                               default=u'current version (${version_id})',
                               mapping={'version_id': context.version_id})

        title = _(u'label_file_copy_downloaded_with_version',
                  default=u'${title} ${version_string}',
                  mapping={
                      'title': title_unversioned,
                      'version_string': version_string
                  })
    else:
        title = title_unversioned

    journal_entry_factory(context, FILE_COPY_DOWNLOADED, title)
Exemple #15
0
    def cancel(self, action):
        # on a document? go back to the document
        if IDocumentSchema.providedBy(self.context):
            return self.request.RESPONSE.redirect(
                self.context.absolute_url())

        # otherwise to the dossier or task
        return get_containg_document_tab_url(self.context)
    def test_keywords_are_listed_on_overview(self, browser):
        self.login(self.regular_user, browser=browser)

        IDocumentSchema(self.document).keywords = u'secret', u'special'

        browser.open(self.document, view='tabbedview_view-overview')

        self.assertEquals([u'secret', u'special'],
                          browser.css('.keywords a').text)
Exemple #17
0
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            source = data['request_paths'].split(';;')
            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            for path in source:

                # Get source object
                src_object = self.context.unrestrictedTraverse(
                    path.encode('utf-8'))

                # Get parent object
                source_container = aq_parent(aq_inner(
                    self.context.unrestrictedTraverse(
                        path.encode('utf-8'))))

                src_name = src_object.title
                src_id = src_object.id

                # If parent isn't a dossier and obj is a document
                # it's connected to a task and shouldn't be moved
                if not IDossierMarker.providedBy(source_container) and \
                    IDocumentSchema.providedBy(src_object):
                    msg = _(u'Document ${name} is connected to a Task.\
                    Please move the Task.', mapping=dict(name=src_name))
                    IStatusMessage(self.request).addStatusMessage(
                        msg, type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = source_container.manage_cutObjects(src_id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(src_name)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(src_name)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects, )

            self.request.RESPONSE.redirect(destination.absolute_url())
Exemple #18
0
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            try:
                objs = self.extract_selected_objs(data)
            except KeyError:
                IStatusMessage(self.request).addStatusMessage(_(
                    u"The selected objects can't be found, please try it again."
                ),
                                                              type='error')
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

            for obj in objs:
                parent = aq_parent(aq_inner(obj))

                if IDocumentSchema.providedBy(obj) and not obj.is_movable():
                    msg = _(u'Document ${name} is not movable.',
                            mapping=dict(name=obj.title))
                    IStatusMessage(self.request).addStatusMessage(msg,
                                                                  type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = parent.manage_cutObjects(obj.id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(obj.title)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(obj.title)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects,
            )

            self.request.RESPONSE.redirect(destination.absolute_url())
Exemple #19
0
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            try:
                objs = self.extract_selected_objs(data)
            except KeyError:
                IStatusMessage(self.request).addStatusMessage(
                    _(u"The selected objects can't be found, please try it again."),
                    type='error')
                return self.request.RESPONSE.redirect(self.context.absolute_url())

            for obj in objs:
                parent = aq_parent(aq_inner(obj))

                if IDocumentSchema.providedBy(obj) and not obj.is_movable():
                    msg = _(u'Document ${name} is connected to a Task. '
                            'Please move the Task.',
                            mapping=dict(name=obj.title))
                    IStatusMessage(self.request).addStatusMessage(msg, type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = parent.manage_cutObjects(obj.id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(obj.title)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(obj.title)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects, )

            self.request.RESPONSE.redirect(destination.absolute_url())
Exemple #20
0
    def item_paths(self):
        # from the form?
        field_name = self.prefix + self.widgets.prefix + 'paths'
        value = self.request.get(field_name, False)
        if value:
            value = value.split(';;')
            return value

        # from folder_contents / tabbed_view?
        value = self.request.get('paths')
        if value:
            return value

        # from the context?
        if IDocumentSchema.providedBy(self.context):
            return ['/'.join(self.context.getPhysicalPath())]

        # nothing found..
        raise NoItemsSelected
Exemple #21
0
    def item_paths(self):
        # from the form?
        field_name = self.prefix + self.widgets.prefix + 'paths'
        value = self.request.get(field_name, False)
        if value:
            value = value.split(';;')
            return value

        # from folder_contents / tabbed_view?
        value = self.request.get('paths')
        if value:
            return value

        # from the context?
        if IDocumentSchema.providedBy(self.context):
            return ['/'.join(self.context.getPhysicalPath())]

        # nothing found..
        raise NoItemsSelected
Exemple #22
0
    def checkin_button_handler(self, action):
        """Handle checkin
        """

        data, errors = self.extractData()

        if len(errors) == 0:
            # check in each document
            for obj in self.objects:
                if IDocumentSchema.providedBy(obj):
                    manager = getMultiAdapter((obj, obj.REQUEST),
                                              ICheckinCheckoutManager)

                    if not manager.is_checkin_allowed():
                        msg = _(
                            u'Could not check in document ${title}',
                            mapping=dict(title=obj.Title().decode('utf-8')))
                        IStatusMessage(self.request).addStatusMessage(
                            msg, type='error')

                    else:
                        manager.checkin(data['comment'])
                        msg = _(
                            u'Checked in: ${title}',
                            mapping=dict(title=obj.Title().decode('utf-8')))
                        IStatusMessage(self.request).addStatusMessage(
                            msg, type='info')

                else:
                    title = obj.Title()
                    if not isinstance(title, unicode):
                        title = title.decode('utf-8')
                    msg = _(
                        u'Could not check in ${title}, it is not a document.',
                        mapping=dict(title=title))
                    IStatusMessage(self.request).addStatusMessage(
                        msg, type='error')

            # redirect to dossier
            return self.request.RESPONSE.redirect(
                get_containg_document_tab_url(self.context))
Exemple #23
0
    def checkin_button_handler(self, action):
        """Handle checkin
        """

        data, errors = self.extractData()

        if len(errors) == 0:
            # check in each document
            for obj in self.objects:
                if IDocumentSchema.providedBy(obj):
                    manager = getMultiAdapter((obj, obj.REQUEST),
                                              ICheckinCheckoutManager)

                    if not manager.is_checkin_allowed():
                        msg = _(
                            u'Could not check in document ${title}',
                            mapping=dict(title=obj.Title().decode('utf-8')))
                        IStatusMessage(self.request).addStatusMessage(
                            msg, type='error')

                    else:
                        manager.checkin(data['comment'])
                        msg = _(
                            u'Checked in: ${title}',
                            mapping=dict(title=obj.Title().decode('utf-8')))
                        IStatusMessage(self.request).addStatusMessage(
                            msg, type='info')

                else:
                    title = obj.Title()
                    if not isinstance(title, unicode):
                        title = title.decode('utf-8')
                    msg = _(
                        u'Could not check in ${title}, it is not a document.',
                        mapping=dict(title=title))
                    IStatusMessage(self.request).addStatusMessage(msg,
                                                                  type='error')

            # redirect to dossier
            return self.request.RESPONSE.redirect(
                get_containg_document_tab_url(self.context))
Exemple #24
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 cancel every document
        for obj in objects:
            self.cancel(obj)

        # 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())
    def __call__(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.')
            api.portal.show_message(message=msg,
                                    request=self.request,
                                    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 = api.portal.get_tool('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 cancel every document
        for obj in objects:
            self.cancel(obj)

        # 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())
 def is_document(self):
     return IDocumentSchema.providedBy(self.context)
 def tearDown(self):
     IDocumentSchema.setTaggedValue(OMITTED_KEY, self.org_omitted_values)
Exemple #28
0
 def end(self):
     document = IDocumentSchema(self.context)
     return document.end
Exemple #29
0
 def add_object(self, obj):
     if IDossierMarker.providedBy(obj):
         self.dossiers.append(Dossier(obj, u'files'))
     elif IDocumentSchema.providedBy(obj):
         self.documents.append(Document(obj, u'files'))
    def test_create_document_method(self):

        # we need to register any plone.directives.form magic components
        # from the module manually (they are not grokky):
        for factory, name in document.__form_value_adapters__:
            provideAdapter(factory, name=name)

        class MockContext(object):
            def __init__(self, fti, template):
                self.fti = fti
                self.template = template
            def _setObject(self, id, obj):
                self.obj = obj
            def _getOb(self, id):
                return self.obj
            def restrictedTraverse(self, testpath):
                return self.template
            def getTypeInfo(self):
                return self.fti

        # Mock the lookup of the site and the site manager at the site root
        dummy_site = self.create_dummy()
        self.mock_utility(dummy_site, ISiteRoot)

        # fti fake
        fti = DexterityFTI(u'opengever.document.document')
        fti.schema = 'opengever.document.document.IDocumentSchema'
        fti.model_source = None
        fti.model_file = None
        fti.addable_types = ['opengever.document.document']
        fti.isConstructionAllowed = lambda x: True
        fti.allowType = lambda x: True
        register(fti)
        site_manager_mock = self.mocker.proxy(
            PersistentComponents(bases=(getGlobalSiteManager(),)))
        getSiteManager_mock = self.mocker.replace(
            'zope.app.component.hooks.getSiteManager')
        self.expect(
            getSiteManager_mock(
                dummy_site)).result(site_manager_mock).count(0 , None)

        alsoProvides(IDocumentSchema.get('file'), IPrimaryField)

        # Name chooser
        class NameChooser(object):
            implements(INameChooser)
            def __init__(self, context):
                pass
            def chooseName(self, name, object):
                return u"newid"
        self.mock_adapter(NameChooser, INameChooser, (Interface,))

        # template
        namedfile = self.stub()
        template_doc = self.stub()
        self.expect(template_doc.file).result(namedfile)
        self.expect(template_doc.portal_type).result(
            'opengever.document.document')
        self.expect(namedfile.data).result('data data data')
        self.expect(namedfile.filename).result(u'test_filename.doc')

        # context and request
        context = MockContext(fti, template_doc)
        request = self.stub_request()
        testpath = 'testpath'

        # registry
        registry_mock = self.stub()
        self.expect(registry_mock.forInterface(IDocumentSettings)).result(registry_mock)
        self.expect(registry_mock.preserved_as_paper_default).result(False)
        self.mock_utility(registry_mock, IRegistry)

        self.replay()
        view = TemplateDocumentFormView(context, request)
        view.title = u'Test Title'

        view.create_document(testpath)

        self.assertEqual(context.obj.portal_type, u'opengever.document.document')
        self.assertFalse(context.obj.file == namedfile)
        self.assertEquals(context.obj.file.data, namedfile.data)
        self.assertEqual(context.obj.document_date, datetime.now().date())
        self.assertEqual(context.obj.preserved_as_paper, False)
Exemple #31
0
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            try:
                objs = self.extract_selected_objs(data)
            except KeyError:
                IStatusMessage(self.request).addStatusMessage(_(
                    u"The selected objects can't be found, please try it again."
                ),
                                                              type='error')
                return self.request.RESPONSE.redirect(
                    self.context.absolute_url())

            for obj in objs:
                parent = aq_parent(aq_inner(obj))

                if IDocumentSchema.providedBy(obj) and not obj.is_movable():
                    if obj.is_inside_a_task():
                        msg = _(
                            'label_not_movable_since_inside_task',
                            default=u'Document ${name} is inside a task and '
                            u'therefore not movable. Move the task '
                            u'instead',
                            mapping=dict(name=obj.title))
                    elif obj.is_inside_a_proposal():
                        msg = _(
                            'label_not_movable_since_inside_proposal',
                            default=u'Document ${name} is inside a proposal '
                            u'and therefore not movable. Move the '
                            u'proposal instead',
                            mapping=dict(name=obj.title))
                    else:
                        raise Exception(
                            'Failed to determine the reason for unmovable document. '
                            'Did IDocumentSchema.is_moveable change?')
                    IStatusMessage(self.request).addStatusMessage(msg,
                                                                  type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = parent.manage_cutObjects(obj.id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(obj.title)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(obj.title)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects,
            )

            self.request.RESPONSE.redirect(destination.absolute_url())
 def test_document_without_digital_file_must_be_preserved_in_paper(self):
     document = create(Builder("document").having(preserved_as_paper=False))
     with self.assertRaises(Invalid) as cm:
         IDocumentSchema.validateInvariants(document)
     self.assertEquals("error_title_or_file_required", str(cm.exception))
    def handle_submit(self, action):
        data, errors = self.extractData()
        if len(errors) == 0:

            destination = data['destination_folder']
            failed_objects = []
            failed_resource_locked_objects = []
            copied_items = 0

            try:
                objs = self.extract_selected_objs(data)
            except KeyError:
                IStatusMessage(self.request).addStatusMessage(
                    _(u"The selected objects can't be found, please try it again."),
                    type='error')
                return self.request.RESPONSE.redirect(self.context.absolute_url())

            for obj in objs:
                parent = aq_parent(aq_inner(obj))

                if IDocumentSchema.providedBy(obj) and not obj.is_movable():
                    if obj.is_inside_a_task():
                        msg = _(
                            'label_not_movable_since_inside_task',
                            default=u'Document ${name} is inside a task and '
                                    u'therefore not movable. Move the task '
                                    u'instead',
                            mapping=dict(name=obj.title))
                    elif obj.is_inside_a_proposal():
                        msg = _(
                            'label_not_movable_since_inside_proposal',
                            default=u'Document ${name} is inside a proposal '
                                    u'and therefore not movable. Move the '
                                    u'proposal instead',
                            mapping=dict(name=obj.title))
                    else:
                        raise Exception(
                            'Failed to determine the reason for unmovable document. '
                            'Did IDocumentSchema.is_moveable change?'
                        )
                    IStatusMessage(self.request).addStatusMessage(msg, type='error')
                    continue

                try:
                    # Try to cut and paste object
                    clipboard = parent.manage_cutObjects(obj.id)
                    destination.manage_pasteObjects(clipboard)
                    copied_items += 1

                except ResourceLockedError:
                    # The object is locket over webdav
                    failed_resource_locked_objects.append(obj.title)
                    continue

                except (ValueError, CopyError):
                    # Catch exception and add title to a list of failed objects
                    failed_objects.append(obj.title)
                    continue

            self.create_statusmessages(
                copied_items,
                failed_objects,
                failed_resource_locked_objects, )

            self.request.RESPONSE.redirect(destination.absolute_url())
 def tearDown(self):
     IDocumentSchema.setTaggedValue(OMITTED_KEY, self.org_omitted_values)
 def test_document_without_digital_file_must_be_preserved_in_paper(self):
     document = create(Builder("document").having(preserved_as_paper=False))
     with self.assertRaises(Invalid) as cm:
         IDocumentSchema.validateInvariants(document)
     self.assertEquals("error_title_or_file_required", str(cm.exception))
Exemple #36
0
 def filefield(self):
     return IDocumentSchema.get('file').get(self.context)
Exemple #37
0
 def filefield(self):
     return IDocumentSchema.get('file').get(self.context)
Exemple #38
0
 def responsible(self):
     mt = getToolByName(self.context, 'portal_membership')
     document = IDocumentSchema(self.context)
     return mt.getMemberById(document.responsible)
 def process_document(self, obj, comment, force=False):
     if IDocumentSchema.providedBy(obj):
         self.perform_checkin(obj, comment, force)
     else:
         self.report_cannot_checkin_non_document(obj)
Exemple #40
0
 def process_document(self, obj, comment, force=False):
     if IDocumentSchema.providedBy(obj):
         self.perform_checkin(obj, comment, force)
     else:
         self.report_cannot_checkin_non_document(obj)