示例#1
0
文件: post.py 项目: geyuntian/yuntien
def _list(request, render, num_per_page=10, filters=[], community='', widget=''):
#    filters.append(lambda q: q.order('-update'))
    
    widget_config = None
    if community and widget:
        w = Community.objects.get(key_name=community).widget_set.get(key_name=widget)
        filters.append(lambda q: q.filter(community_widget=w))  
        
    filters.append(lambda q: q.order_by('-updated'))
    
    posts = build_query(Topic, filters)
    p = Paginator(posts, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    posts = page.object_list    
    
    community_obj = None
    if community:
        community_obj = Community.objects.get(key_name=community)
    widget_config = None
    if widget:
        widget_config = community_obj.widget_set.get(key_name=widget)    
    
    context = {
        'posts': posts,
        'page_info': page,
        'community': community,
        'community_obj': community_obj,
        'widget': widget,
        'widget_config': widget_config,
        'app_config': APPS.get('forum', None)        
    }
    return render(request, context)
示例#2
0
文件: tui.py 项目: geyuntian/yuntien
def _list(request, render, num_per_page=10, filters=[], c={}, community='', widget='', home=False):
    filters = filters #get_common_filters(request) + filters

    if community and widget:
        w = Community.objects.get(key_name=community).widget_set.get(key_name=widget)
        filters.append(lambda q: q.filter(community_widget=w))
        
        if home:
            num_per_page = w.num_on_homepage
        else:
            num_per_page = w.num_per_page
    
    posts = build_query(Topic, filters)    
    p = Paginator(posts, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    posts = page.object_list

    community_obj = None
    if community:
        community_obj = Community.objects.get(key_name=community)
    widget_config = None
    if widget:
        widget_config = community_obj.widget_set.get(key_name=widget)
            
    context = {
        'posts': posts,
        'page_info': page,
        'community': community,
        'community_obj': community_obj,
        'widget': widget,
        'widget_config': widget_config,
        'app_config': APPS.get('tui', None)
    }
    context.update(c)
    return render(request, context)
示例#3
0
def _all(request, render, filters=[], num_per_page=20):
    communities = build_query(Community, filters)    
    p = Paginator(communities, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    
    context = {
        'communities': page.object_list ,
        'page_info': page,
    }
    return render(request, context)
示例#4
0
def public_timeline(request, render, num_per_page=50):
    p = Paginator(Status.objects.all(), num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    statuses = page.object_list
    
    context = {
        'page_info': page,
        'statuses': statuses
    }
    return render(request, context)
示例#5
0
def user_timeline(request, render, user, num_per_page=50):
    user_obj = get_user_model().objects.get(username=user)
    user_obj.latest_communities = [ra.obj for ra in user_obj.main_ra_set.all()[:12]]
    
    p = Paginator(user_obj.status_set.all(), num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    statuses = page.object_list
    
    context = {
        'user_obj':user_obj,
        'community_user': user_obj,
        'page_info': page,
        'statuses': statuses,
        'status_form': StatusForm()
    }
    return render(request, context)
示例#6
0
文件: tui.py 项目: geyuntian/yuntien
def list_comments(request, render, num_per_page=10, filters=[], c={}):
    
    comments = build_query(Comment, filters)    
    p = Paginator(comments, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    comments = page.object_list  
    comments = [_fill_comment(comment, comment.level) for comment in comments]
    for comment in comments:
        comment.request = request
        comment.display_level = 1    
    
    context = {
        'comments': comments,
        'page_info': page,
    }
    context.update(c)
    return render(request, context)
示例#7
0
def list(request, community, widget, render, num_per_page=10):
    community_obj = Community.objects.get(key_name=community)
    widget_config = community_obj.widget_set.get(key_name=widget)
    
    filters = []
    filters.append(lambda q: q.filter(source_type=SOURCE_TYPE_COMMUNITY))    
    filters.append(lambda q: q.filter(source_widget_id=widget_config.id))    
    photos = build_query(Photo, filters)
    p = Paginator(photos, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    photos = page.object_list

    context = {'photos': photos, 
               'page_info': page,
               'community_obj': community_obj, 
               'widget_config': widget_config}
    return render(request, context)
示例#8
0
文件: user.py 项目: geyuntian/yuntien
def _list(request, render, num_per_page=10, filters=[], user='', widget='', c={}):
    filters = get_common_filters(request) + filters
    u = get_user_model().objects.get(username=user)

    w = u.user_widget_set.get(key_name=widget)
    filters.append(lambda q: q.filter(user_widget=w))
    
    posts = build_query(Topic, filters)    
    p = Paginator(posts, num_per_page)
    page = p.page(get_int_param(request, 'page', 1))
    posts = page.object_list
            
    context = {
        'posts': posts,
        'page_info': page,
        'user_obj': u,
        'widget': widget,
        'widget_config': w,
        'app_config': APPS.get('note', None),   
    }
    context.update(c)
    return render(request, context)
示例#9
0
文件: tui.py 项目: geyuntian/yuntien
def display_comment(request, id, render):
    comment = Comment.objects.get(id=id)
    comment.is_current = True
    comment.request = request
    comment = _fill_comment(comment)
    comment.display_level = 1
    
    comments = []
    pages = 0
    versions = []
    
    context = {
        'post':_fill_post(comment.topic),
        'community':comment.community,
        'current_comment':comment,
        'sort':_get_sort_parameter(request),
        'comments':[comment],
        'versions': versions,
        'pages':pages,
        'current_page':get_int_param(request, 'page', 0),
        'form':CommentForm()
    }
    return render(request, context)
示例#10
0
def next_url(request):
    page = get_int_param(request, 'page', 1)
    url, qs = _change_query_str(request, 'page', page+1)    
    return url
示例#11
0
def previous_url(request):
    page = get_int_param(request, 'page', 1)
    url, qs = _change_query_str(request, 'page', page-1)    
    return url