def reindex_containing_dossier_for_contained_objects(dossier, event): """Reindex the containging_dossier index for all the contained obects. """ for brain in dossier.portal_catalog(path='/'.join(dossier.getPhysicalPath())): obj = brain.getObject() obj.reindexObject(idxs=['containing_dossier']) if ITask.providedBy(obj): sync_task(brain.getObject(), event)
def test_list_only_active_tasks(self, browser): create(Builder("forwarding").having(issuer="inbox:client1").titled("Active")) closed = create( Builder("forwarding").having(issuer="inbox:client1").in_state("forwarding-state-closed").titled("Closed") ) sync_task(closed, None) browser.login().open(self.inbox, view="tabbedview_view-overview") self.assertSequenceEqual(browser.css("#issued_inbox_tasksBox li:not(.moreLink) span span").text, ["Active"])
def object_moved_or_added(context, event): if isinstance(event, ObjectAddedEvent): # Don't consider moving or removing an object a "touch". Mass-moves # would immediately fill up the touched log, and removals should not # be tracked anyway. if should_track_touches(context): notify(ObjectTouchedEvent(context)) # If an object has been copy & pasted, we need to reindex some fields. # The IObjectCopiedEvent is too early to do that though, because at # that point the object doesn't have a full AQ chain yet. We therefore # just mark it during IObjectCopiedEvent, and do the reindexing here. if getattr(context, '_v_object_has_been_copied', False): context.reindexObject(idxs=reindex_after_copy) if IObjectRemovedEvent.providedBy(event): return # Update object security after moving or copying. # Specifically, this is needed for the case where an object is moved out # of a location where a Placeful Workflow Policy applies to a location # where it doesn't. # # Plone then no longer provides the placeful workflow for that object, # but doesn't automatically update the object's security. # # We use ftw.upgrade's update_security_for() here to correctly # recalculate security, but do the reindexing ourselves because otherwise # Plone will do it recursively (unnecessarily so). changed = update_security_for(context, reindex_security=False) if changed: reindex_object_security_without_children(context) # There are several indices that need updating when a dossier is moved. # first make sure obj was actually moved and not created if not event.oldParent or not event.newParent: return # When an object is moved, its containing_dossier needs reindexing. to_reindex = ['containing_dossier'] # containing_subdossier is really only used for documents, # while is_subdossier is only meaningful for dossiers. if IDossierMarker.providedBy(context): was_subdossier = IDossierMarker.providedBy(event.oldParent) is_subdossier = IDossierMarker.providedBy(event.newParent) if was_subdossier != is_subdossier: to_reindex.append('is_subdossier') if context.portal_type in TYPES_WITH_CONTAINING_SUBDOSSIER_INDEX: to_reindex.append('containing_subdossier') context.reindexObject(idxs=to_reindex) # synchronize with model if necessary if ITask.providedBy(context): sync_task(context, event)
def reindex_containing_dossier_for_contained_objects(dossier, event): """Reindex the containging_dossier index for all the contained obects. """ for brain in dossier.portal_catalog( path='/'.join(dossier.getPhysicalPath())): obj = brain.getObject() obj.reindexObject(idxs=['containing_dossier']) if ITask.providedBy(obj): sync_task(brain.getObject(), event)
def reindex_containing_dossier(dossier, event): """Reindex the containging_dossier index for all the contained obects, when the title has changed.""" if not IDossierMarker.providedBy(aq_parent(aq_inner(dossier))): for descr in event.descriptions: for attr in descr.attributes: if attr == "IOpenGeverBase.title": for brain in dossier.portal_catalog(path="/".join(dossier.getPhysicalPath())): brain.getObject().reindexObject(idxs=["containing_dossier"]) if brain.portal_type in ["opengever.task.task", "opengever.inbox.forwarding"]: sync_task(brain.getObject(), event)
def object_moved_or_added(context, event): if isinstance(event, ObjectAddedEvent): # Don't consider moving or removing an object a "touch". Mass-moves # would immediately fill up the touched log, and removals should not # be tracked anyway. if should_track_touches(context): notify(ObjectTouchedEvent(context)) if IObjectRemovedEvent.providedBy(event): return # Update object security after moving or copying. # Specifically, this is needed for the case where an object is moved out # of a location where a Placeful Workflow Policy applies to a location # where it doesn't. # # Plone then no longer provides the placeful workflow for that object, # but doesn't automatically update the object's security. # # We use ftw.upgrade's update_security_for() here to correctly # recalculate security, but do the reindexing ourselves because otherwise # Plone will do it recursively (unnecessarily so). changed = update_security_for(context, reindex_security=False) if changed: reindex_object_security_without_children(context) # There are several indices that need updating when a dossier is moved. # first make sure obj was actually moved and not created if not event.oldParent or not event.newParent: return # When an object is moved, its containing_dossier needs reindexing. to_reindex = ['containing_dossier'] # containing_subdossier is really only used for documents, # while is_subdossier is only meaningful for dossiers. if IDossierMarker.providedBy(context): was_subdossier = IDossierMarker.providedBy(event.oldParent) is_subdossier = IDossierMarker.providedBy(event.newParent) if was_subdossier != is_subdossier: to_reindex.append('is_subdossier') if context.portal_type in TYPES_WITH_CONTAINING_SUBDOSSIER_INDEX: to_reindex.append('containing_subdossier') context.reindexObject(idxs=to_reindex) # synchronize with model if necessary if ITask.providedBy(context): sync_task(context, event)
def test_list_only_active_tasks(self, browser): create(Builder('forwarding') .having(issuer='inbox:client1') .titled('Active')) closed = create(Builder('forwarding') .having(issuer='inbox:client1') .in_state('forwarding-state-closed') .titled('Closed')) sync_task(closed, None) transaction.commit() browser.login().open(self.inbox, view='tabbedview_view-overview') self.assertSequenceEqual( browser.css('#issued_inbox_tasksBox li:not(.moreLink) span span').text, ['Active'])
def reindex_containing_dossier(dossier, event): """Reindex the containging_dossier index for all the contained obects, when the title has changed.""" if not IDossierMarker.providedBy(aq_parent(aq_inner(dossier))): for descr in event.descriptions: for attr in descr.attributes: if attr == 'IOpenGeverBase.title': for brain in dossier.portal_catalog( path='/'.join(dossier.getPhysicalPath())): brain.getObject().reindexObject( idxs=['containing_dossier']) if brain.portal_type in [ 'opengever.task.task', 'opengever.inbox.forwarding' ]: sync_task(brain.getObject(), event)
def reindex_containing_dossier(dossier, event): """Reindex the containging_dossier index for all the contained obects, when the title has changed. """ if ILocalrolesModifiedEvent.providedBy(event) or \ IContainerModifiedEvent.providedBy(event): return if not IDossierMarker.providedBy(aq_parent(aq_inner(dossier))): attrs = tuple( attr for descr in event.descriptions for attr in descr.attributes ) if 'IOpenGeverBase.title' in attrs: for brain in dossier.portal_catalog(path='/'.join(dossier.getPhysicalPath())): brain.getObject().reindexObject(idxs=['containing_dossier']) if brain.portal_type in ['opengever.task.task', 'opengever.inbox.forwarding']: sync_task(brain.getObject(), event)
def globalindex_reindex_task(self): """We need to reindex the task in globalindex. This was done already with an earlier event handler - but we have just changed the roles which are indexed too (allowed users). """ sync_task(self.task, self.event)
def set_modification_date(self, obj): super(TaskBuilder, self).set_modification_date(obj) sync_task(obj, None)
def change_workflow_state(self, obj): super(TaskBuilder, self).change_workflow_state(obj) sync_task(obj, None)
def handle_continue(self, action): data, errors = self.extractData() if not errors: oguid = ISuccessorTaskController(self.context).get_oguid() # set forwarding flag if self.context.task_type == 'forwarding_task_type': is_forwarding = True else: is_forwarding = False dm = getUtility(IWizardDataStorage) dmkey = 'accept:%s' % oguid dm.set(dmkey, u'is_forwarding', is_forwarding) dm.set(dmkey, u'is_only_assign', False) dm.update(dmkey, data) method = data.get('method') if method == 'participate': accept_task_with_response(self.context, data['text']) sync_task(self.context, None) IStatusMessage(self.request).addStatusMessage( _(u'The task has been accepted.'), 'info') return self.request.response.redirect( self.context.absolute_url()) elif method == 'forwarding_participate': """only store the forwarding in the inbox and create a successor forwrding""" admin_unit = self.context.get_responsible_admin_unit() # push session data to target unit dm.push_to_remote_client(dmkey, admin_unit.id()) url = '%s/@@accept_store_in_inbox?oguid=%s' % ( admin_unit.public_url, oguid) return self.request.RESPONSE.redirect(url) elif method == 'existing_dossier': admin_unit = self.context.get_responsible_admin_unit() # push session data to target unit dm.push_to_remote_client(dmkey, admin_unit.id()) url = '%s/@@accept_choose_dossier?oguid=%s' % ( admin_unit.public_url, oguid) return self.request.RESPONSE.redirect(url) elif method == 'new_dossier': admin_unit = self.context.get_responsible_admin_unit() oguid = ISuccessorTaskController(self.context).get_oguid() # push session data to target client dm.push_to_remote_client(dmkey, admin_unit.id()) url = '/'.join(( admin_unit.public_url, '@@accept_select_repositoryfolder?oguid=%s' % oguid)) return self.request.RESPONSE.redirect(url)