diff --git a/opentech/apply/funds/models.py b/opentech/apply/funds/models.py index 2245632770fc915fd29ae90129a2580d30c9fc2d..c585cd9c74a7b1074b548e8cfb8340c464fd5750 100644 --- a/opentech/apply/funds/models.py +++ b/opentech/apply/funds/models.py @@ -143,7 +143,7 @@ class Round(AbstractStreamForm): Q(end_date__gte=self.start_date) ) - conflicting_rounds = Round.objects.sibling_of(self).filter( + conflicting_rounds = Round.objects.child_of(self.parent_page).filter( conflict_query ).exclude(id=self.id) diff --git a/opentech/apply/funds/wagtail_hooks.py b/opentech/apply/funds/wagtail_hooks.py index d9ad3c978b7ba35f8d762f27cde028290befa828..178e17a6694c669f0b8b181bcbc7801cbcf7c7d7 100644 --- a/opentech/apply/funds/wagtail_hooks.py +++ b/opentech/apply/funds/wagtail_hooks.py @@ -1,6 +1,15 @@ +from wagtail.wagtailcore import hooks from wagtail.contrib.modeladmin.options import modeladmin_register from .admin import ApplyAdminGroup +from .models import Round modeladmin_register(ApplyAdminGroup) + + +@hooks.register('before_create_page') +def before_create_page(request, parent_page, page_class): + if page_class == Round: + page_class.parent_page = parent_page + return page_class