mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
views: Implement an API to retrieve the readiness status in JSON
- This can have may uses such as: - Waiting properly on the reboot page until the system has been restarted while showing the status. - Or, waiting for first setup to complete before running functional tests. - Or, monitoring for the health status of FreedomBox in general. - The page is public as all the information conveyed there is also already public. Should we introduce any sensitive information there such as 'operations_in_progress', we can provide that information only to administrators. Tests: - Visiting /plinth/status/ shows the status in JSON. Using curl to retrieve the information is also possible. - During the first setup 'is_first_setup_running' is 'true'. After it has completed, it is 'false'. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
parent
8a4f03c58a
commit
623604649e
@ -30,9 +30,10 @@ class FirstBootMiddleware(MiddlewareMixin):
|
||||
if user_requests_login:
|
||||
return
|
||||
|
||||
# Don't interfere with help pages
|
||||
# Don't interfere with help or status pages
|
||||
user_requests_help = request.path.startswith(reverse('help:index'))
|
||||
if user_requests_help:
|
||||
user_requests_status = request.path.startswith(reverse('status'))
|
||||
if user_requests_help or user_requests_status:
|
||||
return
|
||||
|
||||
# Don't interfere with first setup progress page. When first setup is
|
||||
|
||||
@ -18,6 +18,7 @@ system_urlpatterns = [
|
||||
|
||||
urlpatterns = [
|
||||
re_path(r'^$', views.index, name='index'),
|
||||
re_path(r'^status/$', views.status, name='status'),
|
||||
re_path(r'^language-selection/$',
|
||||
public(views.LanguageSelectionView.as_view()),
|
||||
name='language-selection'),
|
||||
|
||||
@ -178,6 +178,16 @@ def index(request):
|
||||
})
|
||||
|
||||
|
||||
@public
|
||||
def status(request):
|
||||
"""Return the status of service in JSON format."""
|
||||
status = {
|
||||
'is_available': True,
|
||||
'is_first_setup_running': setup.is_first_setup_running
|
||||
}
|
||||
return JsonResponse(status)
|
||||
|
||||
|
||||
def _pick_menu_items(menu_items, selected_tags):
|
||||
"""Return a sorted list of menu items filtered by tags."""
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user