mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +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
|
||||
|
||||
can_be_disabled = False
|
||||
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user