Skip to content

Conversation

@ewdurbin
Copy link
Member

Add a new management command reset_sponsorship_benefits that performs a complete clean slate reset of sponsorship benefits when sponsors transition from one year's package to another (e.g., 2025 to 2026).

This addresses the issue where sponsorships created in 2025 were later assigned to 2026 packages but retained 2025 benefit configurations, templates, and asset references, causing inconsistencies in the admin interface and benefit calculations.

Command features:

  • Deletes ALL GenericAssets linked to the sponsorship (including old year references)
  • Deletes ALL existing sponsor benefits (cascades to features)
  • Recreates all benefits fresh from the target year's package template
  • Updates sponsorship year to match package year (with --update-year flag)
  • Supports dry-run mode for safe preview (with --dry-run flag)
  • Uses atomic transactions to ensure data consistency
  • Handles edge cases: duplicates, renamed benefits, missing templates

Usage:
python manage.py reset_sponsorship_benefits [ ...] --update-year python manage.py reset_sponsorship_benefits --dry-run --update-year

Tests added to verify:

  • Full 2025 to 2026 transition scenario
  • Duplicate benefit handling
  • Dry-run mode functionality
  • Year updates
  • GenericAsset cleanup
  • Admin visibility (template year matching)
  • Feature recreation with updated configurations

🤖 Generated with Claude Code

Add a new management command `reset_sponsorship_benefits` that performs a
complete clean slate reset of sponsorship benefits when sponsors transition
from one year's package to another (e.g., 2025 to 2026).

This addresses the issue where sponsorships created in 2025 were later
assigned to 2026 packages but retained 2025 benefit configurations,
templates, and asset references, causing inconsistencies in the admin
interface and benefit calculations.

Command features:
- Deletes ALL GenericAssets linked to the sponsorship (including old year references)
- Deletes ALL existing sponsor benefits (cascades to features)
- Recreates all benefits fresh from the target year's package template
- Updates sponsorship year to match package year (with --update-year flag)
- Supports dry-run mode for safe preview (with --dry-run flag)
- Uses atomic transactions to ensure data consistency
- Handles edge cases: duplicates, renamed benefits, missing templates

Usage:
  python manage.py reset_sponsorship_benefits <id> [<id> ...] --update-year
  python manage.py reset_sponsorship_benefits <id> --dry-run --update-year

Tests added to verify:
- Full 2025 to 2026 transition scenario
- Duplicate benefit handling
- Dry-run mode functionality
- Year updates
- GenericAsset cleanup
- Admin visibility (template year matching)
- Feature recreation with updated configurations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ewdurbin ewdurbin requested a review from JacobCoffee as a code owner October 30, 2025 20:06
@ewdurbin ewdurbin merged commit 869bc73 into main Oct 30, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants