Ejemplo n.º 1
0
def submit(request):
    if request.method == 'POST':
        form = WebsiteForm(request.POST)
        if form.is_valid():
            website = form.save(commit=False)
            website.owner = request.user
            website.save()
            return HttpResponseRedirect('/submit/done/')
    else:
        form = WebsiteForm()
    
    return render_to_response('websites/website_form.html', RequestContext(request, {
        'page_title': 'Submit A Site',
        'editing': False,
        'form': form,
    }))
Ejemplo n.º 2
0
def update_website(request, slug):
    website = get_object_or_404(Website, slug=slug)
    
    if website.owner != request.user:
        raise Http404

    if request.method == 'POST':
        form = WebsiteForm(request.POST, instance=website)
        if form.is_valid():
            website = form.save()
            return HttpResponseRedirect(website.get_absolute_url())
    else:
        form = WebsiteForm(instance=website)

    return render_to_response('websites/website_form.html', RequestContext(request, {
        'page_title': 'Edit Your Site',
        'editing': True,
        'form': form,
        }))
Ejemplo n.º 3
0
def submit(request):
    if request.method == 'POST':
        form = WebsiteForm(request.POST)
        if form.is_valid():
            website = form.save(commit=False)
            website.owner = request.user
            website.save()
            return HttpResponseRedirect('/submit/done/')
    else:
        form = WebsiteForm()

    return render_to_response(
        'websites/website_form.html',
        RequestContext(request, {
            'page_title': 'Submit A Site',
            'editing': False,
            'form': form,
        }))
Ejemplo n.º 4
0
def update_website(request, slug):
    website = get_object_or_404(Website, slug=slug)

    if website.owner != request.user:
        raise Http404

    if request.method == 'POST':
        form = WebsiteForm(request.POST, instance=website)
        if form.is_valid():
            website = form.save()
            return HttpResponseRedirect(website.get_absolute_url())
    else:
        form = WebsiteForm(instance=website)

    return render_to_response(
        'websites/website_form.html',
        RequestContext(request, {
            'page_title': 'Edit Your Site',
            'editing': True,
            'form': form,
        }))