From 3e8ce0c6bd36a1f96730086dc6d1687f16d62c24 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 24 Feb 2020 11:44:40 -0500 Subject: [PATCH] networks: Minor changes to router/internet configuration forms - Cosmetic styling fixes. Having doc string as suggested by Python doc string guidelines. - 'connected to the Internet' seems much more popular phrase than 'connected on the Internet' judging by web search results. - Stylize as 'Internet' for consistency although 'internet' is correct too. - Add space at the end of main radio button option text as translators seems to understand it incorrectly. See current Spanish translation. - Recommend 'DMZ' for router configuration. - Remove incorrect title casing port forwarding text. - Internationalize some strings. - Update the default value for router configuration to 'not_configured'. - Update the default value for Internet connection type to None so that nothing is selected by default. We could consider introducing a fourth option 'not_configured'. - Update the ID of first boot wizard step for Internet connectivity. Signed-off-by: Sunil Mohan Adapa --- plinth/modules/networks/__init__.py | 2 +- plinth/modules/networks/forms.py | 31 ++++++------ plinth/modules/networks/networks.py | 48 +++++++++---------- .../internet_connectivity_firstboot.html | 6 +-- .../templates/internet_connectivity_main.html | 15 ++++-- .../templates/internet_connectivity_type.html | 4 +- .../router_configuration_content.html | 2 +- .../router_configuration_firstboot.html | 5 +- .../templates/router_configuration_main.html | 11 ++--- 9 files changed, 61 insertions(+), 63 deletions(-) diff --git a/plinth/modules/networks/__init__.py b/plinth/modules/networks/__init__.py index cdc32e68a..34139ed7f 100644 --- a/plinth/modules/networks/__init__.py +++ b/plinth/modules/networks/__init__.py @@ -20,7 +20,7 @@ managed_packages = ['network-manager', 'batctl'] first_boot_steps = [ { - 'id': 'internet_connectivity_type', + 'id': 'internet_connectivity_type_wizard', 'url': 'networks:firstboot_internet_connection_type', 'order': 3, }, diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py index e04ea31de..0203838e5 100644 --- a/plinth/modules/networks/forms.py +++ b/plinth/modules/networks/forms.py @@ -286,10 +286,12 @@ requires clients to have the password to connect.'), class InternetConnectionTypeForm(forms.Form): - """ + """Form for type of public/private IP address ISP provides. + Ask the user for what type of Internet connection they have. We store this information and use it suggest various setup options during the setup process and also later on when setting up apps. + """ internet_connection_type = forms.ChoiceField( label=_('Choose your internet connection type'), @@ -298,7 +300,7 @@ class InternetConnectionTypeForm(forms.Form): format_lazy( _('I have a public IP address that may change over time' '

This means that devices on the ' - 'internet can reach you when you are connected on the ' + 'Internet can reach you when you are connected to the ' 'Internet. Every time you connect to the Internet with ' 'your Internet Service Provider (ISP), you may get a ' 'different IP address, especially after some offline time. ' @@ -311,7 +313,7 @@ class InternetConnectionTypeForm(forms.Form): _('I have a public IP address that does not change overtime ' '(recommended)' '

This means that devices on the ' - 'Internet can reach you when you are connected on the ' + 'Internet can reach you when you are connected to the ' 'Internet. Every time you connect to the Internet with ' 'your Internet Service Provider (ISP), you always get the ' 'same IP address. This is the most trouble-free setup for ' @@ -339,10 +341,11 @@ class InternetConnectionTypeForm(forms.Form): class RouterConfigurationWizardForm(forms.Form): - """ - Form to suggest router configuration depending on wan - connectivity/specific setup. The choice will affect - future suggestions during the setup process and other apps. + """Form to suggest how to configure a router. + + Suggest depending on wan connectivity/specific setup. The choice will + affect future suggestions during the setup process and other apps. + """ router_config = forms.ChoiceField( label=_('Preferred router configuration'), @@ -350,20 +353,20 @@ class RouterConfigurationWizardForm(forms.Form): ( 'dmz', format_lazy( - _('Use DMZ feature to forward all traffic' + _('Use DMZ feature to forward all traffic (recommended) ' '

Most routers provide a ' 'configuration setting called DMZ. This will allow the ' 'router to forward all incoming traffic from the ' - 'internet to a single IP address such as the ' - '{box_name}\'s address. First remember to configure a ' - 'static local IP address for your {box_name} in your ' + 'Internet to a single IP address such as the ' + '{box_name}\'s IP address. First remember to configure ' + 'a static local IP address for your {box_name} in your ' 'router\'s configuration.

'), box_name=cfg.box_name, allow_markup=True), ), ('port_forwarding', format_lazy( - _('Forward Specific Traffic as needed by each ' - 'application' + _('Forward specific traffic as needed by each ' + 'application ' '

You may alternatively choose to ' 'forward only specific traffic to your {box_name}. ' 'This is ideal if you have other servers like ' @@ -376,7 +379,7 @@ class RouterConfigurationWizardForm(forms.Form): allow_markup=True)), ('not_configured', format_lazy( - _('Router is currently unconfigured' + _('Router is currently unconfigured ' '

Choose this if you have not ' 'configured or are unable to configure the router ' 'currently and wish to be reminded later. Some of ' diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 3375f3749..a40266ea4 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -11,15 +11,10 @@ from django.views.decorators.http import require_POST from plinth import kvstore, network from plinth.modules import first_boot, networks -from .forms import ( - ConnectionTypeSelectForm, - EthernetForm, - GenericForm, - PPPoEForm, - WifiForm, - RouterConfigurationWizardForm, - InternetConnectionTypeForm, -) + +from .forms import (ConnectionTypeSelectForm, EthernetForm, GenericForm, + InternetConnectionTypeForm, PPPoEForm, + RouterConfigurationWizardForm, WifiForm) logger = logging.getLogger(__name__) @@ -28,6 +23,8 @@ def index(request): """Show connection list.""" connections = network.get_connection_list() + internet_connection_type = kvstore.get_default( + networks.INTERNET_CONNECTION_TYPE_KEY, None) return TemplateResponse( request, 'networks_configuration.html', { 'app_id': 'networks', @@ -36,8 +33,7 @@ def index(request): 'has_diagnostics': True, 'is_enabled': True, 'connections': connections, - 'internet_connectivity_type': kvstore.get_default( - networks.INTERNET_CONNECTION_TYPE_KEY, "dynamic_public_ip") + 'internet_connectivity_type': internet_connection_type }) @@ -410,9 +406,10 @@ def delete(request, uuid): def router_configuration_help_page(request): - """ - Show the router configuration wizard page/form. + """Show the router configuration wizard page/form. + Used both for fistboot step and same networks page. + """ is_firstboot = True \ if 'firstboot' in request.build_absolute_uri() else False @@ -431,19 +428,18 @@ def router_configuration_help_page(request): messages.success(request, _('Router configuration type saved.')) return redirect(resp) - else: - html = "router_configuration_update.html" + html = 'router_configuration_update.html' initial = { - "router_config": + 'router_config': kvstore.get_default(networks.ROUTER_CONFIGURATION_TYPE_KEY, - 'dmz'), + 'not_configured'), } template_kwargs = { 'form': RouterConfigurationWizardForm(initial=initial), } if is_firstboot: - html = "router_configuration_firstboot.html" + html = 'router_configuration_firstboot.html' # mark step done on firstboot visit to get the next_step first_boot.mark_step_done('router_setup_wizard') @@ -455,9 +451,10 @@ def router_configuration_help_page(request): def internet_connection_type_help_page(request): - """ - Show the internet connection type page. + """Show the internet connection type page. + Used for first boot step and networks page. + """ is_firstboot = True \ if 'firstboot' in request.build_absolute_uri() else False @@ -477,17 +474,18 @@ def internet_connection_type_help_page(request): messages.success(request, _('Internet connection type saved.')) return redirect(reverse_lazy('networks:index')) else: - html = "internet_connectivity_type.html" + html = 'internet_connectivity_type.html' initial = { - "internet_connection_type": kvstore.get_default( - networks.INTERNET_CONNECTION_TYPE_KEY, 'dynamic_public_ip'), + 'internet_connection_type': + kvstore.get_default(networks.INTERNET_CONNECTION_TYPE_KEY, + None) } template_kwargs = {'form': InternetConnectionTypeForm(initial=initial)} if is_firstboot: - html = "internet_connectivity_firstboot.html" + html = 'internet_connectivity_firstboot.html' # mark step done on firstboot visit to get the next_step - first_boot.mark_step_done('internet_connectivity_type') + first_boot.mark_step_done('internet_connectivity_type_wizard') template_kwargs.update({ 'first_boot_next_step': reverse_lazy(first_boot.next_step()), }) diff --git a/plinth/modules/networks/templates/internet_connectivity_firstboot.html b/plinth/modules/networks/templates/internet_connectivity_firstboot.html index 64e7c0c3f..04c14e38e 100644 --- a/plinth/modules/networks/templates/internet_connectivity_firstboot.html +++ b/plinth/modules/networks/templates/internet_connectivity_firstboot.html @@ -15,9 +15,7 @@ {{ form|bootstrap }} - {% trans "skip this step" %} - + {% trans "Skip this step" %} + - {% endblock %} diff --git a/plinth/modules/networks/templates/internet_connectivity_main.html b/plinth/modules/networks/templates/internet_connectivity_main.html index 8558cf184..25b30d5bd 100644 --- a/plinth/modules/networks/templates/internet_connectivity_main.html +++ b/plinth/modules/networks/templates/internet_connectivity_main.html @@ -20,15 +20,20 @@

{% if internet_connectivity_type == "static_public_ip" %} - My ISP provides a public IP address that does not change over time. + {% blocktrans trimmed %} + My ISP provides a public IP address that does not change over time. + {% endblocktrans %} {% elif internet_connectivity_type == "dynamic_public_ip" %} - My ISP provides a public IP address that may change over time. + {% blocktrans trimmed %} + My ISP provides a public IP address that may change over time. + {% endblocktrans %} {% else %} - I don't have a public IP address. + {% blocktrans trimmed %} + My ISP does not provide a public IP address. + {% endblocktrans %} {% endif %} - + role="button"> {% trans 'Update...' %}

diff --git a/plinth/modules/networks/templates/internet_connectivity_type.html b/plinth/modules/networks/templates/internet_connectivity_type.html index c8e1d23bf..0bd7bc8f5 100644 --- a/plinth/modules/networks/templates/internet_connectivity_type.html +++ b/plinth/modules/networks/templates/internet_connectivity_type.html @@ -15,8 +15,6 @@ {{ form|bootstrap }} - + - {% endblock %} diff --git a/plinth/modules/networks/templates/router_configuration_content.html b/plinth/modules/networks/templates/router_configuration_content.html index 5f0fb575b..b1deea60a 100644 --- a/plinth/modules/networks/templates/router_configuration_content.html +++ b/plinth/modules/networks/templates/router_configuration_content.html @@ -31,7 +31,7 @@

{% blocktrans trimmed %} If you don't have control over your router, choose not to configure it. To - see options, to overcome this limitation, choose 'no public address' option + see options to overcome this limitation, choose 'no public address' option in Internet connection type selection. {% endblocktrans %}

diff --git a/plinth/modules/networks/templates/router_configuration_firstboot.html b/plinth/modules/networks/templates/router_configuration_firstboot.html index 4720b3332..81cfd8c8d 100644 --- a/plinth/modules/networks/templates/router_configuration_firstboot.html +++ b/plinth/modules/networks/templates/router_configuration_firstboot.html @@ -15,9 +15,8 @@ {{ form|bootstrap }} - {% trans "skip this step" %} - + {% trans "Skip this step" %} + {% endblock %} diff --git a/plinth/modules/networks/templates/router_configuration_main.html b/plinth/modules/networks/templates/router_configuration_main.html index 58d9099b8..c3d109fba 100644 --- a/plinth/modules/networks/templates/router_configuration_main.html +++ b/plinth/modules/networks/templates/router_configuration_main.html @@ -10,6 +10,7 @@ {{ box_name }} Internet Connectivity {% endblocktrans %} +

{% blocktrans trimmed %} The following best describes how your {{ box_name }} is connected in your @@ -20,15 +21,11 @@

{% blocktrans trimmed %} - Your {{ box_name }} gets its internet from your Router via WiFi or + Your {{ box_name }} gets its Internet from your Router via Wi-Fi or Ethernet cable. This is a typical home setup. {% endblocktrans %} -

- - +