radicale: New module for a CalDAV/CardDAV server

This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2016-02-26 15:40:19 +05:30
1 parent 6c67a50e11
commit 9d85084d8d
9 files changed
+390

No files matched your search

+62
View File
@@ -0,0 +1,62 @@
#
# 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/>.
#
"""
Plinth module for radicale.
"""
from django.utils.translation import ugettext_lazy as _
from plinth import action_utils
from plinth import cfg
from plinth import service as service_module
depends = ['plinth.modules.apps']
service = None
def init():
"""Initialize the radicale module."""
menu = cfg.main_menu.get('apps:index')
menu.add_urlname(_('Calendar and Addressbook (Radicale)'),
'glyphicon-calendar', 'radicale:index', 375)
global service
service = service_module.Service(
'radicale-plinth', _('Radicale CalDAV and CardDAV Server'),
is_external=True, enabled=is_enabled())
def is_enabled():
"""Return whether the service is enabled."""
return action_utils.service_is_enabled('radicale')
def is_running():
"""Return whether the service is running."""
return action_utils.service_is_running('radicale')
def diagnose():
"""Run diagnostics and return the results."""
results = []
results.extend(action_utils.diagnose_url_on_all(
'https://{host}/radicale', extra_options=['--no-check-certificate']))
return results
+30
View 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 radicale module.
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
class RadicaleForm(forms.Form):
"""Radicale configuration form."""
enabled = forms.BooleanField(
label=_('Enable Radicale service'),
required=False)
@@ -0,0 +1,65 @@
{% 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 <http://www.gnu.org/licenses/>.
#
{% endcomment %}
{% load bootstrap %}
{% load i18n %}
{% block content %}
<h2>{% trans "Calendar and Addressbook (Radicale)" %}</h2>
<p>
{% blocktrans trimmed %}
Radicale is a CalDAV and CardDAV server. It allows synchronization and
sharing of scheduling and contact data. To use Radicale, a
<a href=
"http://radicale.org/user_documentation/#idcaldav-and-carddav-clients">
supported client application</a> is needed. Radicale can be accessed by
any user with a {{ box_name }} login.
{% endblocktrans %}
</p>
<h3>{% trans "Status" %}</h3>
<p class="running-status-parent">
{% if status.is_running %}
<span class="running-status active"></span>
{% trans "Radicale service is running" %}
{% else %}
<span class="running-status inactive"></span>
{% trans "Radicale service is not running" %}
{% endif %}
</p>
{% include "diagnostics_button.html" with module="radicale" %}
<h3>{% trans "Configuration" %}</h3>
<form class="form" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input type="submit" class="btn btn-primary"
value="{% trans "Update setup" %}"/>
</form>
{% endblock %}
Whitespace-only changes.
+29
View File
@@ -0,0 +1,29 @@
#
# 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/>.
#
"""
URLs for the radicale module.
"""
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^apps/radicale/$', views.index, name='index'),
]
+79
View File
@@ -0,0 +1,79 @@
#
# 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/>.
#
"""
Views for radicale module.
"""
from django.contrib import messages
from django.template.response import TemplateResponse
from django.utils.translation import ugettext as _
from .forms import RadicaleForm
from plinth import actions
from plinth import package
from plinth.modules import radicale
def on_install():
"""Notify that the service is now enabled."""
actions.superuser_run('radicale', ['setup'])
radicale.service.notify_enabled(None, True)
@package.required(['radicale'], on_install=on_install)
def index(request):
"""Serve configuration page."""
status = get_status()
form = None
if request.method == 'POST':
form = RadicaleForm(request.POST, prefix='radicale')
if form.is_valid():
_apply_changes(request, status, form.cleaned_data)
status = get_status()
form = RadicaleForm(initial=status, prefix='radicale')
else:
form = RadicaleForm(initial=status, prefix='radicale')
return TemplateResponse(request, 'radicale.html',
{'title': _('Calendar and Addressbook (Radicale)'),
'status': status,
'form': form})
def get_status():
"""Get the current service status."""
return {'enabled': radicale.is_enabled(),
'is_running': radicale.is_running()}
def _apply_changes(request, old_status, new_status):
"""Apply the changes."""
modified = False
if old_status['enabled'] != new_status['enabled']:
sub_command = 'enable' if new_status['enabled'] else 'disable'
actions.superuser_run('radicale', [sub_command])
radicale.service.notify_enabled(None, new_status['enabled'])
modified = True
if modified:
messages.success(request, _('Configuration updated'))
else:
messages.info(request, _('Setting unchanged'))