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:
Sunil Mohan Adapa 2022-08-19 16:42:14 -07:00 committed by James Valleroy
parent 6bd9211791
commit 0d0c417bcd
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 21 additions and 18 deletions

View File

@ -48,6 +48,8 @@ class NetworksApp(app_module.App):
_version = 1
can_be_disabled = False
def __init__(self):
"""Create components for the app."""
super().__init__()

View File

@ -8,7 +8,7 @@ from django.urls import re_path
from . import views
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,
name='show'),
re_path(r'^sys/networks/(?P<uuid>[\w.@+-]+)/edit/$', views.edit,

View File

@ -12,9 +12,9 @@ from django.utils.translation import gettext_lazy
from django.views.decorators.http import require_POST
from django.views.generic.edit import FormView
from plinth import app as app_module
from plinth import network
from plinth.modules import first_boot, networks
from plinth.views import AppView
from .forms import (ConnectionTypeSelectForm, EthernetForm, GenericForm,
InternetConnectionTypeForm, NetworkTopologyForm, PPPoEForm,
@ -115,23 +115,24 @@ WIRELESS_MODE_STRINGS = {
}
def index(request):
"""Show connection list."""
connections = network.get_connection_list()
class NetworksAppView(AppView):
"""Show networks app main page."""
network_topology_type = networks.get_network_topology_type()
internet_connection_type = networks.get_internet_connection_type()
return TemplateResponse(
request, 'networks_configuration.html', {
'app_id': 'networks',
'app_info': app_module.App.get('networks').info,
'title': _('Network Connections'),
'has_diagnostics': True,
'is_enabled': True,
'connections': connections,
'network_topology': network_topology_type,
'internet_connectivity_type': internet_connection_type,
})
app_id = 'networks'
template_name = 'networks_configuration.html'
def get_context_data(self, *args, **kwargs):
"""Add additional context data for template."""
connections = network.get_connection_list()
network_topology_type = networks.get_network_topology_type()
internet_connection_type = networks.get_internet_connection_type()
context = super().get_context_data(*args, **kwargs)
context['connections'] = connections
context['network_topology'] = network_topology_type
context['internet_connectivity_type'] = internet_connection_type
return context
def show(request, uuid):