mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
owncloud: Use new setup mechanism
- Also reorganize views.
This commit is contained in:
parent
b916d95a0b
commit
166ff9b5bf
@ -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 <a href="/owncloud">/owncloud</a> 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."""
|
||||
|
||||
30
plinth/modules/owncloud/forms.py
Normal file
30
plinth/modules/owncloud/forms.py
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Forms for configuring ownCloud.
|
||||
"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class OwnCloudForm(forms.Form): # pylint: disable-msg=W0232
|
||||
"""ownCloud configuration form"""
|
||||
enabled = forms.BooleanField(
|
||||
label=_('Enable ownCloud'),
|
||||
required=False)
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "app.html" %}
|
||||
{% comment %}
|
||||
#
|
||||
# This file is part of Plinth.
|
||||
@ -21,30 +21,7 @@
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "File Hosting (ownCloud)" %}</h2>
|
||||
|
||||
<p>
|
||||
{% 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 %}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
When enabled, the ownCloud installation will be available
|
||||
from <a href="/owncloud">/owncloud</a> path on the web server.
|
||||
Visit this URL to set up the initial administration account for
|
||||
ownCloud.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
{% block configuration %}
|
||||
|
||||
{% include "diagnostics_button.html" with module="owncloud" %}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ URLs for the ownCloud module
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
from . import owncloud as views
|
||||
from . import views
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
|
||||
@ -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'])
|
||||
Loading…
x
Reference in New Issue
Block a user