from goflow.workflow.models import Process, Application, Transition from goflow.runtime.models import ProcessInstance, WorkItem from django.db import models from django.contrib.auth.models import User from django.forms.models import modelform_factory from django.contrib.auth.decorators import permission_required from django.contrib.auth.decorators import login_required from django.conf import settings from goflow.workflow.logger import Log log = Log('goflow.apptools.views') from goflow.workflow.notification import send_mail @login_required def start_application(request, app_label=None, model_name=None, process_name=None, instance_label=None, template=None, template_def='goflow/start_application.html', form_class=None, redirect='home', submit_name='action',
#!/usr/local/bin/python # -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import Group, User from goflow.workflow.models import Process, Activity, Transition, UserProfile from goflow.workflow.notification import send_mail from datetime import timedelta, datetime from django.urls import resolve from django.core.mail import mail_admins from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import fields from goflow.workflow.logger import Log; log = Log('goflow.runtime.managers') from django.conf import settings from django.contrib.auth.decorators import login_required #流程实例管理 class ProcessInstanceManager(models.Manager): '''Custom model manager for ProcessInstance ''' def start(self, process_name, user, item, title=None, priority=0): ''' Returns a workitem given the name of a preexisting enabled Process instance, while passing in the id of the user, the contenttype object and the title. :type process_name: string :param process_name: a name of a process. e.g. 'leave' :type user: User :param user: an instance of django.contrib.auth.models.User, typically retrieved through a request object.
#!/usr/local/bin/python # -*- coding: utf-8 -*- from .models import Manager from goflow.workflow.logger import Log log = Log('leavedemo.leave.pushapplications') def route_to_secretary(workitem): user = workitem.instance.user mgr_secretary = Manager.objects.get(category='secretary', users=user) return mgr_secretary.user def route_to_supervisor(workitem): user = workitem.instance.user mgr_supervisor = Manager.objects.get(category='supervisor', users=user) log.debug('route_to_supervisor user %s supervisor %s', user, mgr_supervisor.user) return mgr_supervisor.user
#!/usr/local/bin/python # -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import Group, User from goflow.workflow.models import Process, Activity, Transition, UserProfile from goflow.workflow.notification import send_mail from datetime import timedelta, datetime from django.core.urlresolvers import resolve from django.core.mail import mail_admins from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from goflow.workflow.logger import Log log = Log('goflow.runtime.managers') from django.conf import settings from goflow.workflow.decorators import allow_tags class ProcessInstanceManager(models.Manager): '''Custom model manager for ProcessInstance ''' def start(self, process_name, user, item, title=None, priority=0): ''' Returns a workitem given the name of a preexisting enabled Process instance, while passing in the id of the user, the contenttype object and the title. :type process_name: string :param process_name: a name of a process. e.g. 'leave'
#!/usr/local/bin/python # -*- coding: utf-8 -*- from django.db import models from django.contrib.auth.models import Group, User from goflow.workflow.models import Process, Activity, Transition, UserProfile from goflow.workflow.notification import send_mail from datetime import timedelta, datetime from django.urls.base import resolve from django.core.mail import mail_admins from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import fields from django.contrib.auth import get_user_model from goflow.workflow.logger import Log; log = Log('goflow.runtime.managers') from django.conf import settings # from goflow.workflow.decorators import allow_tags from django.utils.safestring import mark_safe User = get_user_model() class ProcessInstanceManager(models.Manager): '''Custom model manager for ProcessInstance ''' def start(self, process_name, user, item, title=None, priority=0): ''' Returns a workitem given the name of a preexisting enabled Process instance, while passing in the id of the user, the contenttype
from goflow.workflow.models import Process, Application, Transition from goflow.runtime.models import ProcessInstance, WorkItem from django.db import models from django.contrib.auth.models import User from django.forms.models import modelform_factory from django.contrib.auth.decorators import permission_required from django.contrib.auth.decorators import login_required from models import DefaultAppModel, Icon, ImageButton from forms import DefaultAppForm from django.conf import settings from goflow.workflow.logger import Log; log = Log('goflow.apptools.views') from goflow.workflow.notification import send_mail @login_required def start_application(request, app_label=None, model_name=None, process_name=None, instance_label=None, template=None, template_def='goflow/start_application.html', form_class=None, redirect='home', submit_name='action', ok_value='OK', cancel_value='Cancel', extra_context={}): ''' generic handler for application that enters a workflow. parameters: app_label, model_name model linked to workflow instance (deprecated)