Exemplo n.º 1
0
def edit_dataset(request, id):
    dataset = get_object_or_404(Dataset, id=id)
    if dataset.user is not request.user:
        redirect("/datasets/%d" % id)

    if request.method == 'POST':
        form = DatasetForm(request.POST, instance=dataset)
        if form.is_valid():
            form.save()
    else:
        form = DatasetForm(instance=dataset)

    return render_to_response('datasets/add.html',{
        'form': form,
    }, RequestContext(request))
Exemplo n.º 2
0
def add_dataset(request):
    form = DatasetForm(request.POST or None, request.FILES or None)
    if form.is_valid():
        new_dataset = form.save(commit=False)
        profile = get_object_or_404(UserProfile, user=request.user)
        new_dataset.user = profile
        new_dataset.save()
        return redirect('/datasets/%d/view' % new_dataset.id)

    return render_to_response('datasets/add.html',{
        'form': form,
    }, RequestContext(request))