|
@@ -0,0 +1,35 @@
|
|
|
+
|
|
|
+from .tickets import Ticket
|
|
|
+
|
|
|
+TICKET_TYPES = Ticket.TICKET_TYPES
|
|
|
+TICKET_STATUSES_NAMES = Ticket.TICKET_STATUSES_NAMES
|
|
|
+TICKET_TYPES_CHOICES = Ticket.TICKET_TYPES_CHOICES
|
|
|
+LIFE_CYCLE_DICT = Ticket.LIFE_CYCLE_DICT
|
|
|
+
|
|
|
+def gen_diagram(x):
|
|
|
+ (i, name, data) = x
|
|
|
+
|
|
|
+ output = 'strict digraph G {\n'
|
|
|
+
|
|
|
+ unique_status = list(set(item for sublist in data for item in sublist))
|
|
|
+
|
|
|
+ for k in unique_status:
|
|
|
+ v = name + '_' + TICKET_STATUSES_NAMES[k]
|
|
|
+ output += f' {k} [label="{v}"]\n'
|
|
|
+
|
|
|
+ output += ' \n'
|
|
|
+
|
|
|
+ for i, x in enumerate(data):
|
|
|
+ # output += f' subgraph cluster_{i} {{\n'
|
|
|
+ output += ' ' + ' -> '.join(list(map(str, x))) + ';\n'
|
|
|
+ # output += ' }\n'
|
|
|
+
|
|
|
+ output += '}\n'
|
|
|
+
|
|
|
+ return output
|
|
|
+
|
|
|
+
|
|
|
+# FIXME: Доделать модуль
|
|
|
+# Gen diagrams: python -m tickets.lib.core
|
|
|
+
|
|
|
+print(gen_diagram(TICKET_TYPES[1]))
|