# -*- coding: utf-8 -*-

from __future__ import absolute_import
import docflow
from werkzeug.exceptions import Forbidden

__all__ = ['WorkflowStateException', 'WorkflowTransitionException',
    'WorkflowPermissionException', 'WorkflowState', 'WorkflowStateGroup',
    'DocumentWorkflow']


class WorkflowStateException(docflow.WorkflowStateException, Forbidden):
    pass


class WorkflowTransitionException(docflow.WorkflowTransitionException, Forbidden):
    pass


class WorkflowPermissionException(docflow.WorkflowPermissionException, Forbidden):
    pass


class WorkflowState(docflow.WorkflowState):
    __doc__ = docflow.WorkflowState.__doc__

    exception_state = WorkflowStateException
    exception_transition = WorkflowTransitionException
    exception_permission = WorkflowPermissionException


class WorkflowStateGroup(docflow.WorkflowStateGroup):
    __doc__ = docflow.WorkflowStateGroup.__doc__

    exception_state = WorkflowStateException
    exception_transition = WorkflowTransitionException
    exception_permission = WorkflowPermissionException


class DocumentWorkflow(docflow.DocumentWorkflow):
    __doc__ = docflow.DocumentWorkflow.__doc__

    exception_state = WorkflowStateException

@@ -57,16 +57,36 @@
 _import%0A
+from flask import g%0A
 import d
@@ -280,16 +280,41 @@
 up',%0A   
+ 'InteractiveTransition',
  'Docume
@@ -1117,141 +1117,1145 @@
 ass 
-DocumentWorkflow(docflow.DocumentWorkflow):%0A    __doc__ = docflow.DocumentWorkflow.__doc__%0A%0A    exception_state = WorkflowStateException
+InteractiveTransition(docflow.InteractiveTransition):%0A    __doc__ = docflow.InteractiveTransition.__doc__%0A%0A    def __init__(self, workflow):%0A        super(InteractiveTransition, self).__init__(workflow)%0A        if hasattr(self, 'formclass'):%0A            self.form = formclass(obj=self.document)%0A%0A    def validate(self):%0A        %22%22%22Validate self.form, assuming Flask-WTF Form%22%22%22%0A        return self.form.validate_on_submit()%0A%0A%0Aclass DocumentWorkflow(docflow.DocumentWorkflow):%0A    __doc__ = docflow.DocumentWorkflow.__doc__%0A%0A    exception_state = WorkflowStateException%0A%0A    def permissions(self):%0A        %22%22%22%0A        Permissions for this workflow. Plays nice with%0A        :meth:%60coaster.views.load_models%60 and%0A        :class:%60coaster.sqlalchemy.PermissionMixin%60 to determine the available%0A        permissions to the current user.%0A        %22%22%22%0A        perms = set(super(DocumentWorkflow, self).permissions())%0A        if hasattr(g, 'permissions'):%0A            perms.update(g.permissions)%0A        if hasattr(self.document, 'permissions') and hasattr(g, 'user'):%0A            perms = self.document.permisssions(g.user, perms)%0A        return perms
 %0A

Update for Docflow 0.3.2 and PermissionMixin