Exemple #1
0
def hardware_install(request, object_id):
    object = get_object_or_404(models.hardware, pk=object_id)
    error_list = [ ]
    pks = []

    if request.method == 'POST':
        pks = request.POST.getlist('pk')
        for pk in pks:
            requested_object = get_object_or_404(models.hardware, pk=pk)
            if requested_object.installed_on is not None:
                if requested_object.installed_on.pk != object.pk:
                    error_list.append(u"Cannot install '%s' as it is already installed on another computer"%(requested_object))
            else:
                requested_object.installed_on = object
                requested_object.save()

    web = webs.hardware_web()
    filter = filters.hardware(request.GET or {'is_installed': '3'})
    table = tables.hardware_list_form(pks, request, web, filter.qs, order_by=request.GET.get('sort'))
    return web.object_list(request, filter.form, table, template="lintory/hardware_list_form.html",
            context={ 'object': object, 'error_list': error_list })
Exemple #2
0
def hardware_list(request):
    web = webs.hardware_web()
    filter = filters.hardware(request.GET or None)
    table = tables.hardware(request, web, filter.qs, order_by=request.GET.get('sort'))
    return web.object_list(request, filter.form, table)