Sunil Mohan Adapa 900c0d30b9
*: Drop module level app property
module.app property usage is greatly reduced because setup() and force_upgrade()
method are now part of App class instead of at the module level. Remove the
remaining minor cases of usage and drop the property altogether.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:29 -04:00

33 lines
840 B
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
FreedomBox app for name services.
"""
from django.template.response import TemplateResponse
from plinth import app as app_module
from . import components
def index(request):
"""Serve name services page."""
status = get_status()
return TemplateResponse(request, 'names.html', {
'app_info': app_module.App.get('names').info,
'status': status
})
def get_status():
"""Get configured services per name."""
domains = components.DomainName.list()
used_domain_types = {domain.domain_type for domain in domains}
unused_domain_types = [
domain_type for domain_type in components.DomainType.list().values()
if domain_type not in used_domain_types
]
return {'domains': domains, 'unused_domain_types': unused_domain_types}