Exemple #1
0
def origins_edit(request, origin=None, template="cache/origins_edit.html"):

    if request.method == "POST":
        instance = TileOrigin.objects.get(name=origin)
        origin_form = TileOriginForm(request.POST,instance=instance)
        if origin_form.is_valid():
            origin_form.save()
            reloadTileOrigins(proxy=False)
            reloadTileOrigins(proxy=True)
            ###
            context_dict = {
                'origin': instance,
                'origin_form': TileOriginForm(instance=instance)
            }

            return HttpResponseRedirect(reverse('origins_list',args=()))

    else:
        instance = TileOrigin.objects.get(name=origin)
        context_dict = {
            'origin': instance,
            'origin_form': TileOriginForm(instance=instance)
        }
        return render_to_response(
            template,
            RequestContext(request, context_dict))
Exemple #2
0
def origins_new(request, template="cache/origins_edit.html"):

    if request.method == "POST":
        origin_form = TileOriginForm(request.POST)
        if origin_form.is_valid():
            origin_form.save()
            reloadTileOrigins(proxy=False)
            reloadTileOrigins(proxy=True)
            ###
            context_dict = {
                'origin_form': TileOriginForm()
            }

        return HttpResponseRedirect(reverse('origins_list',args=()))
    else:
        context_dict = {
            'origin_form': TileOriginForm()
        }
        return render_to_response(
            template,
            RequestContext(request, context_dict))