rcpch / rcpch-audit-engine

Epilepsy12 Audit Platform
https://e12.rcpch.ac.uk/
GNU Affero General Public License v3.0
5 stars 5 forks source link

Banners! #1076

Closed mbarton closed 4 weeks ago

mbarton commented 1 month ago

Fixes #1060 Fixes #1059 Fixes #882

Add banners using the Django admin, targeted to specific pages using a regular expression. Add arbitrary HTML to the banner.

Screenshot 2024-10-15 13 10 13

Screenshot 2024-10-15 12 42 18

Allows us to implement the guidance for the organisational audit in #1060 and #1059 generically. In particular you can target banners at specific users (eg the organisational audit CTA should only be shown to lead clinicians). RCPCH audit team members can always see banners.

Banners are a model in the database but are cached for 10 seconds to avoid introducing another database call on every page load. This might be overkilll though as our pages load from the DB pretty much every time anyway. Although this way at least the unauthenticated homepage doesn't hit the DB every time.

@eatyourpeas do you think a model and the Django admin is the right way to implement this? I'm wondering should the banner definitions just be in the codebase since we have a quick CD pipeline now? At least having it in the DB the team can change banners without raising a PR and being worried they'd break something.

mbarton commented 4 weeks ago

Cool thanks. I agree that in the context of the slow page load the cache doesn't make much difference - testing it locally it takes 1.5 seconds without the banners and 1.6 with.

I think I will still keep in it though just for the sake of the unauthenticated homepage.

I've raised a separate issue to look at the performance of the org summary page: https://github.com/rcpch/rcpch-audit-engine/issues/1092

mbarton commented 4 weeks ago

The nice thing about a model is that you could potentially track who has seen the banner and who hasn't? So for example if they have already completed the audit you could hide the banner, or if you have read the notification we could stop showing it

I'm definitely up for the latter, the former feels quite use case specific where I'm trying to keep the banners implementation as general as possible

mbarton commented 4 weeks ago

Overdue on STAGING, LIVE (merged by @mbarton 30 minutes and 5 seconds ago) What's gone wrong?

mbarton commented 4 weeks ago

Seen on STAGING, LIVE (merged by @mbarton 57 minutes and 59 seconds ago) Please check your changes!