datamade / bga-payroll

💰 How much do your public officials make?
4 stars 4 forks source link

Conditionally show donate banner #493

Closed hancush closed 4 years ago

hancush commented 4 years ago

Description

This PR installs django-extra-settings to enable editing of a new setting, PAYROLL_SHOW_DONATION_BANNER, via the admin interface. It also uses this setting to conditionally display the large and small donate callouts on the homepage. Finally, it adds a new cache, vary_on_setting, stores the homepage there, and extends the Setting admin to clear this special cache when settings are changed, so the banners are toggled in real time.

Testing instructions

fgregg commented 4 years ago

thank you so much for explaining the voyage here, I appreciate that you've gone down so many alleys.

it feels like we are going against the grain here, and that feeling generally makes me nervous.

what about something like

  1. creating a different cache backend called something like "promotion_volatile" with it's own table
  2. set this page (and maybe future page) to use the "promotion_volatile" cache
  3. clear this whole, special cache when we change the banner.

You would also need to update the flush cache endpoint to flush both caches.

I know this is a pretty different way to go, so let me know if you want to talk it through by phone

hancush commented 4 years ago

What a great idea, @fgregg! Made the switch in https://github.com/datamade/bga-payroll/pull/493/commits/c17a678fb88766891175d4736018233b2ee4a579 – really streamlines things. Thoughts?

hancush commented 4 years ago

FWIW, deployed to and tested on staging. Works like a charm!

fgregg commented 4 years ago

Looks great!