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

            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            new_prod.tags = t

            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Added Tracked File to a Product',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_objects', args=(pid,)))
    else:
        tform = ObjectSettingsForm()
        product_tab = Product_Tab(pid, title="Add Tracked Files to a Product", tab="settings")

        return render(request, 'dojo/new_object.html',
                      {'tform': tform,
                       'product_tab': product_tab,
                       'pid': prod.id})
Beispiel #2
0
def edit_object(request, pid, ttid):
    object = Objects.objects.get(pk=ttid)

    if request.method == 'POST':
        tform = ObjectSettingsForm(request.POST, instance=object)
        if tform.is_valid():
            tform.save()

            tags = request.POST.getlist('tags')
            t = ", ".join('"{0}"'.format(w) for w in tags)
            object.tags = t

            messages.add_message(
                request,
                messages.SUCCESS,
                'Tool Product Configuration Successfully Updated.',
                extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_objects', args=(pid, )))
    else:
        tform = ObjectSettingsForm(
            instance=object,
            initial={'tags': get_tag_list(Tag.objects.get_for_object(object))})

    tform.initial['tags'] = [tag.name for tag in object.tags]
    product_tab = Product_Tab(pid, title="Edit Tracked Files", tab="settings")
    return render(request, 'dojo/edit_object.html', {
        'tform': tform,
        'product_tab': product_tab
    })
Beispiel #3
0
def delete_object(request, pid, ttid):
    object = Objects_Product.objects.get(pk=ttid)
    product = get_object_or_404(Product, id=pid)
    if object.product != product:
        raise BadRequest(
            f'Product {pid} does not fit to product of Object {object.product.id}'
        )

    if request.method == 'POST':
        tform = ObjectSettingsForm(request.POST, instance=object)
        object.delete()
        messages.add_message(request,
                             messages.SUCCESS,
                             'Tracked Product Files Deleted.',
                             extra_tags='alert-success')
        return HttpResponseRedirect(reverse('view_objects', args=(pid, )))
    else:
        tform = DeleteObjectsSettingsForm(instance=object)

    product_tab = Product_Tab(pid,
                              title="Delete Product Tool Configuration",
                              tab="settings")
    return render(request, 'dojo/delete_object.html', {
        'tform': tform,
        'product_tab': product_tab
    })
Beispiel #4
0
def new_object(request, pid):
    prod = get_object_or_404(Product, id=pid)
    if request.method == 'POST':
        tform = ObjectSettingsForm(request.POST)
        if tform.is_valid():
            new_prod = tform.save(commit=False)
            new_prod.product = prod
            new_prod.save()

            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Added Tracked File to a Product',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_objects', args=(pid, )))
    else:
        tform = ObjectSettingsForm()
        product_tab = Product_Tab(pid,
                                  title="Add Tracked Files to a Product",
                                  tab="settings")

        return render(request, 'dojo/new_object.html', {
            'tform': tform,
            'product_tab': product_tab,
            'pid': prod.id
        })
Beispiel #5
0
def edit_object(request, pid, ttid):
    object = Objects.objects.get(pk=ttid)

    if request.method == 'POST':
        tform = ObjectSettingsForm(request.POST, instance=object)
        if tform.is_valid():
            tform.save()

            tags = request.POST.getlist('tags')
            t = ", ".join(tags)
            object.tags = t

            messages.add_message(request,
                                 messages.SUCCESS,
                                 'Tool Product Configuration Successfully Updated.',
                                 extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_objects', args=(pid,)))
    else:
        tform = ObjectSettingsForm(instance=object,
                                    initial={'tags': get_tag_list(Tag.objects.get_for_object(object))})

    tform.initial['tags'] = [tag.name for tag in object.tags]
    product_tab = Product_Tab(pid, title="Edit Tracked Files", tab="settings")
    return render(request,
                  'dojo/edit_object.html',
                  {
                      'tform': tform,
                      'product_tab': product_tab
                  })
def edit_object(request, pid, ttid):
    object = Objects_Product.objects.get(pk=ttid)

    if request.method == 'POST':
        tform = ObjectSettingsForm(request.POST, instance=object)
        if tform.is_valid():
            tform.save()

            messages.add_message(
                request,
                messages.SUCCESS,
                'Tool Product Configuration Successfully Updated.',
                extra_tags='alert-success')
            return HttpResponseRedirect(reverse('view_objects', args=(pid, )))
    else:
        tform = ObjectSettingsForm(instance=object)

    product_tab = Product_Tab(pid, title="Edit Tracked Files", tab="settings")
    return render(request, 'dojo/edit_object.html', {
        'tform': tform,
        'product_tab': product_tab
    })