Skip to content

Commit

Permalink
include previous effective date in context/review form for renewals
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Dec 19, 2023
1 parent 3593c83 commit 7ed4397
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
6 changes: 6 additions & 0 deletions sponsors/models/sponsorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
1 change: 1 addition & 0 deletions sponsors/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 2 additions & 0 deletions sponsors/tests/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def setUp(self):
"benefits": [],
"legal_clauses": [],
"renewal": None,
"previous_effective": "UNKNOWN",
}
self.template = "sponsors/admin/preview-contract.html"

Expand Down Expand Up @@ -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"

Expand Down
6 changes: 5 additions & 1 deletion sponsors/views_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
21 changes: 20 additions & 1 deletion templates/sponsors/admin/approve_application.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@
{% extends 'admin/change_form.html' %}
{% load i18n static sponsors %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">{% endblock %}
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}">
<style>
.helptext {
font-size: smaller;
display: block;
padding-top: .5em;
color: #999;
}
</style>
{% endblock %}

{% block title %}Accept {{ sponsorship }} | python.org{% endblock %}

Expand Down Expand Up @@ -33,6 +44,14 @@ <h1>Generate Contract for Signing</h1>
{{ form.media }}
{{ form.as_p }}

<p>
<label for="id_renewal_previous_effective_date">
Previous Effective Contract:
</label>
<span><b>{{ previous_effective }}</b></span>
<span class="helptext">The last known contract effective date for this sponsor. This will <i>only</i> impact renewals. If UNKNOWN, you <strong>MUST</strong> update the resulting docx with the correct effective date.</span>
</p>

<input name="confirm" value="yes" style="display:none">
<div class="submit-row">
<input type="submit" value="Approve" class="default">
Expand Down

0 comments on commit 7ed4397

Please sign in to comment.