def __call__(self, **kwargs): PostOnly(self.request) form = self.request.form recurse = form.get('workflow_archive_recurse', False) prev_versions = form.get('workflow_archive_previous_versions', False) val = {'initiator': form.get('workflow_archive_initiator', ''), 'custom_message': form.get('workflow_other_reason', '').strip(), 'reason': form.get('workflow_reasons_radio', 'other'), } context = self.context ploneview = getMultiAdapter((context, self.request), name='plone') if ploneview.isDefaultPageInFolder(): context = self.context.getParentNode() if recurse and not prev_versions: archive_obj_and_children(context, **val) elif recurse and prev_versions: archive_obj_and_children(context, **val) archive_previous_versions(context, also_children=True, **val) elif prev_versions and not recurse: archive_object(context, **val) archive_previous_versions(context, **val) else: archive_object(context, **val) return "OK"
def test_archive_previous_versions(self): """ Test the archival of the previous versions for the given object """ version = create_version(self.folder) archive_previous_versions(version) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder)
def test_archive_previous_versions_with_children(self): """ Test the archival of the previous versions for the given object and their children """ version = create_version(self.folder) archive_previous_versions(version, also_children=True) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder) assert IObjectArchived.providedBy(self.doc)
def test_archive_previous_versions_without_children(self): """ Test the archival of the previous versions for the given object even when calling the method that should archive also the children """ fid = self.portal.invokeFactory("Folder", 'f2') self.folder = self.portal[fid] version = create_version(self.folder) archive_previous_versions(version, also_children=True) assert not IObjectArchived.providedBy(version) assert IObjectArchived.providedBy(self.folder)
def test_archive_previous_versions_with_children_return(self): """ Test the return value for archival of the previous versions for the given object and their children """ version = create_version(self.folder) objects = archive_previous_versions(version, also_children=True) expected_output = [self.folder, self.doc] assert objects == expected_output