コード例 #1
0
ファイル: views.py プロジェクト: frellica/neupCMS
def list_by_type(request,typeid):
    #大量文章下的表现有待优化。。现在的肯定不成
    page = request.GET.get('page','')
    t = get_object_or_404(Type, typeid=typeid)
    article_list=[{'aid':item.aid,'title':item.title,'senddate':item.senddate,'is_headline':item.is_headline} for item in Article.objects.filter(typeid=t.typeid).order_by('-aid')]
    p = Paginator(article_list,20)
    try:
        article_list = p.page(page)
    except PageNotAnInteger:
        # 如果页码不是整数,返回第一页.
        article_list = p.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        article_list = p.page(p.num_pages)
    return render_to_response('article-list-by-type.html', {'article_list':article_list,
        'type':{'typeid':t.typeid,'typename':t.typename},
        'newest':get_new_article(),
        'page_title':t.typename},context_instance=RequestContext(request,processors=[custom_proc]))
コード例 #2
0
ファイル: views.py プロジェクト: frellica/neupCMS
def show_article(request, articleid, status={}, verify_form=None):
    a = get_object_or_404(Article, aid=articleid)
    if a.is_verified or in_editor_group(request.user) or request.user.username==a.authorname:
        if not a.is_deleted or in_admin_group(request.user):
            a_addon = AddonArticle.objects.get(aid=articleid)
            type = Type.objects.get(typeid=a.typeid)
            content = a_addon.content
            try:
                author = Member.objects.get(username=a.authorname)
                nickname = author.nickname
            except:
                nickname = a.authorname
            return render_to_response('show-article.html', {'article':a,
                'nickname':nickname,
                'content':content,
                'type':type,
                'newest':get_new_article(),
                'status':status,
                'verify_form':verify_form,
                'page_title':a.title},context_instance=RequestContext(request,processors=[custom_proc]))