Skip to content

Commit b4c4deb

Browse files
committed
make status filter default to all if no deals
1 parent 268850e commit b4c4deb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

deals/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ def get_filter_form(self):
7878
# Copy GET params and set defaults for missing fields
7979
data = self.request.GET.copy()
8080
if 'status_filter' not in data:
81-
data['status_filter'] = 'active'
81+
# Default to 'all' if there are no active deals, otherwise 'active'
82+
has_active_deals = Deal.objects.filter(expires__gt=timezone.now()).exists()
83+
data['status_filter'] = 'active' if has_active_deals else 'all'
8284
if 'sort' not in data:
8385
data['sort'] = 'newest'
8486

0 commit comments

Comments
 (0)