Ejemplo n.º 1
0
def workflow(request):
    if request.method == 'POST':
        if 'method' in request.POST:
            this = int(request.POST['next'].replace('flw', ''))
            now = int(request.POST['now'].replace('flw', ''))
            if request.POST['method'] == 'add':
                try:
                    ticket_flow_edges.objects.get(now=now, next=this)
                except:
                    ticket_flow_edges(now_id=now, next_id=this).save(user=request.user)
                return HttpResponse('OK')

            elif request.POST['method'] == 'del':
                ticket_flow_edges.objects.filter(now=now, next=this).delete()
                return HttpResponse('OK')

    flows = ticket_flow.objects.all()
    edges = ticket_flow_edges.objects.all()
    nodes = {}

    offset_x = 30
    offset_y = 30

    min_x = 0
    min_y = 0
    max_x = 0
    max_y = 0

    g = graph.create()

    for flow in flows:
        g.add_node('flw%s' % flow.pk)

    for edge in edges:
        g.add_edge('flw%s' % edge.now_id, 'flw%s' % edge.next_id)
    g.solve()

    for id in g:
        # print '%s => %s,%s' % (id, g[id].x, g[id].y)
        nodes[id] = (g[id].x, g[id].y)
        min_x = min(min_x, g[id].x)
        min_y = min(min_y, g[id].y)
        max_x = max(max_x, g[id].x)
        max_y = max(max_y, g[id].y)

    if min_x < 0:
        min_x = min_x * (-1)
    if min_y < 0:
        min_y = min_y * (-1)

    for node in nodes:
        (x, y) = nodes[node]
        nodes[node] = (x + min_x + offset_x, y + min_y + offset_y)

    max_x = max_x + min_x + (offset_x * 2)
    max_y = max_y + min_y + (offset_y * 2)

    return render(request, 'tickets/workflow.html', {'layout': 'horizontal', 'flows': flows, 'edges': edges, 'nodes': nodes, 'width': max_x, 'height': max_y})
Ejemplo n.º 2
0
def workflow(request):
    if request.method == 'POST':
        if 'method' in request.POST:
            this = int(request.POST['next'].replace('flw', ''))
            now = int(request.POST['now'].replace('flw', ''))
            if request.POST['method'] == 'add':
                try:
                    ticket_flow_edges.objects.get(now=now, next=this)
                except Exception:
                    ticket_flow_edges(now_id=now, next_id=this).save(user=request.user)
                return HttpResponse('OK')

            elif request.POST['method'] == 'del':
                ticket_flow_edges.objects.filter(now=now, next=this).delete()
                return HttpResponse('OK')

    flows = ticket_flow.objects.all()
    edges = ticket_flow_edges.objects.all()
    nodes = {}

    offset_x = 30
    offset_y = 30

    min_x = 0
    min_y = 0
    max_x = 0
    max_y = 0

    g = graph.create()

    for flow in flows:
        g.add_node('flw%s' % flow.pk)

    for edge in edges:
        g.add_edge('flw%s' % edge.now_id, 'flw%s' % edge.next_id)
    g.solve()

    for id in g:
        # print '%s => %s,%s' % (id, g[id].x, g[id].y)
        nodes[id] = (g[id].x, g[id].y)
        min_x = min(min_x, g[id].x)
        min_y = min(min_y, g[id].y)
        max_x = max(max_x, g[id].x)
        max_y = max(max_y, g[id].y)

    if min_x < 0:
        min_x = min_x * (-1)
    if min_y < 0:
        min_y = min_y * (-1)

    for node in nodes:
        (x, y) = nodes[node]
        nodes[node] = (x + min_x + offset_x, y + min_y + offset_y)

    max_x = max_x + min_x + (offset_x * 2)
    max_y = max_y + min_y + (offset_y * 2)

    return render(request, 'tickets/workflow.html', {'layout': 'horizontal', 'flows': flows, 'edges': edges, 'nodes': nodes, 'width': max_x, 'height': max_y})
Ejemplo n.º 3
0
    def forwards(self, orm):
        user = User.objects.all()[0]

        init = ticket_flow(name=_('incoming'), type=1)
        init.save(user=user)
        last = ticket_flow(name=_('close'), type=2)
        last.save(user=user)

        ticket_flow_edges(now=init, next=last).save(user=user)

        mod_path, cls_name = settings.TICKET_CLASS.rsplit('.', 1)
        mod_path = mod_path.split('.').pop(0)
        get_model(mod_path, cls_name).objects.all().update(state=init)
Ejemplo n.º 4
0
    def forwards(self, orm):
        user = User.objects.all()[0]

        init = ticket_flow(name=_('incoming'), type=1)
        init.save(user=user)
        last = ticket_flow(name=_('close'), type=2)
        last.save(user=user)

        ticket_flow_edges(now=init, next=last).save(user=user)
        
        mod_path, cls_name = settings.TICKET_CLASS.rsplit('.', 1)
        mod_path = mod_path.split('.').pop(0)
        get_model(mod_path, cls_name).objects.all().update(state=init)