diff --git a/plinth/modules/network/network.py b/plinth/modules/network/network.py
index 6e67c1a28..86252935e 100644
--- a/plinth/modules/network/network.py
+++ b/plinth/modules/network/network.py
@@ -77,6 +77,65 @@ def index(request):
'connections': connections})
+@login_required
+def edit(request, conn_id):
+ """Serve connection editing form."""
+ form = None
+ name = urllib.parse.unquote_plus(conn_id)
+ form_data = {'name': name}
+
+ conn_found = False
+ for conn in NetworkManager.Settings.ListConnections():
+ settings = conn.GetSettings()
+ if settings['connection']['id'] == name:
+ conn_found = True
+ break
+ if not conn_found:
+ return redirect(reverse_lazy('network:index'))
+
+ if request.method == 'POST':
+ if settings['connection']['type'] == '802-11-wireless':
+ form = AddWifiForm(request.POST)
+ else:
+ form = AddEthernetForm(request.POST)
+ if form.is_valid():
+ new_settings = {
+ 'connection': {
+ 'id': form.cleaned_data['name'],
+ 'type': settings['connection']['type'],
+ 'uuid': settings['connection']['uuid'],
+ },
+ 'ipv4': {'method': form.cleaned_data['ipv4_method']},
+ }
+ if form.cleaned_data['ipv4_method'] == 'manual':
+ new_settings['ipv4']['addresses'] = [
+ (form.cleaned_data['ipv4_address'],
+ 24, # CIDR prefix length
+ '0.0.0.0')] # gateway
+ if settings['connection']['type'] == '802-3-ethernet':
+ new_settings['802-3-ethernet'] = {}
+ elif settings['connection']['type'] == '802-11-wireless':
+ new_settings['802-11-wireless'] = {
+ 'ssid': form.cleaned_data['ssid'],
+ }
+
+ conn.Update(new_settings)
+ return redirect(reverse_lazy('network:index'))
+ else:
+ form_data['ipv4_method'] = settings['ipv4']['method']
+ if settings['ipv4']['addresses']:
+ form_data['ipv4_address'] = settings['ipv4']['addresses'][0][0]
+ if settings['connection']['type'] == '802-11-wireless':
+ form_data['ssid'] = settings['802-11-wireless']['ssid']
+ form = AddWifiForm(form_data)
+ else:
+ form = AddEthernetForm(form_data)
+ return TemplateResponse(request, 'connections_edit.html',
+ {'title': _('Edit Connection'),
+ 'subsubmenu': subsubmenu,
+ 'form': form})
+
+
@login_required
def activate(request, conn_id):
"""Activate the connection."""
diff --git a/plinth/modules/network/templates/connections_edit.html b/plinth/modules/network/templates/connections_edit.html
new file mode 100644
index 000000000..bf53463d3
--- /dev/null
+++ b/plinth/modules/network/templates/connections_edit.html
@@ -0,0 +1,61 @@
+{% extends "base.html" %}
+{% comment %}
+#
+# This file is part of Plinth.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see