apluslms / a-plus

A+ frontend portal - A+ LMS documentation:
https://apluslms.github.io/
Other
65 stars 72 forks source link

Make sitewide alerts adjustable at runtime #1324

Closed ashi006 closed 5 months ago

ashi006 commented 7 months ago

Fixes #1047

Description

What?

Previously showing sitewide alert (e.g. about service breaks) is set in the settings file, meaning that A+ needs to be restarted for it take effect.

Why?

Setting alert in settings file is unnecessarily complicated e.g. in Kubernetes environment. This could be implemented it in such way (e.g. using DB) that an A+ user with sufficient privileges can update it during runtime, without needing to restart the whole Django app.

How?

The solution created a model named "Site alerts" in admin page where admin can add one or multiple alerts along with their status (Active / Removed). Alerts with Active status will be shown on A+.

Fixes #1047

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

The issue was tested by adding multiple entries in "Site alerts" model, all alerts with Active status were being displayed on A+. No alerts are displayed if there are no entries in "Site alerts" model at all or if there are no entries present with Active status.

Did you test the changes in

Think of what is affected by these changes and could become broken

Translation

Programming style

Have you updated the README or other relevant documentation?

Is it Done?

Clean up your git commit history before submitting the pull request!

ihalaij1 commented 5 months ago

Nice!

I made some small modifications to the code style and translations.

murhum1 commented 5 months ago

Changed the alert field to a JSONField so translations are supported as well.