Add status filter to search
This commit is contained in:
parent
371353fbbe
commit
ca79e88c16
1 changed files with 13 additions and 2 deletions
|
|
@ -102,7 +102,10 @@ class GovPlanProposeUpdateView(GovernmentMixin, LoginRequiredMixin, UpdateView):
|
|||
|
||||
|
||||
def search(request):
|
||||
plans = GovernmentPlan.objects.search(request.GET.get("q", ""))
|
||||
q = request.GET.get("q", "")
|
||||
plans = GovernmentPlan.objects.filter(public=True)
|
||||
if q:
|
||||
plans = GovernmentPlan.objects.search(q, qs=plans)
|
||||
|
||||
if request.GET.get("government"):
|
||||
try:
|
||||
|
|
@ -110,7 +113,15 @@ def search(request):
|
|||
plans = plans.filter(government_id=gov_id)
|
||||
except ValueError:
|
||||
pass
|
||||
if request.GET.get("status"):
|
||||
try:
|
||||
status = request.GET["status"]
|
||||
plans = plans.filter(status=status)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if q:
|
||||
# limit when there's a search
|
||||
plans = plans[:20]
|
||||
return render(
|
||||
request, "froide_govplan/plugins/card_cols.html", {"object_list": plans}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue