diff --git a/opentech/apply/funds/admin.py b/opentech/apply/funds/admin.py index 1c14147560931422f2032419e8a8d7dcb4b30cc6..b90fa2196dba232a8e70cafa667db5432759d73c 100644 --- a/opentech/apply/funds/admin.py +++ b/opentech/apply/funds/admin.py @@ -14,6 +14,7 @@ from .admin_helpers import ( FormsFundRoundListFilter, RoundStateListFilter, RoundFundChooserView, + RoundAdminURLHelper, ApplicationFormButtonHelper, ) from .admin_views import CopyApplicationFormViewClass @@ -34,6 +35,7 @@ class RoundAdmin(BaseRoundAdmin): menu_icon = 'repeat' list_display = ('title', 'fund', 'start_date', 'end_date', 'applications', 'review_forms') list_filter = (RoundStateListFilter,) + url_helper_class = RoundAdminURLHelper def applications(self, obj): diff --git a/opentech/apply/funds/admin_helpers.py b/opentech/apply/funds/admin_helpers.py index 8df313c633a441bf4e17a398117d5dc9a3595950..5687b6fb005999bfcf8f0bab6970cf0b82e1f75d 100644 --- a/opentech/apply/funds/admin_helpers.py +++ b/opentech/apply/funds/admin_helpers.py @@ -1,10 +1,13 @@ +from urllib.parse import urlencode + from django import forms from django.contrib import admin from django.urls import reverse +from django.utils.functional import cached_property from django.utils.translation import ugettext as _ from wagtail.contrib.modeladmin.forms import ParentChooserForm -from wagtail.contrib.modeladmin.helpers import PageButtonHelper, ButtonHelper +from wagtail.contrib.modeladmin.helpers import PageAdminURLHelper, PageButtonHelper, ButtonHelper from wagtail.contrib.modeladmin.views import ChooseParentView from wagtail.core.models import Page @@ -122,3 +125,11 @@ class ApplicationFormButtonHelper(ButtonHelper): buttons.append(copy_form_button) return buttons + + +class RoundAdminURLHelper(PageAdminURLHelper): + @cached_property + def index_url(self): + # By default set open filter for Round listing page's index URL + params = {'form-state': 'open'} + return f"{self.get_action_url('index')}?{urlencode(params)}"