From 7033b7cf1ec9fa462d6a1aa4b64101a4b99354a0 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 7 Oct 2024 11:09:30 -0700 Subject: [PATCH] upgrades: Show notification to remind user to run updates manually - This is needed as we don't have software updates step during first setup anymore. Tests: - Trigger first setup by removing /var/lib/plinth/plinth.sqlite3 and re-running the service. After completing the setup, a notification is shown with correct severity, title, app icon, message and options. Dismiss remove the notifications. 'Go to Software Updates' takes us to updates app. - After dismissing the notification, re-running the service does not show notification again. - Increasing the app version number also does not show notification again. - Re-running the app setup does not show notification again. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/upgrades/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/plinth/modules/upgrades/__init__.py b/plinth/modules/upgrades/__init__.py index 34bb13dd0..7b225e177 100644 --- a/plinth/modules/upgrades/__init__.py +++ b/plinth/modules/upgrades/__init__.py @@ -132,6 +132,31 @@ class UpgradesApp(app_module.App): group='admin') note.dismiss(should_dismiss=dismiss) + def _show_first_manual_update_notification(self): + """After first setup, show notification to manually run updates.""" + from plinth.notification import Notification + title = gettext_noop('Run software update manually') + message = gettext_noop( + 'Automatic software update runs daily by default. For the first ' + 'time, manually run it now.') + data = { + 'app_name': 'translate:' + gettext_noop('Software Update'), + 'app_icon': 'fa-refresh' + } + actions = [{ + 'type': 'link', + 'class': 'primary', + 'text': gettext_noop('Go to {app_name}'), + 'url': 'upgrades:index' + }, { + 'type': 'dismiss' + }] + Notification.update_or_create(id='upgrades-first-manual-update', + app_id='upgrades', severity='info', + title=title, message=message, + actions=actions, data=data, + group='admin', dismissed=False) + def setup(self, old_version): """Install and configure the app.""" super().setup(old_version) @@ -140,6 +165,10 @@ class UpgradesApp(app_module.App): if not old_version and not cfg.develop: privileged.enable_auto() + # Request user to run manual update as a one time activity + if not old_version: + self._show_first_manual_update_notification() + # Update apt preferences whenever on first install and on version # increment. privileged.setup()