12 Commits

Author SHA1 Message Date
Joseph Nuthalapati
efbf2a80f5
notifications: Fix setting last_update_time
The field last_update_time is set to auto_now in the Django model, but it is not
being updated when using update_or_create() since Django 4.2. This is because it
sends update_fields= argument to save().

Say, a user installed an app a few hours ago and uninstalls it now, the
notification should be updated to show the uninstallation status but it shows
the timestamp of the installation instead.

Explicitly setting the updated timestamp is one way of fixing this issue.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Use django_db mark in test case]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2025-07-10 16:05:47 -07:00
Sunil Mohan Adapa
685e636a93
notification: Handle more formatting errors
When there message strings containing substrings of the form
"{object.property}", an AttributeError is raised instead of KeyError during
string formatting. Catch these errors.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-05-06 17:14:47 -04:00
James Valleroy
a5820bc36d
diagnostics: Add method to translate checks
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:18:56 -08:00
Sunil Mohan Adapa
daabeccb60
db: Serialize most of the database queries using locks
See db.py for rationale.

Tests:

- Run functional tests and unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-10-23 12:40:13 -04:00
Sunil Mohan Adapa
d69167bcfa
notification: Don't fail when formatting message strings
- When a notification's message contains unexpected formatting characters such
as '{}', showing the notification and consequently the entire FreedomBox web
interface fails. Prevent that by make sure that that message formatting never
fails.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-01 08:02:51 -04:00
Sunil Mohan Adapa
fee21cba0d
notification: Pass full context when rendering body template
- Important information such as id of the notification should be available when
rendering the body template.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:06 -04:00
Sunil Mohan Adapa
74214c18ae
*: Use Django gettext functions instead of ugettext
- ugettext functions will be removed in Django 4.0. Each use emits a warning
when running with Django 3.2. Since we have warnings enabled in developer mode,
we see quite a few messages because of this.

- ugettext is already a simple alias of gettext. So, no regressions are
expected.

Tests:

- Accessing an affected app in UI with Django 3.2 and Django 2.2 works fine.

- Using Django 3.2 there are no warnings related to removal of ugettext
functions.

- Ran regular unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:16 -04:00
Sunil Mohan Adapa
5a126e62a8
notifications: Fix issue with redirection on dismiss
The request variable is not available when a custom template is used to render a
notification. Fix this by passing the template rendering context additional
request variable.

Closes: #1887.

Tests:

- Reduce the version number in data for 'upgrades-new-release' notification
in the plinth_storednotification table in the DB. Start FreedomBox. New release
message will appear. Go to page other than home page. The dismiss button has
next= parameter filled properly with current URL. Dismiss the notification and
notice that page URL stays the same.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-27 16:03:12 -04:00
Sunil Mohan Adapa
b3663075a0
notification: Expand and clarify restriction on id property
- This is to allow arbitrary strings to be part of id property via base32
encoding.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-05-15 18:00:53 -07:00
Sunil Mohan Adapa
22c3241a52
notification: Add developer documentation
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-22 15:51:47 -05:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Sunil Mohan Adapa
8e0a94282f
notification: New API for showing better notifications
Closes: #867.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-10 18:13:19 -05:00