diff --git a/plinth/modules/sharing/__init__.py b/plinth/modules/sharing/__init__.py index c716b13b5..1ce644648 100644 --- a/plinth/modules/sharing/__init__.py +++ b/plinth/modules/sharing/__init__.py @@ -10,10 +10,11 @@ from django.utils.translation import gettext_lazy as _ from plinth import actions from plinth import app as app_module from plinth import cfg, menu +from plinth.modules.apache.components import Webserver from plinth.modules.backups.components import BackupRestore from plinth.utils import format_lazy -from . import manifest +from . import manifest, privileged _description = [ format_lazy( @@ -28,7 +29,7 @@ class SharingApp(app_module.App): app_id = 'sharing' - _version = 1 + _version = 2 def __init__(self): """Create components for the app.""" @@ -43,13 +44,21 @@ class SharingApp(app_module.App): parent_url_name='apps') self.add(menu_item) + webserver = Webserver('webserver-sharing', 'sharing-freedombox') + self.add(webserver) + backup_restore = BackupRestore('backup-restore-sharing', **manifest.backup) self.add(backup_restore) + def has_diagnostics(self): + """Disable diagnostics button despite having webserver component.""" + return False + def setup(self, old_version): """Install and configure the app.""" super().setup(old_version) + privileged.setup() self.enable() diff --git a/plinth/modules/sharing/privileged.py b/plinth/modules/sharing/privileged.py new file mode 100644 index 000000000..79c247f07 --- /dev/null +++ b/plinth/modules/sharing/privileged.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Configure sharing.""" + +import pathlib + +from plinth.actions import privileged + +APACHE_CONFIGURATION = '/etc/apache2/conf-available/sharing-freedombox.conf' + + +@privileged +def setup(): + """Create an empty apache configuration file.""" + path = pathlib.Path(APACHE_CONFIGURATION) + if not path.exists(): + path.touch() diff --git a/plinth/modules/sharing/templates/sharing.html b/plinth/modules/sharing/templates/sharing.html index e63f125d3..4eedd13c7 100644 --- a/plinth/modules/sharing/templates/sharing.html +++ b/plinth/modules/sharing/templates/sharing.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "app.html" %} {% comment %} # SPDX-License-Identifier: AGPL-3.0-or-later {% endcomment %} @@ -11,9 +11,8 @@ href="{% static 'sharing/sharing.css' %}"/> {% endblock %} -{% block content %} - - {% include "app-header.html" with icon_filename=icon_filename name=title description=description %} +{% block configuration %} + {{ block.super }}
[a-z0-9]+)/edit/$', EditShareView.as_view(), name='edit'), diff --git a/plinth/modules/sharing/views.py b/plinth/modules/sharing/views.py index 26c0b75b8..e317244fd 100644 --- a/plinth/modules/sharing/views.py +++ b/plinth/modules/sharing/views.py @@ -10,24 +10,22 @@ from django.shortcuts import redirect from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ from django.views.decorators.http import require_POST -from django.views.generic import FormView, TemplateView +from django.views.generic import FormView -from plinth import app as app_module from plinth.modules import sharing +from plinth.views import AppView from .forms import AddShareForm -class IndexView(TemplateView): - """View to show list of shares.""" +class SharingAppView(AppView): + """Sharing configuration page.""" + app_id = 'sharing' template_name = 'sharing.html' def get_context_data(self, **kwargs): """Return additional context for rendering the template.""" context = super().get_context_data(**kwargs) - app = app_module.App.get('sharing') - context['title'] = app.info.name - context['app_info'] = app.info context['shares'] = sharing.list_shares() return context