Example #1
0
def rename(request):
    options = request.POST
    if 'workflow_id' in options:
        new_section = None
        if options['new_section']:
            sections = WorkflowSection.objects.order_by('-id')
            top_section_id = sections and sections[0].id or 0
            new_section = WorkflowSection(top_section_id + 1, options['new_section'])
            new_section.save()

        workflow = Workflow.objects.filter(id=options['workflow_id'])[0];
        workflow.label = options['new_name']
        workflow.workflow_section_id = new_section and new_section.id or options['section']
        workflow.save()
        return {'label' : workflow.label}
    elif 'item_id' in options:
        item = Item.objects.filter(id=options['item_id'])[0]
        item.label = options['new_name']
        item.save()
        return {'label' : item.label}
    elif 'category_id' in options:
        category = Category.objects.filter(id=options['category_id'])[0]
        category.label = options['new_name']
        category.save()
    return {'label' : category.label}
Example #2
0
def create(request):
    options = request.POST

    if 'new_item' in options:
        items = Item.objects.order_by('-id')
        top_item_id = items and items[0].id or 0
        category_id = Category.objects.filter(id=options['category'])[0].id
        new_item = Item(id=top_item_id + 1, label=options['new_item'], details=options['details'], assigned_to_id=None, validation_id=3, category_id=category_id)
        new_item.save()
        return render_to_response('workflow/one_item.html', {'item' : new_item})

    if 'new_category' in options:
        categories = Category.objects.order_by('-id')
        top_category_id = categories and categories[0].id or 0
        orders = Category.objects.order_by('-order')
        top_order = orders and orders[0].id or 0
        new_category = Category(top_category_id + 1, options['new_category'], top_order, options['workflow_id'])
        new_category.save()
        return render_to_response('workflow/one_category.html', {'category' : new_category})

    if options['new_section']:
        sections = WorkflowSection.objects.order_by('-id')
        top_section_id = sections and sections[0].id or 0
        new_section = WorkflowSection(top_section_id + 1, options['new_section'])
        new_section.save()
    else:
        new_section = WorkflowSection.objects.filter(label=options['section'])[0]

    workflows = Workflow.objects.order_by('-id')
    top_id = workflows and workflows[0].id or 0
    new_workflow = Workflow(id=top_id + 1, workflow_section=new_section, label=options['new_workflow'])
    new_workflow.save()
    return HttpResponseRedirect(reverse('index'))
Example #3
0
def copy_workflow(request):
    options = request.POST

    origin_workflow = Workflow.objects.filter(id=options['workflow_id'])[0];
    copy_workflow = copy(origin_workflow)
    copy_workflow.id = Workflow.objects.order_by('-id')[0].id + 1
    copy_workflow.label = options['label']

    new_section = None
    if options['new_section']:
        sections = WorkflowSection.objects.order_by('-id')
        top_section_id = sections and sections[0].id or 0
        new_section = WorkflowSection(top_section_id + 1, options['new_section'])
        new_section.save()

    copy_workflow.workflow_section_id = new_section and new_section.id or options['section']
    copy_workflow.save()

    _copy_categories(origin_workflow.id, copy_workflow, options)
    return HttpResponseRedirect(reverse('index'))