Commit 51959c7d authored by cermak's avatar cermak
Browse files

[Fix] Calling QuerySet.filter() after union() is not supported.

parent fcb49688
......@@ -131,16 +131,19 @@ class ProposalsDetailView(LoginRequiredMixin, DetailView):
def get_queryset(self):
# check permission
qs = super(ProposalsDetailView, self).get_queryset()
myqs = qs.filter(Q(proposer=self.request.user) |
Q(coproposers__uid__exact=self.request.user) |
Q(local_contacts__uid__exact=self.request.user))
if self.request.user.has_perm('app.view_proposals'):
pass # view all
elif self.request.user.has_perm('app.view_panel_proposals') or self.request.user.has_perm('app.view_board_proposals'):
qs = qs.exclude(last_status__in='P').exclude(proposaltype='T')
qs = qs.union(myqs)
qs = qs.filter(Q(proposer=self.request.user) |
Q(coproposers__uid__exact=self.request.user) |
Q(local_contacts__uid__exact=self.request.user) |
~Q(last_status__in='P') |
~Q(proposaltype='T')
)
else: # can view only if it is part of the team
qs = myqs
qs = qs.filter(Q(proposer=self.request.user) |
Q(coproposers__uid__exact=self.request.user) |
Q(local_contacts__uid__exact=self.request.user))
return qs.distinct()
def get_context_data(self, *args, **kwargs):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment