diff --git a/judge/models/profile.py b/judge/models/profile.py index 14fc5f7..283373b 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -397,12 +397,13 @@ class Profile(models.Model): return self.get_user_css_class(self.cached_display_rank, self.cached_rating) def get_friends(self): # list of ids, including you - friend_obj = self.following_users.prefetch_related("users") - ret = [] - if friend_obj: - ret = [friend.id for friend in friend_obj[0].users.all()] - ret.append(self.id) - return ret + friend_obj = self.following_users.prefetch_related("users").first() + friend_ids = ( + [friend.id for friend in friend_obj.users.all()] if friend_obj else [] + ) + friend_ids.append(self.id) + + return friend_ids def can_edit_organization(self, org): if not self.user.is_authenticated: diff --git a/judge/views/submission.py b/judge/views/submission.py index d1bc3f3..7b7223c 100644 --- a/judge/views/submission.py +++ b/judge/views/submission.py @@ -587,7 +587,9 @@ class AllUserSubmissions(ConditionalUserTabMixin, UserMixin, GeneralSubmissions) return context -class AllFriendSubmissions(LoginRequiredMixin, GeneralSubmissions): +class AllFriendSubmissions( + LoginRequiredMixin, InfinitePaginationMixin, GeneralSubmissions +): def get_queryset(self): friends = self.request.profile.get_friends() return (