mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
names: Make all apps use new api to retrieve domain names
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
ab42b9b241
commit
b684b07d11
10 files changed
+28
-55
No files matched your search
@@ -32,9 +32,9 @@ from plinth.modules import names
|
||||
def access_info(request, **kwargs):
|
||||
"""API view to return a list of domains and types."""
|
||||
domains = [{
|
||||
'domain': domain,
|
||||
'type': domain_type
|
||||
} for domain_type, domains in names.domains.items() for domain in domains]
|
||||
'domain': domain.name,
|
||||
'type': domain.domain_type.component_id
|
||||
} for domain in names.components.DomainName.list()]
|
||||
response = {'domains': domains}
|
||||
|
||||
return HttpResponse(json.dumps(response), content_type='application/json')
|
||||
|
||||
@@ -110,11 +110,9 @@ def init():
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
domains = [
|
||||
domain for domains_of_a_type in names.domains.values()
|
||||
for domain in domains_of_a_type
|
||||
]
|
||||
helper.call('post', actions.superuser_run, 'cockpit', ['setup'] + domains)
|
||||
domains = names.components.DomainName.list_names('https')
|
||||
helper.call('post', actions.superuser_run, 'cockpit',
|
||||
['setup'] + list(domains))
|
||||
helper.call('post', app.enable)
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ from django.utils.translation import ugettext as _
|
||||
from django.views.generic import FormView
|
||||
|
||||
from plinth.forms import DomainSelectionForm
|
||||
from plinth.modules import diaspora
|
||||
from plinth.utils import get_domain_names
|
||||
from plinth.modules import diaspora, names
|
||||
from plinth.views import AppView
|
||||
|
||||
from .forms import DiasporaAppForm
|
||||
@@ -50,7 +49,8 @@ class DiasporaSetupView(FormView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['description'] = self.description
|
||||
context['title'] = self.title
|
||||
context['domain_names'] = get_domain_names()
|
||||
context['domain_names'] = names.components.DomainName.list_names(
|
||||
'https')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -111,12 +111,9 @@ def diagnose():
|
||||
"""Run diagnostics and return the results."""
|
||||
results = []
|
||||
|
||||
for domain_type, domains in names.domains.items():
|
||||
if domain_type == 'hiddenservice':
|
||||
continue
|
||||
|
||||
for domain in domains:
|
||||
results.append(action_utils.diagnose_url('https://' + domain))
|
||||
for domain in names.components.DomainName.list():
|
||||
if domain.domain_type.can_have_certificate:
|
||||
results.append(action_utils.diagnose_url('https://' + domain.name))
|
||||
|
||||
return results
|
||||
|
||||
@@ -203,13 +200,9 @@ def get_status():
|
||||
status = actions.superuser_run('letsencrypt', ['get-status'])
|
||||
status = json.loads(status)
|
||||
|
||||
for domain_type, domains in names.domains.items():
|
||||
# XXX: Remove when Let's Encrypt supports .onion addresses
|
||||
if domain_type == 'hiddenservice':
|
||||
continue
|
||||
|
||||
for domain in domains:
|
||||
status['domains'].setdefault(domain, {})
|
||||
for domain in names.components.DomainName.list():
|
||||
if domain.domain_type.can_have_certificate:
|
||||
status['domains'].setdefault(domain.name, {})
|
||||
|
||||
return status
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ from django.views.generic import FormView
|
||||
|
||||
from plinth import actions
|
||||
from plinth.forms import DomainSelectionForm
|
||||
from plinth.modules import matrixsynapse
|
||||
from plinth.utils import get_domain_names
|
||||
from plinth.modules import matrixsynapse, names
|
||||
from plinth.views import AppView
|
||||
|
||||
from . import get_public_registration_status
|
||||
@@ -51,7 +50,8 @@ class SetupView(FormView):
|
||||
|
||||
context['title'] = matrixsynapse.name
|
||||
context['description'] = matrixsynapse.description
|
||||
context['domain_names'] = get_domain_names()
|
||||
context['domain_names'] = names.components.DomainName.list_names(
|
||||
'matrix-synapse-plinth')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -51,10 +51,8 @@ class MinetestAppView(AppView): # pylint: disable=too-many-ancestors
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
"""Add service to the context data."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
# Filter out onion addresses and get a unique list of domains
|
||||
domains = set(domain for domains in names.domains.values()
|
||||
for domain in domains if not domain.endswith('.onion'))
|
||||
context['domains'] = domains
|
||||
context['domains'] = names.components.DomainName.list_names(
|
||||
'minetest-plinth')
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
@@ -109,10 +109,7 @@ def get_keys(fingerprint=None):
|
||||
['host-show-keys'] + fingerprint)
|
||||
keys = json.loads(output)['keys']
|
||||
|
||||
domains = [
|
||||
domain for domains_of_a_type in names.domains.values()
|
||||
for domain in domains_of_a_type
|
||||
]
|
||||
domains = names.components.DomainName.list_names()
|
||||
for key in keys.values():
|
||||
key['imported_domains'] = set(key.get('imported_domains', []))
|
||||
key['available_domains'] = set(key.get('available_domains', []))
|
||||
|
||||
@@ -22,8 +22,7 @@ from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
from plinth.forms import DomainSelectionForm
|
||||
from plinth.modules import tahoe
|
||||
from plinth.utils import get_domain_names
|
||||
from plinth.modules import names, tahoe
|
||||
from plinth.views import AppView
|
||||
|
||||
|
||||
@@ -44,7 +43,8 @@ class TahoeSetupView(FormView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['description'] = self.description
|
||||
context['title'] = self.title
|
||||
context['domain_names'] = get_domain_names()
|
||||
context['domain_names'] = names.components.DomainName.list_names(
|
||||
'tahoe-plinth')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
Reference in new issue
Block a user