Skip to content
Snippets Groups Projects
Commit 01bd6dfd authored by Roang's avatar Roang
Browse files

Fix conference accessible_by_user

Using union prevents us from using filters in the get() method, so we
need to use a list of ids instead.
parent ff139374
No related branches found
No related tags found
No related merge requests found
...@@ -179,14 +179,12 @@ class ConferenceManager(models.Manager): ...@@ -179,14 +179,12 @@ class ConferenceManager(models.Manager):
return qs return qs
# limit on the public ones # limit on the public ones
qs = qs.filter(is_public=True) public_query = qs.filter(is_public=True).values('id')
# for logged-in members, add all non-public conferences in which the user has the staff flag set # for logged-in members, add all non-public conferences in which the user has the staff flag set
conf_ids = ConferenceMember.objects.filter(user=user, is_staff=True, conference__is_public=False).values_list('conference_id', flat=True) conf_staff_query = ConferenceMember.objects.filter(user=user, is_staff=True, conference__is_public=False).values('conference_id')
if len(conf_ids) > 0:
qs = qs.union(self.get_queryset().filter(id__in=conf_ids))
return qs return qs.filter(id__in=public_query.union(conf_staff_query))
def public_accessible(self): def public_accessible(self):
return self.get_queryset().filter(is_public=True) return self.get_queryset().filter(is_public=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment