diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index af28b5a8f..e732f1f81 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -22,7 +22,7 @@ import os import socket import augeas -from django.utils.translation import ugettext_lazy +from django.utils.translation import ugettext_lazy as _ from plinth import actions from plinth import app as app_module @@ -34,6 +34,8 @@ version = 2 is_essential = True +name = _('General Configuration') + depends = ['firewall', 'names'] manual_page = 'Configure' @@ -57,14 +59,12 @@ class ConfigApp(app_module.App): def __init__(self): """Create components for the app.""" super().__init__() - menu_item = menu.Menu('menu-config', ugettext_lazy('Configure'), None, - 'fa-cog', 'config:index', - parent_url_name='system') + menu_item = menu.Menu('menu-config', _('Configure'), None, 'fa-cog', + 'config:index', parent_url_name='system') self.add(menu_item) - domain_type = DomainType('domain-type-static', - ugettext_lazy('Domain Name'), 'config:index', - can_have_certificate=True) + domain_type = DomainType('domain-type-static', _('Domain Name'), + 'config:index', can_have_certificate=True) self.add(domain_type) diff --git a/plinth/modules/config/templates/config.html b/plinth/modules/config/templates/config.html deleted file mode 100644 index 39fb5bd65..000000000 --- a/plinth/modules/config/templates/config.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends "base.html" %} -{% comment %} -# -# This file is part of FreedomBox. -# -# 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 . -# -{% endcomment %} - -{% load bootstrap %} -{% load i18n %} -{% load static %} - -{% block content %} - - {% block pagetitle %} -

{{ title }}

- {% endblock %} - - {% if manual_page %} -

- - {% trans 'Learn more...' %} - -

- {% endif %} - -
- {% csrf_token %} - - {{ form|bootstrap }} - - -
- -{% endblock %} diff --git a/plinth/modules/config/urls.py b/plinth/modules/config/urls.py index 676e60a0f..5d4570bba 100644 --- a/plinth/modules/config/urls.py +++ b/plinth/modules/config/urls.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # - """ URLs for the Configuration module """ @@ -24,5 +23,5 @@ from django.conf.urls import url from . import views urlpatterns = [ - url(r'^sys/config/$', views.index, name='index'), + url(r'^sys/config/$', views.ConfigAppView.as_view(), name='index'), ] diff --git a/plinth/modules/config/views.py b/plinth/modules/config/views.py index 8b2988633..90da42afc 100644 --- a/plinth/modules/config/views.py +++ b/plinth/modules/config/views.py @@ -21,10 +21,9 @@ FreedomBox views for basic system configuration. import logging from django.contrib import messages -from django.template.response import TemplateResponse from django.utils.translation import ugettext as _ -from plinth import actions +from plinth import actions, views from plinth.modules import config from plinth.signals import (domain_added, domain_removed, post_hostname_change, pre_hostname_change) @@ -34,27 +33,13 @@ from .forms import ConfigurationForm LOGGER = logging.getLogger(__name__) -def index(request): - """Serve the configuration form""" - status = get_status() - - if request.method == 'POST': - form = ConfigurationForm(request.POST, initial=status, - prefix='configuration') - # pylint: disable-msg=E1101 - if form.is_valid(): - _apply_changes(request, status, form.cleaned_data) - status = get_status() - form = ConfigurationForm(initial=status, prefix='configuration') - else: - form = ConfigurationForm(initial=status, prefix='configuration') - - return TemplateResponse( - request, 'config.html', { - 'title': _('General Configuration'), - 'form': form, - 'manual_page': config.manual_page - }) +class ConfigAppView(views.AppView): + """Serve configuration page.""" + name = config.name + form_class = ConfigurationForm + app_id = 'config' + manual_page = config.manual_page + show_status_block = False def get_status():