コード例 #1
0
ファイル: feed.py プロジェクト: zouf/AllSortz
def get_user_recent_activity(user):
 
    ratings = Rating.objects.filter(user=user).order_by('-date')[:5]
   
    feed = []
    
    for r in ratings:
        r.type = "business"
        r.business = get_single_bus_data(r.business, user, isSideBar=True)
        r.user.photo = get_user_profile_pic(r.user)
        feed.append(r)
    allcomments = Comment.objects.filter(user=user).order_by('-date')
    for c in allcomments:
        try: 
            tc = TagComment.objects.get(thread=c)
            tc.type = "tagcomment"
            tc.business = get_single_bus_data(tc.business, user, isSideBar=True)
            tc.user.photo = get_user_profile_pic(c.user)

            feed.append(tc)
        except:
            pass
        
        try:
            bc = BusinessComment.objects.get(thread=c)
            bc.business = get_single_bus_data(bc.business, user, isSideBar=True)
            bc.type = "buscomment"
            bc.user.photo = get_user_profile_pic(c.user)
            feed.append(bc) 
        except:
            pass
    return feed
コード例 #2
0
ファイル: feed.py プロジェクト: zouf/AllSortz
def get_bus_recent_activity(b):
    ratings = Rating.objects.filter(business=b).order_by('-date')[:5]
   
    feed = []
    
    for r in ratings:
        r.type = "business"
        r.user.photo = get_user_profile_pic(r.user)
        feed.append(r)
    allbuscomments = BusinessComment.objects.filter(business=b).order_by('-date')
    for c in allbuscomments:  
        bc = c
        bc.type = "buscomment"
        bc.thread.user.photo = get_user_profile_pic(c.thread.user)

        feed.append(bc)
    return feed
コード例 #3
0
ファイル: views.py プロジェクト: zouf/AllSortz
def user_details(request,uid):
    if not request.user.is_authenticated():
        return redirect('/')
  
    context = get_default_blank_context(request.user)
    checkon = User.objects.get(id=uid)
        
    communities = []
    for um in UserMembership.objects.filter(user=request.user):
        communities.append(um.community)

    context.update({
        'user_communities':communities,
        'user_favorites' : get_user_favorites(request.user),
        'user_traits' : get_user_traits(request.user),
        'checkon' : checkon,
        'feed' : get_user_recent_activity( checkon),
        'p' : get_user_profile_pic(checkon)
        })
    return render_to_response('ratings/user/user_detail.html', context_instance=RequestContext(request,context))