diff --git a/opentech/apply/funds/models/applications.py b/opentech/apply/funds/models/applications.py index 0d7e1b53136b0b1bbb00fd55ab0abadc09d4a443..62a6e13faa09dec1ff67c4a45150d162d12ea2f1 100644 --- a/opentech/apply/funds/models/applications.py +++ b/opentech/apply/funds/models/applications.py @@ -52,6 +52,11 @@ class ApplicationBase(EmailForm, WorkflowStreamForm): # type: ignore parent_page_types = ['apply_home.ApplyHomePage'] + def get_template(self, request, *args, **kwargs): + # We want to force children to use our base template + # template attribute is ignored by children + return 'funds/application_base.html' + def detail(self): # The location to find out more information return self.application_public.first() diff --git a/opentech/apply/funds/templates/funds/fund_type.html b/opentech/apply/funds/templates/funds/application_base.html similarity index 86% rename from opentech/apply/funds/templates/funds/fund_type.html rename to opentech/apply/funds/templates/funds/application_base.html index 126f364f7fe9fcd316b76a18cacfd0d54e78ad25..f3c0e80f6e04a9d4272d80f2e35f86361913803f 100644 --- a/opentech/apply/funds/templates/funds/fund_type.html +++ b/opentech/apply/funds/templates/funds/application_base.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% load wagtailcore_tags static i18n %} +{% load wagtailcore_tags static i18n util_tags %} {# Dont include fixed apply button on this page #} {% block apply_button %}{% endblock %} {% block header_modifier %}header--light-bg{% endblock %} @@ -23,8 +23,8 @@ <div class="wrapper wrapper--medium wrapper--light-grey-bg wrapper--form"> {% if not page.open_round and not page.start_date and not request.is_preview %} - {# the fund has no open rounds and we arent on a round page #} - <h3>{% trans "Sorry this fund is not accepting applications at the moment" %}</h3> + {# the page has no open rounds and we arent on a round page #} + <h3>{% blocktrans %}Sorry this {{ page|verbose_name }} is not accepting applications at the moment{% endblocktrans %}</h3> {% else%} <form class="form" action="" method="POST" enctype="multipart/form-data"> {{ form.media }} diff --git a/opentech/apply/funds/templates/funds/fund_type_landing.html b/opentech/apply/funds/templates/funds/application_base_landing.html similarity index 100% rename from opentech/apply/funds/templates/funds/fund_type_landing.html rename to opentech/apply/funds/templates/funds/application_base_landing.html diff --git a/opentech/apply/funds/templates/funds/lab_type.html b/opentech/apply/funds/templates/funds/lab_type.html index baf5e0176d6b7c3e71491c18de68bb7ce1c11d41..a72feba691ae4ad6e67af8038e3da2a26b5ce0ed 100644 --- a/opentech/apply/funds/templates/funds/lab_type.html +++ b/opentech/apply/funds/templates/funds/lab_type.html @@ -1 +1 @@ -{% extends "funds/fund_type.html" %} +{% extends "funds/application_base.html" %} diff --git a/opentech/apply/funds/templates/funds/lab_type_landing.html b/opentech/apply/funds/templates/funds/lab_type_landing.html index 1b73052e1d57d66278b59e9f92f090f0691682ee..b6fcf631f03cdecbc1a57f103c80147ad6b8a040 100644 --- a/opentech/apply/funds/templates/funds/lab_type_landing.html +++ b/opentech/apply/funds/templates/funds/lab_type_landing.html @@ -1 +1 @@ -{% extends "funds/fund_type_landing.html" %} +{% extends "funds/application_base_landing.html" %} diff --git a/opentech/apply/funds/templates/funds/round.html b/opentech/apply/funds/templates/funds/round.html index 953606218a6a04918cfdfcab714e227e73c736dc..3b266d76dddecc5932b7e0304e354cc2c2520a15 100644 --- a/opentech/apply/funds/templates/funds/round.html +++ b/opentech/apply/funds/templates/funds/round.html @@ -1,4 +1,4 @@ -{% extends "funds/fund_type.html" %} +{% extends "funds/application_base.html" %} {% block page_title %}{{ page.get_parent.title }}{% endblock %} diff --git a/opentech/apply/funds/templates/funds/round_landing.html b/opentech/apply/funds/templates/funds/round_landing.html index f4f58593182e3d30195aaece1dbceafd2ba7f6e0..0ed5e7f0e678b2c322fe7499bc599a42c822b686 100644 --- a/opentech/apply/funds/templates/funds/round_landing.html +++ b/opentech/apply/funds/templates/funds/round_landing.html @@ -1,3 +1,3 @@ -{% extends "funds/fund_type_landing.html" %} +{% extends "funds/application_base_landing.html" %} {% block page_title %}{{ page.get_parent.title }}{% endblock %} diff --git a/opentech/apply/funds/tests/factories/models.py b/opentech/apply/funds/tests/factories/models.py index 144d4ef4eac47e6e961a2017f4070f7e94fb2fb5..36e233f24ce381b036f2191b24d8f666f8d96dd0 100644 --- a/opentech/apply/funds/tests/factories/models.py +++ b/opentech/apply/funds/tests/factories/models.py @@ -40,8 +40,10 @@ __all__ = [ 'LabFactory', 'LabBaseFormFactory', 'LabSubmissionFactory', + 'RequestForPartnersFactory', 'SealedRoundFactory', 'SealedSubmissionFactory', + 'TodayRoundFactory', 'workflow_for_stages', ] diff --git a/opentech/apply/funds/tests/test_models.py b/opentech/apply/funds/tests/test_models.py index 5eddda0737c153a99d474480ab8e77e29de31fa4..012127318004a6c19f08ec575060cc3652a7242e 100644 --- a/opentech/apply/funds/tests/test_models.py +++ b/opentech/apply/funds/tests/test_models.py @@ -19,7 +19,9 @@ from .factories import ( CustomFormFieldsFactory, FundTypeFactory, LabFactory, + RequestForPartnersFactory, RoundFactory, + TodayRoundFactory, ) @@ -465,3 +467,20 @@ class TestSubmissionRenderMethods(TestCase): ) answers = submission.render_answers() self.assertNotIn(rich_text_label, answers) + + +class TestRequestForPartners(TestCase): + def test_message_when_no_round(self): + rfp = RequestForPartnersFactory() + request = make_request(site=rfp.get_site()) + response = rfp.serve(request) + self.assertContains(response, 'not accepting') + self.assertNotContains(response, 'Submit') + + def test_form_when_round(self): + rfp = RequestForPartnersFactory() + TodayRoundFactory(parent=rfp) + request = make_request(site=rfp.get_site()) + response = rfp.serve(request) + self.assertNotContains(response, 'not accepting') + self.assertContains(response, 'Submit')