コード例 #1
0
ファイル: views.py プロジェクト: sanshao27/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(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
ファイル: views.py プロジェクト: admin-pro/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()
            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
        },
    )