Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
variable-ize date in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
camsom committed Jan 12, 2016
1 parent f7ba2e1 commit 8967ca2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bulbs/special_coverage/filters.py
Expand Up @@ -12,9 +12,14 @@ def filter_queryset(self, request, queryset, view):
queryset = super(SpecialCoverageFilter, self).filter_queryset(request, queryset, view)
query_params = get_query_params(request)
if "active" in query_params:
today_filter = today()
value = query_params.get("active").lower()
if value == "true":
queryset = queryset.filter(start_date__lte=today(), end_date__gte=today())
queryset = queryset.filter(
start_date__lte=today_filter, end_date__gte=today_filter
)
elif value == "false":
queryset == queryset.exclude(start_date__lte=today(), end_date__gte=today())
queryset == queryset.exclude(
start_date__lte=today_filter, end_date__gte=today_filter
)
return queryset

1 comment on commit 8967ca2

@mparent61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay

Please sign in to comment.