示例#1
0
def article_edit(request,user_name,article_slug):
	if request.user.username != user_name:
		raise Http404
		
	try:
		art = Article.objects.get(slug = article_slug);
	except Article.DoesNotExist:
		raise Http404

	
	if request.method == 'POST':
		f = ArticleForm(instance=art, data=request.POST)
		
		if f.is_valid():			
			new_art = f.save(commit=False)
			new_art.author = request.user;
			new_art.time_posted = datetime.now()
			new_art.save()
			return HttpResponseRedirect(new_art.get_absolute_url())			
	else:		
		f = ArticleForm(instance=art)
	
	req_context = RequestContext(request,{
											'form':f,
											})
	link = get_new_button_link('new_article',{'user_name':user_name})
	return render_with_navlist(request,'edit_page_template.html',{'username':user_name,'new_button_link':link,},req_context)
示例#2
0
def article_new(request,user_name):
	if request.user.username != user_name:
		raise Http404
		
	if request.method == 'POST':
		f = ArticleForm(data = request.POST)
		if f.is_valid():
			obj = f.save(commit=False)
			obj.author = request.user;			
			obj.time_posted = datetime.now()
			obj.save()
			return HttpResponseRedirect(obj.get_absolute_url())		
	else:
		f = ArticleForm()
		
	req_context = RequestContext(request,{
											'form':f,
											})
	link = get_new_button_link('new_article',{'user_name':user_name})
	return render_with_navlist(request,'edit_page_template.html',{'username':user_name,'new_button_link':link,},req_context)
示例#3
0
def article_new(request, user_name):
    if request.user.username != user_name:
        raise Http404

    if request.method == "POST":
        f = ArticleForm(data=request.POST)
        if f.is_valid():
            obj = f.save(commit=False)
            obj.author = request.user
            obj.time_posted = datetime.now()
            obj.save()
            return HttpResponseRedirect(obj.get_absolute_url())
    else:
        f = ArticleForm()

    req_context = RequestContext(request, {"form": f})
    link = get_new_button_link("new_article", {"user_name": user_name})
    return render_with_navlist(
        request, "edit_page_template.html", {"username": user_name, "new_button_link": link}, req_context
    )
示例#4
0
def article_edit(request, user_name, article_slug):
    if request.user.username != user_name:
        raise Http404

    try:
        art = Article.objects.get(slug=article_slug)
    except Article.DoesNotExist:
        raise Http404

    if request.method == 'POST':
        f = ArticleForm(instance=art, data=request.POST)

        if f.is_valid():
            new_art = f.save(commit=False)
            new_art.author = request.user
            new_art.time_posted = datetime.now()
            new_art.save()
            return HttpResponseRedirect(new_art.get_absolute_url())
    else:
        f = ArticleForm(instance=art)

    req_context = RequestContext(request, {
        'form': f,
    })
    link = get_new_button_link('new_article', {'user_name': user_name})
    return render_with_navlist(request, 'edit_page_template.html', {
        'username': user_name,
        'new_button_link': link,
    }, req_context)
示例#5
0
def article_new(request, user_name):
    if request.user.username != user_name:
        raise Http404

    if request.method == 'POST':
        f = ArticleForm(data=request.POST)
        if f.is_valid():
            obj = f.save(commit=False)
            obj.author = request.user
            obj.time_posted = datetime.now()
            obj.save()
            return HttpResponseRedirect(obj.get_absolute_url())
    else:
        f = ArticleForm()

    req_context = RequestContext(request, {
        'form': f,
    })
    link = get_new_button_link('new_article', {'user_name': user_name})
    return render_with_navlist(request, 'edit_page_template.html', {
        'username': user_name,
        'new_button_link': link,
    }, req_context)