mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Tests: - App page shows properly. Status of the current domains is shown properly. - App page does not show enable/disable button. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
34 lines
909 B
Python
34 lines
909 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
FreedomBox app for name services.
|
|
"""
|
|
|
|
from plinth.views import AppView
|
|
|
|
from . import components
|
|
|
|
|
|
class NamesAppView(AppView):
|
|
"""Show names app main page."""
|
|
|
|
app_id = 'names'
|
|
template_name = 'names.html'
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
"""Add additional context data for template."""
|
|
context = super().get_context_data(*args, **kwargs)
|
|
context['status'] = get_status()
|
|
return context
|
|
|
|
|
|
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}
|