当前位置: 首页>>代码示例>>Python>>正文


Python User.profile_dislikes方法代码示例

本文整理汇总了Python中core.models.User.profile_dislikes方法的典型用法代码示例。如果您正苦于以下问题:Python User.profile_dislikes方法的具体用法?Python User.profile_dislikes怎么用?Python User.profile_dislikes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.models.User的用法示例。


在下文中一共展示了User.profile_dislikes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: profile

# 需要导入模块: from core.models import User [as 别名]
# 或者: from core.models.User import profile_dislikes [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_dislikes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。