mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
networks: Use AppView for app page
Tests: - Enable/disable button is not shown. - Diagnostics button is shown and works. - Connections list, internet connection type and connectivity are shown properly. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
6bd9211791
commit
0d0c417bcd
@ -48,6 +48,8 @@ class NetworksApp(app_module.App):
|
|||||||
|
|
||||||
_version = 1
|
_version = 1
|
||||||
|
|
||||||
|
can_be_disabled = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Create components for the app."""
|
"""Create components for the app."""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from django.urls import re_path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
re_path(r'^sys/networks/$', views.index, name='index'),
|
re_path(r'^sys/networks/$', views.NetworksAppView.as_view(), name='index'),
|
||||||
re_path(r'^sys/networks/(?P<uuid>[\w.@+-]+)/show/$', views.show,
|
re_path(r'^sys/networks/(?P<uuid>[\w.@+-]+)/show/$', views.show,
|
||||||
name='show'),
|
name='show'),
|
||||||
re_path(r'^sys/networks/(?P<uuid>[\w.@+-]+)/edit/$', views.edit,
|
re_path(r'^sys/networks/(?P<uuid>[\w.@+-]+)/edit/$', views.edit,
|
||||||
|
|||||||
@ -12,9 +12,9 @@ from django.utils.translation import gettext_lazy
|
|||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
|
||||||
from plinth import app as app_module
|
|
||||||
from plinth import network
|
from plinth import network
|
||||||
from plinth.modules import first_boot, networks
|
from plinth.modules import first_boot, networks
|
||||||
|
from plinth.views import AppView
|
||||||
|
|
||||||
from .forms import (ConnectionTypeSelectForm, EthernetForm, GenericForm,
|
from .forms import (ConnectionTypeSelectForm, EthernetForm, GenericForm,
|
||||||
InternetConnectionTypeForm, NetworkTopologyForm, PPPoEForm,
|
InternetConnectionTypeForm, NetworkTopologyForm, PPPoEForm,
|
||||||
@ -115,23 +115,24 @@ WIRELESS_MODE_STRINGS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
class NetworksAppView(AppView):
|
||||||
"""Show connection list."""
|
"""Show networks app main page."""
|
||||||
connections = network.get_connection_list()
|
|
||||||
|
|
||||||
network_topology_type = networks.get_network_topology_type()
|
app_id = 'networks'
|
||||||
internet_connection_type = networks.get_internet_connection_type()
|
template_name = 'networks_configuration.html'
|
||||||
return TemplateResponse(
|
|
||||||
request, 'networks_configuration.html', {
|
def get_context_data(self, *args, **kwargs):
|
||||||
'app_id': 'networks',
|
"""Add additional context data for template."""
|
||||||
'app_info': app_module.App.get('networks').info,
|
connections = network.get_connection_list()
|
||||||
'title': _('Network Connections'),
|
|
||||||
'has_diagnostics': True,
|
network_topology_type = networks.get_network_topology_type()
|
||||||
'is_enabled': True,
|
internet_connection_type = networks.get_internet_connection_type()
|
||||||
'connections': connections,
|
|
||||||
'network_topology': network_topology_type,
|
context = super().get_context_data(*args, **kwargs)
|
||||||
'internet_connectivity_type': internet_connection_type,
|
context['connections'] = connections
|
||||||
})
|
context['network_topology'] = network_topology_type
|
||||||
|
context['internet_connectivity_type'] = internet_connection_type
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
def show(request, uuid):
|
def show(request, uuid):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user