Do not display repeated sponsorship applications #2003
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This PR updates the logic that executes a new sponsorship contract to query for existing and active applications from that same sponsor and "deactivate" them.
The sponsorship model now has a new FK called
overlapped_by
to flag these existing applications as overlapped by the new one. Beyond enabling us to understand which application replaces another, this FK is also being used to control which sponsorships should be considered as active ones. If this FK is populated, the application gets excluded from theSponsorship.objects.enabled()
queryset, even though it is finalized and has a valid start/end date range.