Display friend list for anonymous user

This commit is contained in:
cuom1999 2020-11-24 13:17:13 -06:00
parent ae9ef37e3a
commit aeed1814b3

View file

@ -283,14 +283,18 @@ class UserList(QueryStringSortMixin, DiggPaginatorMixin, TitleMixin, ListView):
default_desc = all_sorts default_desc = all_sorts
default_sort = '-performance_points' default_sort = '-performance_points'
def filter_friend_queryset(self, queryset):
friends = list(self.request.profile.get_friends())
ret = queryset.filter(user__username__in=friends)
return ret
def get_queryset(self): def get_queryset(self):
ret = Profile.objects.filter(is_unlisted=False).order_by(self.order, 'id').select_related('user') \ ret = Profile.objects.filter(is_unlisted=False).order_by(self.order, 'id').select_related('user') \
.only('display_rank', 'user__username', 'points', 'rating', 'performance_points', .only('display_rank', 'user__username', 'points', 'rating', 'performance_points',
'problem_count') 'problem_count')
if (self.request.GET.get('friend') == 'true'): if (self.request.GET.get('friend') == 'true') and self.request.profile:
friends = list(self.request.profile.get_friends()) ret = self.filter_friend_queryset(ret)
ret = ret.filter(user__username__in=friends)
return ret return ret
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):