Refactor on how to link packages to sponsorship benefits #1840
Labels
Comments
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue addresses a needed refactoring on how we're currently linking
Sponsorship
objects toSponsorshipPackage
. For some forgotten reason, the initial database modeling doesn't implement a foreign key from the first to the second model but only introduced alevel_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 certainSponsorshipPackage
to do stuff. Both PRs are relying on top of thelevel_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:
package
FK from theSponsorship
model to theSponsorshipPackage
;level_name
attribute;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?);TieredQuantityConfiguration.get_benefit_feature_kwargs
to replacelevel_name
by the new FK;The text was updated successfully, but these errors were encountered: