Skip to content
Snippets Groups Projects
Commit 86038302 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Add a open/closed filter to the round admin page in wagtail admin.

parent f076b017
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ from opentech.apply.categories.admin import CategoryAdmin, MetaTermAdmin ...@@ -12,6 +12,7 @@ from opentech.apply.categories.admin import CategoryAdmin, MetaTermAdmin
from .admin_helpers import ( from .admin_helpers import (
ButtonsWithPreview, ButtonsWithPreview,
FormsFundRoundListFilter, FormsFundRoundListFilter,
RoundStateListFilter,
RoundFundChooserView, RoundFundChooserView,
ApplicationFormButtonHelper, ApplicationFormButtonHelper,
) )
...@@ -32,6 +33,7 @@ class RoundAdmin(BaseRoundAdmin): ...@@ -32,6 +33,7 @@ class RoundAdmin(BaseRoundAdmin):
model = Round model = Round
menu_icon = 'repeat' menu_icon = 'repeat'
list_display = ('title', 'fund', 'start_date', 'end_date', 'applications', 'review_forms') list_display = ('title', 'fund', 'start_date', 'end_date', 'applications', 'review_forms')
list_filter = (RoundStateListFilter,)
def applications(self, obj): def applications(self, obj):
......
...@@ -71,6 +71,25 @@ class FormsFundRoundListFilter(admin.SimpleListFilter): ...@@ -71,6 +71,25 @@ class FormsFundRoundListFilter(admin.SimpleListFilter):
return queryset return queryset
class RoundStateListFilter(admin.SimpleListFilter):
title = 'state'
parameter_name = 'form-state'
def lookups(self, request, model_admin):
return (
('open', _('Open')),
('closed', _('Closed')),
)
def queryset(self, request, queryset):
value = self.value()
if value == 'open':
return queryset.open()
elif value == 'closed':
return queryset.closed()
return queryset
class ApplicationFormButtonHelper(ButtonHelper): class ApplicationFormButtonHelper(ButtonHelper):
def prepare_classnames(self, start=None, add=None, exclude=None): def prepare_classnames(self, start=None, add=None, exclude=None):
"""Parse classname sets into final css classess list.""" """Parse classname sets into final css classess list."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment