def latest_pins_for_user(self, user, category=None): user = getattr(user, "pk", user) followed_users = follow.get_user_following(user) unfollowed_boards = follow.get_user_unfollowed_boards(user) followed_boards = follow.get_user_followed_boards(user) query_params = ( Q(video_id="") & Q(is_active=True) & Q(board__is_active=True) & Q(board__category__is_active=True) ) query_params = query_params & ~Q(board__in=unfollowed_boards) board_params = Q(board__user__in=followed_users) | Q(board__in=followed_boards) qs = self.filter(query_params & board_params) qs = qs.select_related("board", "domain", "board__category", "source_pin", "board__user", "created_user") if category: qs = qs.filter(board__category=category) return qs
def latest_pins_for_user(self, user, category=None): user = getattr(user, 'pk', user) followed_users = follow.get_user_following(user) unfollowed_boards = follow.get_user_unfollowed_boards(user) followed_boards = follow.get_user_followed_boards(user) query_params = Q(video_id='') & Q(is_active=True) & Q( board__is_active=True) & Q(board__category__is_active=True) query_params = query_params & ~Q(board__in=unfollowed_boards) board_params = Q(board__user__in=followed_users) | Q( board__in=followed_boards) qs = self.filter(query_params & board_params) qs = qs.select_related('board', 'domain', 'board__category', 'source_pin', 'board__user', 'created_user') if category: qs = qs.filter(board__category=category) return qs
def following_users_list(request): user_list = User.objects.filter(pk__in=follow.get_user_following(request.user.pk)) profile = request.user.get_profile() return direct_to_template(request, 'profiles/follow/following_users.html', locals())
def number_of_following(user): return len(follow.get_user_following(user.pk))