Пример #1
0
def profile_page(request, username='', ):
    if not username or username == request.user.username or username==request.user.id:
        user = request.user
        is_self = True
    else:
        try:
            user = Member.objects.get(id=username)
        except:
            user = get_object_or_404(Member,username=username)
    page = request.GET.get('page','')
    profile_dict={
        'id':user.id,
        'username':user.username,
        'nickname':user.nickname,
        'email':user.email,
    }
    verify_auth=in_editor_group(request.user)
    resume_auth=in_admin_group(request.user)
    article_list = [{'aid':a.aid, 'is_deleted':a.is_deleted,
        'is_verified':a.is_verified, 'is_headline':a.is_headline,
        'title':a.title, 'authorname':a.authorname,
        'typename':Type.objects.get(typeid=a.typeid).typename} 
        for a in Article.objects.filter(authorname=user.username) 
        if (not a.is_deleted or resume_auth) and 
        (a.is_verified or verify_auth or a.authorname==request.user.username)]
    article_list = pag(article_list,page,20)
    return render_to_response('member-profile.html',{'profile_dict':profile_dict,
        'article_list':article_list,
        'verify_auth':verify_auth,
        'resume_auth':resume_auth,
        'page_title':user.username},context_instance=RequestContext(request,processors=[custom_proc]))
Пример #2
0
def list_article(request, u='', list_method='all'):
    verify_auth=in_editor_group(request.user)
    if not verify_auth:
        return Http404()

    resume_auth=in_admin_group(request.user)
    list_all = False

    if not u or u == request.user.username or u==request.user.id:
        user = request.user
        is_self = True
        if not u:
            list_all = True
    else:
        try:
            user = Member.objects.get(id=u)
        except:
            user = get_object_or_404(Member,username=u)
            
    page = request.GET.get('page','')
    
    if list_all:
        articles = Article.objects.all()
    else:
        articles = Article.objects.filter(authorname=user.username)
    article_list = [{'aid':a.aid, 'is_deleted':a.is_deleted,
        'is_verified':a.is_verified, 'is_headline':a.is_headline,
        'title':a.title, 'authorname':a.authorname,
        'typename':Type.objects.get(typeid=a.typeid).typename} 
        for a in articles if check_article(a,list_method,verify_auth,resume_auth)]
    article_list = pag(article_list,page,20)
    list_method_dict = {list_method:1}
    return render_to_response('wheel/list-article.html',{'article_list':article_list,
        'resume_auth':resume_auth,
        'verify_auth':verify_auth,
        'user':user,
        'list_all':list_all,
        'method':list_method_dict,
        'page_title':u'article manage'},context_instance=RequestContext(request,processors=[custom_proc]))