def dispatch(self, *args, **kwargs): messages.warning( self.request, _( 'This is a feature preview. Things might not work as expect.' ) ) AccessControlList.objects.check_access( permissions=permission_workflow_edit, user=self.request.user, obj=self.get_object().workflow ) Event.refresh() return super( SetupWorkflowTransitionTriggerEventListView, self ).dispatch(*args, **kwargs)
def handler_trigger_transition(sender, **kwargs): action = kwargs['instance'] Document = apps.get_model( app_label='documents', model_name='Document' ) WorkflowInstance = apps.get_model( app_label='document_states', model_name='WorkflowInstance' ) WorkflowTransition = apps.get_model( app_label='document_states', model_name='WorkflowTransition' ) trigger_transitions = WorkflowTransition.objects.filter(trigger_events__event_type__name=kwargs['instance'].verb) if isinstance(action.target, Document): workflow_instances = WorkflowInstance.objects.filter(workflow__transitions__in=trigger_transitions, document=action.target).distinct() elif isinstance(action.action_object, Document): workflow_instances = WorkflowInstance.objects.filter(workflow__transitions__in=trigger_transitions, document=action.action_object).distinct() else: workflow_instances = WorkflowInstance.objects.none() for workflow_instance in workflow_instances: # Select the first transition that is valid for this workflow state transition = list(set(trigger_transitions) & set(workflow_instance.get_transition_choices()))[0] workflow_instance.do_transition( comment=_('Event trigger: %s') % Event.get(name=action.verb).label, transition=transition )
def handler_trigger_transition(sender, **kwargs): action = kwargs['instance'] Document = apps.get_model(app_label='documents', model_name='Document') WorkflowInstance = apps.get_model(app_label='document_states', model_name='WorkflowInstance') WorkflowTransition = apps.get_model(app_label='document_states', model_name='WorkflowTransition') trigger_transitions = WorkflowTransition.objects.filter( trigger_events__event_type__name=kwargs['instance'].verb) if isinstance(action.target, Document): workflow_instances = WorkflowInstance.objects.filter( workflow__transitions__in=trigger_transitions, document=action.target).distinct() elif isinstance(action.action_object, Document): workflow_instances = WorkflowInstance.objects.filter( workflow__transitions__in=trigger_transitions, document=action.action_object).distinct() else: workflow_instances = WorkflowInstance.objects.none() for workflow_instance in workflow_instances: # Select the first transition that is valid for this workflow state transition = list( set(trigger_transitions) & set(workflow_instance.get_transition_choices()))[0] workflow_instance.do_transition(comment=_('Event trigger: %s') % Event.get(name=action.verb).label, transition=transition)
def get_initial(self): obj = self.get_object() initial = [] # Return the queryset by name from the sorted list of the class event_type_ids = [event_type.name for event_type in Event.all()] event_type_queryset = EventType.objects.filter(name__in=event_type_ids) for event_type in event_type_queryset: initial.append({ 'transition': obj, 'event_type': event_type, }) return initial
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_parsing_document_version_submit = Event( name='parsing_document_version_submit', label=_('Document version submitted for parsing')) event_parsing_document_version_finish = Event( name='parsing_document_version_finish', label=_('Document version parsing finished'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_document_comment_create = Event( name='document_comment_create', label=_('Document comment created') ) event_document_comment_delete = Event( name='document_comment_delete', label=_('Document comment deleted') )
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_document_auto_register_in = Event( name='checkouts_document_auto_register_in', label=_('Documento in entrata registrato automaticamente')) event_document_register_in = Event(name='checkouts_document_register_in', label=_('Document in entrata registrato')) event_document_register_out = Event(name='checkouts_document_register_out', label=_('Document in uscita registrato')) event_document_forceful_register_in = Event( name='checkouts_document_forceful_register_in', label=_('Document in entrata registrato forzatamente'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_document_create = Event(name='documents_document_create', label=_('Document created')) event_document_download = Event(name='documents_document_download', label=_('Document downloaded')) event_document_properties_edit = Event(name='documents_document_edit', label=_('Document properties edited')) event_document_type_change = Event(name='documents_document_type_change', label=_('Document type changed')) event_document_new_version = Event(name='documents_document_new_version', label=_('New version uploaded')) event_document_version_revert = Event(name='documents_document_version_revert', label=_('Document version reverted')) event_document_view = Event(name='documents_document_view', label=_('Document viewed'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_ocr_document_version_submit = Event( name='ocr_document_version_submit', label=_('Document version submitted for OCR')) event_ocr_document_version_finish = Event( name='ocr_document_version_finish', label=_('Document version OCR finished'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_document_check_out = Event(name='checkouts_document_check_out', label=_('Document checked out')) event_document_check_in = Event(name='checkouts_document_check_in', label=_('Document checked in')) event_document_auto_check_in = Event( name='checkouts_document_auto_check_in', label=_('Document automatically checked in')) event_document_forceful_check_in = Event( name='checkouts_document_forceful_check_in', label=_('Document forcefully checked in'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_document_create = Event(name='documents_document_create', label=_('Document created')) event_document_properties_edit = Event(name='documents_document_edit', label=_('Document properties edited')) event_document_type_change = Event(name='documents_document_type_change', label=_('Document type changed'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_cabinets_add_document = Event(name='cabinets_add_document', label=_('Document added to cabinet')) event_cabinets_remove_document = Event( name='cabinets_remove_document', label=_('Document removed from cabinet'))
from __future__ import absolute_import, unicode_literals from django.utils.translation import ugettext_lazy as _ from events.classes import Event event_tag_attach = Event(name='tag_attach', label=_('Tag attached to document')) event_tag_remove = Event(name='tag_remove', label=_('Tag removed from document'))