本文整理汇总了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))