Beispiel #1
0
def mirror_edit(request, repo_id, mirror_id):

    mirror = get_object_or_404(Mirror, id=mirror_id)

    if request.method == 'POST':
        edit_form = EditMirrorForm(request.POST, instance=mirror)
        if edit_form.is_valid():
            mirror = edit_form.save()
            mirror.save()
            messages.info(request, 'Saved changes to Mirror %s' % mirror)
        else:
            mirror = get_object_or_404(Mirror, id=mirror_id)
    else:
        edit_form = EditMirrorForm(instance=mirror)

    return render_to_response('repos/mirror_edit.html', {'mirror': mirror, 'edit_form': edit_form}, context_instance=RequestContext(request))
Beispiel #2
0
def mirror_edit(request, repo_id, mirror_id):

    mirror = get_object_or_404(Mirror, id=mirror_id)

    if request.method == "POST":
        edit_form = EditMirrorForm(request.POST, instance=mirror)
        if edit_form.is_valid():
            mirror = edit_form.save()
            mirror.save()
            messages.info(request, "Saved changes to Mirror %s" % mirror)
        else:
            mirror = get_object_or_404(Mirror, id=mirror_id)
    else:
        edit_form = EditMirrorForm(instance=mirror)

    return render_to_response(
        "repos/mirror_edit.html", {"mirror": mirror, "edit_form": edit_form}, context_instance=RequestContext(request)
    )
Beispiel #3
0
def mirror_edit(request, mirror_id):

    mirror = get_object_or_404(Mirror, id=mirror_id)

    if request.method == 'POST':
        if 'save' in request.POST:
            edit_form = EditMirrorForm(request.POST, instance=mirror)
            if edit_form.is_valid():
                mirror = edit_form.save()
                mirror.save()
                text = 'Saved changes to Mirror {0!s}'.format(mirror)
                messages.info(request, text)
                return HttpResponseRedirect(mirror.get_absolute_url())
            else:
                mirror = get_object_or_404(Mirror, id=mirror_id)
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(
                reverse('mirror_detail', args=[mirror_id]))
    else:
        edit_form = EditMirrorForm(instance=mirror)

    return render(
        request,
        'repos/mirror_edit.html',
        {
            'mirror': mirror,
            'edit_form': edit_form
        },
    )
Beispiel #4
0
def mirror_edit(request, mirror_id):

    mirror = get_object_or_404(Mirror, id=mirror_id)

    if request.method == 'POST':
        if 'save' in request.POST:
            edit_form = EditMirrorForm(request.POST, instance=mirror)
            if edit_form.is_valid():
                mirror = edit_form.save()
                mirror.save()
                text = 'Saved changes to Mirror {0!s}'.format(mirror)
                messages.info(request, text)
                return HttpResponseRedirect(mirror.get_absolute_url())
            else:
                mirror = get_object_or_404(Mirror, id=mirror_id)
        elif 'cancel' in request.POST:
            return HttpResponseRedirect(reverse('mirror_detail',
                                                args=[mirror_id]))
    else:
        edit_form = EditMirrorForm(instance=mirror)

    return render(request,
                  'repos/mirror_edit.html',
                  {'mirror': mirror, 'edit_form': edit_form}, )