當前位置: 首頁>>代碼示例>>Python>>正文


Python User.profile_likes方法代碼示例

本文整理匯總了Python中core.models.User.profile_likes方法的典型用法代碼示例。如果您正苦於以下問題:Python User.profile_likes方法的具體用法?Python User.profile_likes怎麽用?Python User.profile_likes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在core.models.User的用法示例。


在下文中一共展示了User.profile_likes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: profile

# 需要導入模塊: from core.models import User [as 別名]
# 或者: from core.models.User import profile_likes [as 別名]
def profile(request, browsing_data="def"):
    #browsing_data will represent the type of data the user want to see " likes, dislikes ,or comments"

    user = None
    if request.user.is_authenticated():
      user = request.user
    else:
      return HttpResponseRedirect(reverse('index'))

    ids = []
    liked_articles = []
    disliked_articles = []
    commented_articles = []

    obj_contributions = Feedback.objects.filter(user = user,parent_id = None)

    contributions = obj_contributions.count

    voted_articles = ArticleRating.objects.filter(user = user)

    if browsing_data == "likes" or browsing_data == "def":
        liked_articles = User.profile_likes(user.username)

    elif browsing_data == "dislikes":
        disliked_articles = User.profile_dislikes(user.username)

    elif browsing_data == "comments":
        commented_ids = Feedback.objects.filter(user = user,parent_id = None).values('articledetails').distinct()
        for id in commented_ids:
            if id['articledetails'] != None:
                temp = ArticleDetails.objects.get(id = id['articledetails'])
                feedbacks = Feedback.objects.filter(articledetails_id = id['articledetails'], parent_id = None, user = user)
                commented_articles.append({'topic':temp.header.topic,'name':temp.header.name,'slug':temp.slug,'feedbacks':feedbacks})
                

    return render_to_response('profile.html', {'voted_articles': voted_articles, 'contributions': contributions, 'profile':True,'browsing_data':browsing_data,'commented_articles':commented_articles,'disliked_articles':disliked_articles,'liked_articles':liked_articles,'settings': settings,'user':user} ,RequestContext(request))
開發者ID:amedhat3,項目名稱:sharek,代碼行數:38,代碼來源:views.py


注:本文中的core.models.User.profile_likes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。