mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
Tests: - Functional tests work - When the app is enabled, if the log path does not exist, it is created /var/log/radicale. - Not tested: upgrading from older version to 3.x - Setting the access rights works. It is reflected in the app page and configuration file /etc/radicale/config. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Views for radicale module.
|
|
"""
|
|
|
|
from django.contrib import messages
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from plinth.views import AppView
|
|
|
|
from . import get_rights_value, privileged
|
|
from .forms import RadicaleForm
|
|
|
|
|
|
class RadicaleAppView(AppView):
|
|
"""A specialized view for configuring radicale service."""
|
|
form_class = RadicaleForm
|
|
app_id = 'radicale'
|
|
|
|
def get_initial(self):
|
|
"""Return the values to fill in the form."""
|
|
initial = super().get_initial()
|
|
initial['access_rights'] = get_rights_value()
|
|
return initial
|
|
|
|
def form_valid(self, form):
|
|
"""Change the access control of Radicale service."""
|
|
data = form.cleaned_data
|
|
if get_rights_value() != data['access_rights']:
|
|
privileged.configure(data['access_rights'])
|
|
messages.success(self.request,
|
|
_('Access rights configuration updated'))
|
|
return super().form_valid(form)
|