12
12
from django .utils .module_loading import import_string
13
13
from django .utils .safestring import SafeString
14
14
from django .utils .translation import gettext_lazy as t
15
+ from django .views import View
15
16
from django .views .generic .edit import BaseCreateView
16
17
17
- from . import tasks , utils , views
18
+ from . import utils
18
19
from .conf import settings
19
20
from .utils import NoDashDiGraph
20
21
@@ -41,14 +42,14 @@ def __new__(mcs, name, bases, attrs):
41
42
if func in nodes :
42
43
node = getattr (klass , name )
43
44
node .name = name
44
- node .type = (
45
- tasks .HUMAN
46
- if isinstance (node , views .TaskViewMixin )
47
- else tasks .MACHINE
48
- )
45
+ node .type = getattr (node , "type" , "machine" )
49
46
node .workflow_cls = klass
50
47
except TypeError :
51
48
pass
49
+ if "override_view" in attrs and isinstance (klass .override_view , str ):
50
+ klass .override_view = import_string (klass .override_view )
51
+ if "detail_view" in attrs and isinstance (klass .detail_view , str ):
52
+ klass .detail_view = import_string (klass .detail_view )
52
53
return klass
53
54
54
55
@@ -94,8 +95,8 @@ def save(self, **kwargs):
94
95
including start end end not of an edge.
95
96
"""
96
97
97
- override_view = views .OverrideView
98
- detail_view = views .WorkflowDetailView
98
+ override_view = "joeflow. views.OverrideView"
99
+ detail_view = "joeflow. views.WorkflowDetailView"
99
100
100
101
@classmethod
101
102
def _wrap_view_instance (cls , name , view_instance ):
@@ -133,7 +134,7 @@ def urls(cls):
133
134
"""
134
135
urls = []
135
136
for name , node in cls .get_nodes ():
136
- if isinstance (node , views . TaskViewMixin ):
137
+ if isinstance (node , View ):
137
138
if isinstance (node , BaseCreateView ):
138
139
route = "{name}/" .format (name = name )
139
140
else :
@@ -205,7 +206,7 @@ def get_graph(cls, color="black"):
205
206
)
206
207
for name , node in cls .get_nodes ():
207
208
node_style = "filled"
208
- if node .type == tasks . HUMAN :
209
+ if node .type == "human" :
209
210
node_style += ", rounded"
210
211
graph .node (name , style = node_style , color = color , fontcolor = color )
211
212
@@ -251,7 +252,7 @@ def get_instance_graph(self):
251
252
style = "filled"
252
253
peripheries = "1"
253
254
254
- if task .type == tasks . HUMAN :
255
+ if task .type == "human" :
255
256
style += ", rounded"
256
257
if not task .completed :
257
258
style += ", bold"
@@ -284,7 +285,7 @@ def get_instance_graph(self):
284
285
for task in self .task_set .exclude (name__in = names ).exclude (name = "override" ):
285
286
style = "filled, dashed"
286
287
peripheries = "1"
287
- if task .type == tasks . HUMAN :
288
+ if task .type == "human" :
288
289
style += ", rounded"
289
290
if not task .completed :
290
291
style += ", bold"
0 commit comments