mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
first_boot: Add notification for next steps after first setup
- Since there is no way to reach the next steps page from the interface, provide a notification for it. Until the notification is dismissed, the user can reach this page with the notification. Tests: - On testing and stable containers, remove the sqlite file start the service. Complete the first setup wizard. After reaching the 'setup complete' page, notice that there is a notification for next steps to take. Title, icon, message and button text and styling are as expected. - Clicking on 'See next steps' takes us to next steps page. - Clicking on dismiss removes the notification. - Restarting the service does not bring back the notification. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
35312bd672
commit
7671f4a749
@ -8,6 +8,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext_noop
|
||||||
|
|
||||||
from plinth import app as app_module
|
from plinth import app as app_module
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
@ -48,8 +49,38 @@ class FirstBootApp(app_module.App):
|
|||||||
def setup(self, old_version):
|
def setup(self, old_version):
|
||||||
"""Install and configure the app."""
|
"""Install and configure the app."""
|
||||||
super().setup(old_version)
|
super().setup(old_version)
|
||||||
|
|
||||||
|
if not old_version:
|
||||||
|
self._show_next_steps_notification()
|
||||||
|
|
||||||
self.enable()
|
self.enable()
|
||||||
|
|
||||||
|
def _show_next_steps_notification(self):
|
||||||
|
"""After first setup, show notification for next steps."""
|
||||||
|
from plinth.notification import Notification
|
||||||
|
title = gettext_noop('Setup complete! Next steps:')
|
||||||
|
message = gettext_noop(
|
||||||
|
'Initial setup has been completed. Perform the next steps to make '
|
||||||
|
'your {box_name} operational.')
|
||||||
|
data = {
|
||||||
|
'app_name': 'translate:' + gettext_noop('Next steps'),
|
||||||
|
'app_icon': 'fa-arrow-right',
|
||||||
|
'box_name': 'translate:' + cfg.box_name
|
||||||
|
}
|
||||||
|
actions = [{
|
||||||
|
'type': 'link',
|
||||||
|
'class': 'primary',
|
||||||
|
'text': gettext_noop('See next steps'),
|
||||||
|
'url': 'first_boot:complete'
|
||||||
|
}, {
|
||||||
|
'type': 'dismiss'
|
||||||
|
}]
|
||||||
|
Notification.update_or_create(id='first-boot-complete',
|
||||||
|
app_id='first_boot', severity='info',
|
||||||
|
title=title, message=message,
|
||||||
|
actions=actions, data=data,
|
||||||
|
group='admin', dismissed=False)
|
||||||
|
|
||||||
|
|
||||||
def _clear_first_boot_steps(sender, module_name, **kwargs):
|
def _clear_first_boot_steps(sender, module_name, **kwargs):
|
||||||
"""Flush the cache of first boot steps so it is recreated."""
|
"""Flush the cache of first boot steps so it is recreated."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user