Skip to content

Some fixes for notifications #11093

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

Closed
wants to merge 3 commits into from
Closed

Some fixes for notifications #11093

wants to merge 3 commits into from

Conversation

agjohnson
Copy link
Contributor

This includes a few fixes and small restructuring to the notification/message classes.

  • Centralize message lookup and format string population on the registry model instead of the Notification model. This change will make more sense with my next PR
  • Use copy() when setting the format values, as to ensure thread safety, these shouldn't be set on the static instance class in the registry.
  • Add a base class for notifications, for messages/notifications that fall outside doc building.

This includes a few fixes and small restructuring to the notification/message classes.

- Centralize message lookup and format string population on the registry model
  instead of the Notification model. This change will make more sense with my next PR
- Use `copy()` when setting the format values, as to ensure thread safety,
  these shouldn't be set on the static instance class in the registry.
- Add a base class for notifications, for messages/notifications that fall
  outside doc building.
@agjohnson agjohnson requested a review from a team as a code owner February 5, 2024 21:03
@agjohnson agjohnson requested a review from stsewd February 5, 2024 21:03
@agjohnson agjohnson requested a review from humitos February 5, 2024 21:03
I found myself rebuilding these messages in template code and figured it
would be a good excuse to further consolidate the patterns we're using.

In short, these messages are emitted at view time and are not saved to
the database. The view time logic is similar as notifications however.

A few questions stand for me:

- I like centering all of our notifications/errors around exceptions, as
  it retains an opportunity to emit exceptions from wherever we might
  want to move some of this logic. Arguably, this logic should not exist
  on a single view and could be moved on to modeling/queryset classes.
- I don't have a strong opinion on whether it's important for these
  messages to exist in the registry. I see arguments for both, but I
  chose to use the registry so that we can consolidate logic there --
  format values and message lookup, etc.

I'm looking for input on these patterns.

On the template side, the display is now just a simple `if` and template
logic similar to the current notification display, using the header/body
render methods.
@agjohnson
Copy link
Contributor Author

Oops, this was the wrong branch, see #11094 instead.

@agjohnson agjohnson closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant