Skip to content

Commit

Permalink
Merge pull request #337 from splashcat-ink/group-discovery-fix
Browse files Browse the repository at this point in the history
 Filter random public groups to exclude those owned or joined by user
  • Loading branch information
catgirlinspace authored Nov 13, 2024
2 parents 601f6a8 + 1da2848 commit 2c7306d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion groups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ def groups_index(request):
# discovery of new groups and links to joined groups
user: User = request.user
member_groups = user.get_groups() if user.is_authenticated else None
random_public_groups = Group.objects.filter(privacy_level=Group.PrivacyLevels.PUBLIC).order_by('?')[:24]
if user.is_authenticated:
random_public_groups = Group.objects.filter(privacy_level = Group.PrivacyLevels.PUBLIC).exclude(owner=user).exclude(members=user).order_by('?')[:24]
else:
random_public_groups = Group.objects.filter(privacy_level=Group.PrivacyLevels.PUBLIC).order_by('?')[:24]
pending_invites = user.pending_group_invites.all() if user.is_authenticated else None
return render(request, 'groups/index.html', {
'member_groups': member_groups,
Expand Down

0 comments on commit 2c7306d

Please sign in to comment.