コード例 #1
0
def articles_list(request, slug, id):
   # category = Category.objects.filter(id=id, status=True).first()
   # appitem = category.appitem_set.first()
    appitem = get_appitem(slug)
    code = request.GET.get("code", '')
   # openid = get_user_openid(appitem.appid, appitem.app_secret, code)
    openid = appitem.get_user_openid(request)
    category = appitem.categories.get(id=id)        
    if openid and code:
        user = AppUser.objects.get(openid=openid)
        if not category.status: #不显示的分类
            if appitem.app_groups.filter(app_users=user, status=True).exists():
                articles = category.articles.all()
            else:
                return render_to_response('nanjing/notavailable.html', {},
                    context_instance=RequestContext(request))
        else:
            articles = category.articles.all()
    elif not code:
        articles = category.articles.all()
    else:
        articles = []
            
    page = int(request.GET.get("p",1))
   # return_articles = get_entry_page(articles,10,page)
    matchs, show_pages = page_turning(articles, request, 4)
    context = { 
        'appitem': appitem,
        'articles': articles,
        'matchs': matchs,
    }   
    return render_to_response('nanjing/articles_list.html', context,
        context_instance=RequestContext(request))
コード例 #2
0
def activity_list(request, slug):
    appitem = get_appitem(slug)
    activities = appitem.activity_set.filter(status=True)
    matchs, show_pages = page_turning(activities, request, 1)
    context = {'appitem': appitem, 'activities': activities, 'matchs': matchs}
    
    return render_to_response('nanjing/activity_list.html', context,
        context_instance=RequestContext(request))