예제 #1
0
파일: views.py 프로젝트: dbsGen/neupCMS
def update_article(request,articleid=0):
    typeid = request.POST.get('typeid', '')
    title = request.POST.get('title', '')
    u_text = request.POST.get('u_text', '')
    #assert False
    if articleid==0:
        a = Article(title=title,
            typeid=typeid,
            authorname=request.user.username)
        a.save()
        a_addon = AddonArticle(aid_id=a.aid,
            content=u_text,
            authorip=request.META['REMOTE_ADDR'])
        a_addon.save()
    else:
        a = get_object_or_404(Article, aid=articleid)
        if request.user.username==a.authorname or in_editor_group(request.user):
            a.title = title
            a.typeid = typeid
            a_addon = AddonArticle.objects.get(aid_id=articleid)
            a_addon.content = u_text
            c=a_addon.content
            a.save()
            a_addon.save()
            #assert False
        else:
            return show_article(request,articleid,no_perm=True)
    return show_article(request,a.aid,edited=True)
예제 #2
0
파일: views.py 프로젝트: frellica/neupCMS
def update_article(request,articleid=0):
    typeid = request.POST.get('typeid', '')
    title = request.POST.get('title', '')
    u_text = request.POST.get('u_text', '')
    if articleid==0:
        a = Article(title=title,
            typeid=typeid,
            authorname=request.user.username)
        a.save()
        a_addon = AddonArticle(aid=a.aid,
            content=u_text,
            authorip=request.META['REMOTE_ADDR'])
        a_addon.save()
        sort_img(a.aid)
        return render_to_response('edit-article.html', {'form': EditForm(),
            'page_title': u'添加新文章',
            'result_aid':a.aid,
            'aid':articleid},context_instance=RequestContext(request,processors=[custom_proc]))#articleid是0时,表示添加新文章
    else:
        a = get_object_or_404(Article, aid=articleid)
        if request.user.username==a.authorname or in_editor_group(request.user):
            a.title = title
            a.typeid = typeid
            #a.is_verified = None
            a_addon = AddonArticle.objects.get(aid=articleid)
            a_addon.content = u_text
            c=a_addon.content
            a.save()
            a_addon.save()
            sort_img(a.aid)
        else:
            return show_article(request,articleid,{'no_perm':True})
    return show_article(request,a.aid,{'has_edited':True})