diff --git a/plinth/modules/owncloud/__init__.py b/plinth/modules/owncloud/__init__.py
index 543909e21..29d77934e 100644
--- a/plinth/modules/owncloud/__init__.py
+++ b/plinth/modules/owncloud/__init__.py
@@ -19,15 +19,60 @@
Plinth module to configure ownCloud
"""
-from . import owncloud
-from .owncloud import init
+from django.utils.translation import ugettext_lazy as _
+from plinth import actions
from plinth import action_utils
+from plinth import cfg
+from plinth import service as service_module
-__all__ = ['owncloud', 'init']
+version = 1
depends = ['apps']
+title = _('File Hosting (ownCloud)')
+
+description = [
+ _('ownCloud gives you universal access to your files through a web '
+ 'interface or WebDAV. It also provides a platform to easily view '
+ '& sync your contacts, calendars and bookmarks across all your '
+ 'devices and enables basic editing right on the web. Installation '
+ 'has minimal server requirements, doesn\'t need special '
+ 'permissions and is quick. ownCloud is extendable via a simple '
+ 'but powerful API for applications and plugins.'),
+
+ _('When enabled, the ownCloud installation will be available '
+ 'from /owncloud path on the web server. '
+ 'Visit this URL to set up the initial administration account for '
+ 'ownCloud.')
+]
+
+service = None
+
+
+def init():
+ """Initialize the ownCloud module"""
+ menu = cfg.main_menu.get('apps:index')
+ menu.add_urlname(title, 'glyphicon-picture', 'owncloud:index', 700)
+
+ global service
+ service = service_module.Service(
+ 'owncloud', title, ['http', 'https'], is_external=True,
+ enabled=is_enabled())
+
+
+def setup(helper, old_version=None):
+ """Install and configure the module."""
+ helper.install(['postgresql', 'php5-pgsql', 'owncloud'])
+ helper.call('post', actions.superuser_run, 'owncloud-setup', ['enable'])
+ helper.call('post', service.notify_enabled, None, True)
+
+
+def is_enabled():
+ """Return whether the module is enabled."""
+ output = actions.run('owncloud-setup', ['status'])
+ return 'enable' in output.split()
+
def diagnose():
"""Run diagnostics and return the results."""
diff --git a/plinth/modules/owncloud/forms.py b/plinth/modules/owncloud/forms.py
new file mode 100644
index 000000000..3ea4c6f8c
--- /dev/null
+++ b/plinth/modules/owncloud/forms.py
@@ -0,0 +1,30 @@
+#
+# 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
- {% blocktrans trimmed %} - ownCloud gives you universal access to your files through a web - interface or WebDAV. It also provides a platform to easily view - & sync your contacts, calendars and bookmarks across all your - devices and enables basic editing right on the web. Installation - has minimal server requirements, doesn't need special - permissions and is quick. ownCloud is extendable via a simple - but powerful API for applications and plugins. - {% endblocktrans %} -
- -- {% blocktrans trimmed %} - When enabled, the ownCloud installation will be available - from /owncloud path on the web server. - Visit this URL to set up the initial administration account for - ownCloud. - {% endblocktrans %} -
+{% block configuration %} {% include "diagnostics_button.html" with module="owncloud" %} diff --git a/plinth/modules/owncloud/urls.py b/plinth/modules/owncloud/urls.py index d69ac14ef..338ad6cc5 100644 --- a/plinth/modules/owncloud/urls.py +++ b/plinth/modules/owncloud/urls.py @@ -21,7 +21,7 @@ URLs for the ownCloud module from django.conf.urls import url -from . import owncloud as views +from . import views urlpatterns = [ diff --git a/plinth/modules/owncloud/owncloud.py b/plinth/modules/owncloud/views.py similarity index 63% rename from plinth/modules/owncloud/owncloud.py rename to plinth/modules/owncloud/views.py index 249054dbb..b2e77077b 100644 --- a/plinth/modules/owncloud/owncloud.py +++ b/plinth/modules/owncloud/views.py @@ -19,47 +19,15 @@ Plinth module for configuring ownCloud. """ -from django import forms from django.contrib import messages from django.template.response import TemplateResponse from django.utils.translation import ugettext_lazy as _ +from .forms import OwnCloudForm from plinth import actions -from plinth import cfg -from plinth import package -from plinth import service as service_module +from plinth.modules import owncloud -service = None - - -class OwnCloudForm(forms.Form): # pylint: disable-msg=W0232 - """ownCloud configuration form""" - enabled = forms.BooleanField(label=_('Enable ownCloud'), required=False) - - -def init(): - """Initialize the ownCloud module""" - menu = cfg.main_menu.get('apps:index') - menu.add_urlname(_('File Hosting (ownCloud)'), 'glyphicon-picture', - 'owncloud:index', 700) - - status = get_status() - - global service # pylint: disable-msg=W0603 - service = service_module.Service( - 'owncloud', _('ownCloud'), ['http', 'https'], is_external=True, - enabled=status['enabled']) - - -def on_install(): - """Tasks to run after package install.""" - actions.superuser_run('owncloud-setup', ['enable']) - service.notify_enabled(None, True) - - -@package.required(['postgresql', 'php5-pgsql', 'owncloud'], - on_install=on_install) def index(request): """Serve the ownCloud configuration page""" status = get_status() @@ -77,14 +45,14 @@ def index(request): form = OwnCloudForm(initial=status, prefix='owncloud') return TemplateResponse(request, 'owncloud.html', - {'title': _('ownCloud'), + {'title': owncloud.title, + 'description': owncloud.description, 'form': form}) def get_status(): """Return the current status""" - output = actions.run('owncloud-setup', ['status']) - return {'enabled': 'enable' in output.split()} + return {'enabled': owncloud.is_enabled()} def _apply_changes(request, old_status, new_status): @@ -104,4 +72,4 @@ def _apply_changes(request, old_status, new_status): # Send a signal to other modules that the service is # enabled/disabled - service.notify_enabled(None, new_status['enabled']) + owncloud.service.notify_enabled(None, new_status['enabled'])