Sunil Mohan Adapa affffddf36
roundcube: Add setting for local connection only
When this option is enabled, it would make the interface easy to work with. This
is likely what most users would want. Don't break things for users who have
already installed roundcube and ensure that local only is disable for them.

Tests:

- Install roundcube without the patch. Disable the app. Apply patch. Restart
service. Notice that roundcube is not re-enabled.

- Install roundcube without the patch. Apply patch. Restart service. Notice that
roundcube configuration /etc/roundcube/config.inc.php file has been updated and
include_once() at the end has been added. The file
/etc/roundcube/freedombox-config.php has been added. Local only option is
disabled.

- Install roundcube freshly with the patch. Local only option is enabled. Open
interface. Notice that server option is not presented.

- Disable local only option and notice that server field is shown in the
interface.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
[jvalleroy: Fix comment]
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-01-31 18:46:01 -05:00

35 lines
985 B
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Views for roundcube.
"""
from django.contrib import messages
from django.utils.translation import gettext_lazy as _
from plinth.modules import roundcube
from plinth.views import AppView
from .forms import RoundcubeForm
class RoundcubeAppView(AppView):
"""Roundcube configuration page."""
app_id = 'roundcube'
form_class = RoundcubeForm
def get_initial(self):
"""Return the values to fill in the form."""
initial = super().get_initial()
initial['local_only'] = roundcube.get_config()['local_only']
return initial
def form_valid(self, form):
"""Change the config of Roundcube app."""
old_data = form.initial
data = form.cleaned_data
if old_data['local_only'] != data['local_only']:
roundcube.set_config(data['local_only'])
messages.success(self.request, _('Configuration updated'))
return super().form_valid(form)