Beispiel #1
0
def new_tool_product(request, pid):
    prod = get_object_or_404(Product, id=pid)
    if request.method == 'POST':
        tform = ToolProductSettingsForm(request.POST)
        if tform.is_valid():
            # form.tool_type = tool_type
            new_prod = tform.save(commit=False)
            new_prod.product = prod
            new_prod.save()

            messages.add_message(
                request,
                messages.SUCCESS,
                'Product Tool Configuration Successfully Created.',
                extra_tags='alert-success')
            return HttpResponseRedirect(
                reverse('all_tool_product', args=(pid, )))
    else:
        tform = ToolProductSettingsForm()
    product_tab = Product_Tab(pid, title="Tool Configurations", tab="settings")
    return render(request, 'dojo/new_tool_product.html', {
        'tform': tform,
        'product_tab': product_tab,
        'pid': pid
    })
Beispiel #2
0
def delete_tool_product(request, pid, ttid):
    tool_product = Tool_Product_Settings.objects.get(pk=ttid)
    product = get_object_or_404(Product, id=pid)
    if tool_product.product != product:
        raise BadRequest(
            f'Product {pid} does not fit to product of Tool_Product {tool_product.product.id}'
        )

    if request.method == 'POST':
        tform = DeleteToolProductSettingsForm(request.POST,
                                              instance=tool_product)
        tool_product.delete()
        messages.add_message(request,
                             messages.SUCCESS,
                             'Tool Product Successfully Deleted.',
                             extra_tags='alert-success')
        return HttpResponseRedirect(reverse('all_tool_product', args=(pid, )))
    else:
        tform = ToolProductSettingsForm(instance=tool_product)

    product_tab = Product_Tab(pid,
                              title="Delete Product Tool Configuration",
                              tab="settings")

    return render(request, 'dojo/delete_tool_product.html', {
        'tform': tform,
        'product_tab': product_tab
    })
def edit_tool_product(request, pid, ttid):
    prod = get_object_or_404(Product, id=pid)
    tool_product = Tool_Product_Settings.objects.get(pk=ttid)

    if request.method == 'POST':
        tform = ToolProductSettingsForm(request.POST, instance=tool_product)
        if tform.is_valid():
            tform.save()
            messages.add_message(
                request,
                messages.SUCCESS,
                'Tool Product Configuration Successfully Updated.',
                extra_tags='alert-success')
            return HttpResponseRedirect(
                reverse('all_tool_product', args=(pid, )))
    else:
        tform = ToolProductSettingsForm(instance=tool_product)

    product_tab = Product_Tab(pid,
                              title="Edit Product Tool Configuration",
                              tab="settings")
    return render(request, 'dojo/edit_tool_product.html', {
        'tform': tform,
        'product_tab': product_tab
    })
def new_tool_product(request, pid):
    prod = get_object_or_404(Product, id=pid)
    if request.method == 'POST':
        tform = ToolProductSettingsForm(request.POST)
        if tform.is_valid():
            # form.tool_type = tool_type
            new_prod = tform.save(commit=False)
            new_prod.product = prod
            new_prod.save()

            messages.add_message(
                request,
                messages.SUCCESS,
                'Product Tool Configuration Successfully Created.',
                extra_tags='alert-success')
            return HttpResponseRedirect(
                reverse('all_tool_product', args=(pid, )))
    else:
        tform = ToolProductSettingsForm()
    product_tab = Product_Tab(pid, title="Tool Configurations", tab="settings")
    return render(request, 'dojo/new_tool_product.html', {
        'tform': tform,
        'product_tab': product_tab,
        'pid': pid
    })
Beispiel #5
0
def edit_tool_product(request, pid, ttid):
    prod = get_object_or_404(Product, id=pid)
    tool_product = Tool_Product_Settings.objects.get(pk=ttid)

    if request.method == 'POST':
        tform = ToolProductSettingsForm(request.POST, instance=tool_product)
        if tform.is_valid():
            tform.save()
            messages.add_message(
                request,
                messages.SUCCESS,
                'Tool Product Configuration Successfully Updated.',
                extra_tags='alert-success')
            return HttpResponseRedirect(reverse('all_tool_product', args=(pid, )))
    else:
        tform = ToolProductSettingsForm(instance=tool_product)

    product_tab = Product_Tab(pid, title="Edit Product Tool Configuration", tab="settings")
    return render(request, 'dojo/edit_tool_product.html', {
        'tform': tform,
        'product_tab': product_tab
    })