Esempio n. 1
0
def add_show(request):
    """添加Show"""
    from show.forms import ShowForm 
    form = ShowForm(request.POST or None, request.FILES or None)
    #print form
    if form.is_valid():
        photo = form.save(commit=False)
        photo.user = request.user
        photo.save()
        photo.tags = request.POST.get("tags", None)
        #print photo
        return HttpResponseRedirect(reverse("show", args=[photo.pk]))
    return render_to_response("show/add-show.xhtml", locals(), context_instance=RequestContext(request))
Esempio n. 2
0
def edit_show(request, show_pk):
    """编辑Show"""
    from show.forms import ShowForm 
    photo = get_object_or_404(Show, pk=show_pk)
    if photo.user != request.user:
        return HttpResponseForbidden("Not Allow")
    form = ShowForm(request.POST or None, request.FILES or None, instance=photo)
    if form.is_valid():
        photo = form.save(commit=False)
        photo.user = request.user
        photo.save()
        photo.tags = request.POST.get("tags", None)
        return HttpResponseRedirect(reverse("show", args=[photo.pk]))
    return render_to_response("show/edit_show.html", locals(), context_instance=RequestContext(request))