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
Keep track of current sponsorship year #2087
Conversation
…d a la carte benefits from the current year
…efits by the current year
…xecution time instead of interpretation's one
This reverts commit 17f7bed.
@ewdurbin I didn't manage to test this PR via the web interface. I still couldn't load the data for the sponsors app using the dump JSON files you sent me, but we can talk about this topic next Monday. |
ba2db7a
to
26d1b56
Compare
…ing db constraints and with valid due dates
… year will look like
…om active year list
@ewdurbin I guess now we have the whole workflow implemented. I managed to test the whole process of cloning an sponsorship application, updating the new year's benefits info, previewing it and everything work smoothly. I'm adding a few screen shots here to guide you through you own QA: 1 - Clone by yearYou can access the following page via admin going to Sponsors > Active Yer and then clicking on the button "Clone Application Configuraton". After submiting the form, the same page will be displayed for you with the links to the benefits and packages from the new configured year in the list of already configured years: 2 - Customizing the configuration for the yearYou can change benefits and package information for that year. You can access them directly from the filter URLs displayed in the Active Year as the screen shot bellow shows: 3 - Previewing the form from a specific yearAs you can see, the previous page also lists a link to preview the application form for those years. I'm using the same URL as the current one, but with an extra querystring parameter called |
This is stellar work @berinhard I pushed one minor tweak to make the preview a little more obvious. Otherwise, I was able to test this with a full prod dataset for sponsorship and it is |
Fixes #2084
This PR introduces a new singleton model in the sponsors app called
SponsorshipCurrentYear
. This model is used to keep rack of the current application year.I wanted to not use Django to manage the singleton because I felt it would make the Python code more complex. Instead, I left this responsibility to Postgres. I did so by adding an unique index on a constant value in this new table. By doing that, the only changes required in Django were to disable deletion and addition for this new model. Even though the singleton is implemented in Postgres, this PR adds Django unit tests to ensure it's working. This PR also introduces an initial data migration to populate the singleton and to set the year to 2023.
Then, a new
year
indexed column was added to the following models:Sponsorship
,SponsorshipPackage
andSponsorshipBenefit
. The first one represents the sponsorship application itself, while the others are used as configuration models used by application to properly populate its related objects. The year of the sponsorship gets populated when it gets created using the value fromSponsorshipCurrentYear.get_year
. The year for the configuration models can be edit via Django admin, but this PR introduces an initial migration to populate them with 2023.The queries to list packages, their benefits, add-ons and a la carte benefits in the sponsorship application form were updated to only return configured objects from the current year. That way, we can customize the whole sponsorship application form by year.
It's worthwhile to mention that the
SponsorshipCurrentYear.get_year
has a cache policy to avoid repeated and unnecessary db hits to fetch for the year value. The cached value, when populated, is set to never expire. But, when the year gets updated in the database, thesave
method invalidates the existing cache. So, that way, the cache will get populated again with the new value onceSponsorshipCurrentYear.get_year
is called again.