示例#1
0
def os_detail(request, os_id):

    os = get_object_or_404(OS, id=os_id)

    if request.method == 'POST':
        create_form = CreateOSGroupForm(request.POST, prefix='create')
        if create_form.is_valid():
            osgroup = create_form.save()
            os.osgroup = osgroup
            os.save()
            messages.info(request, 'Created and linked to new OS Group')
            return HttpResponseRedirect(os.get_absolute_url())
        link_form = LinkOSGroupForm(request.POST, instance=os, prefix='link')
        if link_form.is_valid():
            link_form.save()
            messages.info(request, 'Link to OS Group successful')
            return HttpResponseRedirect(os.get_absolute_url())
    else:
        link_form = LinkOSGroupForm(instance=os, prefix='link')
        create_form = CreateOSGroupForm(prefix='create')

    return render(request,
                  'operatingsystems/os_detail.html',
                  {'os': os,
                   'link_form': link_form,
                   'create_form': create_form}, )
示例#2
0
文件: views.py 项目: VPAC/patchman
def os_detail(request, os_id):

    os = get_object_or_404(OS, id=os_id)

    if request.method == "POST":
        create_form = CreateOSGroupForm(request.POST, prefix="create")
        if create_form.is_valid():
            osgroup = create_form.save()
            os.osgroup = osgroup
            os.save()
            messages.info(request, "Created and linked to new OS Group")
            return HttpResponseRedirect(os.get_absolute_url())
        link_form = LinkOSGroupForm(request.POST, instance=os, prefix="link")
        if link_form.is_valid():
            link_form.save()
            messages.info(request, "Link to OS Group successful")
            return HttpResponseRedirect(os.get_absolute_url())
    else:
        link_form = LinkOSGroupForm(instance=os, prefix="link")
        create_form = CreateOSGroupForm(prefix="create")

    return render_to_response(
        "operatingsystems/os_detail.html",
        {"os": os, "link_form": link_form, "create_form": create_form},
        context_instance=RequestContext(request),
    )
示例#3
0
def os_detail(request, os_id):

    os = get_object_or_404(OS, id=os_id)

    if request.method == 'POST':
        create_form = CreateOSGroupForm(request.POST, prefix='create')
        if create_form.is_valid():
            osgroup = create_form.save()
            os.osgroup = osgroup
            os.save()
            text = 'Created OS Group {0!s} '.format(osgroup)
            text += 'and added OS {0!s} to it'.format(os)
            messages.info(request, text)
            return HttpResponseRedirect(os.get_absolute_url())
        add_form = AddOSToOSGroupForm(request.POST, instance=os, prefix='add')
        if add_form.is_valid():
            add_form.save()
            text = 'OS {0!s} added to OS Group {1!s}'.format(os, os.osgroup)
            messages.info(request, text)
            return HttpResponseRedirect(os.get_absolute_url())
    else:
        add_form = AddOSToOSGroupForm(instance=os, prefix='add')
        create_form = CreateOSGroupForm(prefix='create')

    return render(request,
                  'operatingsystems/os_detail.html',
                  {'os': os,
                   'add_form': add_form,
                   'create_form': create_form}, )
示例#4
0
def os_detail(request, os_id):

    os = get_object_or_404(OS, id=os_id)

    if request.method == 'POST':
        create_form = CreateOSGroupForm(request.POST, prefix='create')
        if create_form.is_valid():
            osgroup = create_form.save()
            os.osgroup = osgroup
            os.save()
            text = 'Created OS Group {0!s} '.format(osgroup)
            text += 'and added OS {0!s} to it'.format(os)
            messages.info(request, text)
            return HttpResponseRedirect(os.get_absolute_url())
        add_form = AddOSToOSGroupForm(request.POST, instance=os, prefix='add')
        if add_form.is_valid():
            add_form.save()
            text = 'OS {0!s} added to OS Group {1!s}'.format(os, os.osgroup)
            messages.info(request, text)
            return HttpResponseRedirect(os.get_absolute_url())
    else:
        add_form = AddOSToOSGroupForm(instance=os, prefix='add')
        create_form = CreateOSGroupForm(prefix='create')

    return render(
        request,
        'operatingsystems/os_detail.html',
        {
            'os': os,
            'add_form': add_form,
            'create_form': create_form
        },
    )