The Wayback Machine - https://web.archive.org/web/20211022011723/https://github.com/python/pythondotorg/issues/1840
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor on how to link packages to sponsorship benefits #1840

Closed
6 tasks done
berinhard opened this issue Aug 11, 2021 · 0 comments
Closed
6 tasks done

Refactor on how to link packages to sponsorship benefits #1840

berinhard opened this issue Aug 11, 2021 · 0 comments

Comments

@berinhard
Copy link
Collaborator

@berinhard berinhard commented Aug 11, 2021

This issue addresses a needed refactoring on how we're currently linking Sponsorship objects to SponsorshipPackage. For some forgotten reason, the initial database modeling doesn't implement a foreign key from the first to the second model but only introduced a level_name attribute which holds a copy of the package name at the moment of the sponsorship creation, as you can see here.

This wasn't a problem until we start to introduce more complex logic on the sponsors app such as conditional logo placement (#1822) and more tier quantities for benefits (#1826). Both features depends on checking if a Sponsorship belongs to a certain SponsorshipPackage to do stuff. Both PRs are relying on top of the level_name attribute but this checking is problematic since string comparison are way more unstable than using foreign key to check against objects.

The refactoring touches:

  • Add a package FK from the Sponsorship model to the SponsorshipPackage;
  • Data migration to populate the new FK for existing sponsors based in the level_name attribute;
  • Update the sponsorships creation to populate the new FK;
  • Update sponsorship admin + approval process;
  • Refactor list_sponsors template tag to use the package instead of name to control the logo dimensions (maybe adding a new attribute to the package itself to store this data?);
  • Refactor TieredQuantityConfiguration.get_benefit_feature_kwargs to replace level_name by the new FK;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant