diff --git a/sponsors/models/sponsorship.py b/sponsors/models/sponsorship.py index 6a12d2f30..7443d4d2c 100644 --- a/sponsors/models/sponsorship.py +++ b/sponsors/models/sponsorship.py @@ -383,6 +383,12 @@ def next_status(self): } return states_map[self.status] + @property + def previous_effective_date(self): + if len(self.sponsor.sponsorship_set.all().order_by('-year')) > 1: + return self.sponsor.sponsorship_set.all().order_by('-year')[1].start_date + return None + class SponsorshipBenefit(OrderedModel): """ diff --git a/sponsors/pdf.py b/sponsors/pdf.py index 35585499f..f1b80d911 100644 --- a/sponsors/pdf.py +++ b/sponsors/pdf.py @@ -34,6 +34,7 @@ def _contract_context(contract, **context): "legal_clauses": _clean_split(contract.legal_clauses.raw), "renewal": contract.sponsorship.renewal, }) + context["previous_effective"] = contract.sponsorship.previous_effective_date if contract.sponsorship.previous_effective_date else "UNKNOWN" return context diff --git a/sponsors/tests/test_pdf.py b/sponsors/tests/test_pdf.py index fdb6d5835..2116b7c21 100644 --- a/sponsors/tests/test_pdf.py +++ b/sponsors/tests/test_pdf.py @@ -29,6 +29,7 @@ def setUp(self): "benefits": [], "legal_clauses": [], "renewal": None, + "previous_effective": "UNKNOWN", } self.template = "sponsors/admin/preview-contract.html" @@ -88,6 +89,7 @@ def test_render_response_with_docx_attachment__renewal(self, MockDocxTemplate): "benefits": [], "legal_clauses": [], "renewal": True, + "previous_effective": "UNKNOWN", } renewal_template = "sponsors/admin/preview-contract.html" diff --git a/sponsors/views_admin.py b/sponsors/views_admin.py index 8968da1b7..e9a808ccc 100644 --- a/sponsors/views_admin.py +++ b/sponsors/views_admin.py @@ -85,7 +85,11 @@ def approve_sponsorship_view(ModelAdmin, request, pk): ) return redirect(redirect_url) - context = {"sponsorship": sponsorship, "form": form} + context = { + "sponsorship": sponsorship, + "form": form, + "previous_effective": sponsorship.previous_effective_date if sponsorship.previous_effective_date else "UNKNOWN", + } return render(request, "sponsors/admin/approve_application.html", context=context) diff --git a/templates/sponsors/admin/approve_application.html b/templates/sponsors/admin/approve_application.html index 1415f871b..42a5f7382 100644 --- a/templates/sponsors/admin/approve_application.html +++ b/templates/sponsors/admin/approve_application.html @@ -2,7 +2,18 @@ {% extends 'admin/change_form.html' %} {% load i18n static sponsors %} -{% block extrastyle %}{{ block.super }}{% endblock %} +{% block extrastyle %} + {{ block.super }} + + +{% endblock %} {% block title %}Accept {{ sponsorship }} | python.org{% endblock %} @@ -33,6 +44,14 @@

Generate Contract for Signing

{{ form.media }} {{ form.as_p }} +

+ + {{ previous_effective }} + The last known contract effective date for this sponsor. This will only impact renewals. If UNKNOWN, you MUST update the resulting docx with the correct effective date. +

+