Skip to content

Commit b942a20

Browse files
committed
prevent dupe in progress apps
1 parent 49f81df commit b942a20

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apps/sponsors/manage/views.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,8 +2051,15 @@ def _create_sponsorship(self, request, data, sponsor, package, benefits):
20512051
"""Create the Sponsorship and SponsorBenefit copies."""
20522052
import datetime
20532053

2054+
from apps.sponsors.exceptions import SponsorWithExistingApplicationError
2055+
20542056
year = data.get("year") or SponsorshipCurrentYear.get_year()
20552057

2058+
# Guard: prevent duplicate in-progress sponsorships (same check as Sponsorship.new())
2059+
if Sponsorship.objects.in_progress().filter(sponsor=sponsor).exists():
2060+
msg = f"Sponsor pk: {sponsor.pk}"
2061+
raise SponsorWithExistingApplicationError(msg)
2062+
20562063
sponsorship = Sponsorship.objects.create(
20572064
submited_by=request.user,
20582065
sponsor=sponsor,

0 commit comments

Comments
 (0)