Beispiel #1
0
def scan_edit(request, scan_id, template='core/scan_edit.html'):
    requested_scan = _get_scan(request, scan_id)
    if requested_scan:
        form = ScanForm(request.user, request.POST or None,
            instance=requested_scan)

        if form.is_valid():
            form.save()
            messages.info(request, u'Your changes have been saved.')

        else:
            return render_to_response(template,
                {'scan_form': form},
                context_instance=RequestContext(request))
    else:
        messages.error(request, _no_scan_err_)

    return redirect('core_scan_list')
Beispiel #2
0
def scan_new(request, template='core/scan_new.html'):
    form = ScanForm(request.user, request.POST or None)
    if form.is_valid():
        f = form.save(commit=False)
        f.owner = request.user
        f.save()
        messages.info(request, u'Scan created.')
        return redirect('core_scan_list')

    else:
        return render_to_response(template,
            {'scan_form': form},
            context_instance=RequestContext(request))