Skip to content

Commit

Permalink
use the sponsorship form directly rather than editing template
Browse files Browse the repository at this point in the history
  • Loading branch information
ewdurbin committed Dec 19, 2023
1 parent 3a9ef62 commit 3593c83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions sponsors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ class SponsorshipReviewAdminForm(forms.ModelForm):
start_date = forms.DateField(widget=AdminDateWidget(), required=False)
end_date = forms.DateField(widget=AdminDateWidget(), required=False)
overlapped_by = forms.ModelChoiceField(queryset=Sponsorship.objects.select_related("sponsor", "package"), required=False)
renewal = forms.CheckboxInput()
renewal = forms.BooleanField(
help_text="If true, it means the sponsorship is a renewal of a previous sponsorship and will use the renewal template for contracting.",
required=False,
)

def __init__(self, *args, **kwargs):
force_required = kwargs.pop("force_required", False)
Expand All @@ -404,11 +407,12 @@ def __init__(self, *args, **kwargs):
self.fields.pop("overlapped_by") # overlapped should never be displayed on approval
for field_name in self.fields:
self.fields[field_name].required = True
self.fields["renewal"].required = False


class Meta:
model = Sponsorship
fields = ["start_date", "end_date", "package", "sponsorship_fee"]
fields = ["start_date", "end_date", "package", "sponsorship_fee", "renewal"]
widgets = {
'year': SPONSORSHIP_YEAR_SELECT,
}
Expand Down
6 changes: 5 additions & 1 deletion sponsors/models/sponsorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ class Sponsorship(models.Model):
package = models.ForeignKey(SponsorshipPackage, null=True, on_delete=models.SET_NULL)
sponsorship_fee = models.PositiveIntegerField(null=True, blank=True)
overlapped_by = models.ForeignKey("self", null=True, on_delete=models.SET_NULL)
renewal = models.BooleanField(null=True, blank=True)
renewal = models.BooleanField(
null=True,
blank=True,
help_text="If true, it means the sponsorship is a renewal of a previous sponsorship and will use the renewal template for contracting."
)

assets = GenericRelation(GenericAsset)

Expand Down
2 changes: 0 additions & 2 deletions templates/sponsors/admin/approve_application.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ <h1>Generate Contract for Signing</h1>
{{ form.as_p }}

<input name="confirm" value="yes" style="display:none">
<input type="checkbox" id="renewal" name="renewal" value="renewal">
<label for="renewal">Renewal of a previous sponsorship</label><br>
<div class="submit-row">
<input type="submit" value="Approve" class="default">
</div>
Expand Down

0 comments on commit 3593c83

Please sign in to comment.