예제 #1
0
def friends_timeline(request, render, num_per_page=50):
    if not request.user.is_authenticated():
        return render_404(request)
    
#    q = Status.objects.raw('SELECT * FROM status_status AS t1, user_relation AS t2 WHERE t1.user_id = t2.user2_id AND t2.user1_id = %s ORDER BY t1.date_time DESC LIMIT 50', [str(request.user.id)])
    q = Status.objects.raw('SELECT * FROM status_status AS t1, user_relation AS t2 WHERE t1.user_id = t2.user2_id AND t2.user1_id = %s ORDER BY t1.date_time DESC LIMIT '+str(num_per_page), [str(request.user.id)])
    context = {
        'page_info': None,
        'statuses': q
    }    
    return render(request, context)
예제 #2
0
파일: user.py 프로젝트: geyuntian/yuntien
def dispatch(request, render, user, widget, path=''):
    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]]
    
    if not widget in USER_WIDGETS:
        return render_404(request)

    w = copy.deepcopy(USER_WIDGETS[widget])
    app_config = APPS[w['app_id']]
    
    title = ''
    head = ''
    sidebar = ''
    
    view, args, kwargs = resolve(request.path, app_config['urls'])
    response = view(request, *args, **kwargs)
    if isinstance(response, HttpResponseRedirect):
        return response
    elif isinstance(response, HttpResponseDirectOutput):
        return response
    elif isinstance(response, HttpResponseRichOutput):
        w['content'] = response.content
        title = response.get_title()
        head = response.get_head()
        sidebar = response.get_sidebar()
    else:
        w['content'] = response.content
        
    context = {
        'title':title,
        'head':head,
        'sidebar':sidebar,
        'widget':w,
        'app':app_config,
        'user_obj':user_obj,
        'community_user': user_obj,
    }
    return render(request, context)
예제 #3
0
def dispatch(request, render, community, widget, path=''):
    c = Community.objects.get(key_name=community)
    w = c.widget_set.get(key_name=widget)
    
    if not w:
        return render_404(request)
    
    title = ''
    head = ''
    sidebar = ''
    
    view, args, kwargs = resolve(request.path, w.app_config['urls'])
    kwargs['community'] = community
    kwargs['widget'] = widget
    response = view(request, *args, **kwargs)
    if isinstance(response, HttpResponseRedirect):
        return response
    elif isinstance(response, HttpResponseDirectOutput):
        return response
    elif isinstance(response, HttpResponseRichOutput):
        w.content = response.content
        title = response.get_title()
        head = response.get_head()
        sidebar = response.get_sidebar()
    else:
        w.content = response.content
        
    context = {
        'title':title,
        'head':head,
        'sidebar':sidebar,
        'community':c,
        'area':w.area.key_name,
        'areas':c.area_set.all(),
        'widget':w
    }
    return render(request, context)