mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-25 08:43:36 +00:00
- Introduce new API to mark an app that it can't be disabled. - Mark jsxc, storage, config, upgrade and firewall apps as can't be disabled. - Fixed functional tests - Replaced AppForm with forms.Form in all modules' forms.py. - Remove app.template.js. - Remove unused styles. - Remove app status checks in form_valid of Deluge, Diaspora, Matrix, Ejabberd, MediaWiki, Storage, Transmission, Quassel - Purge unused is_enabled context variables (Ikiwiki) - ejabberd: Minor cleanup in template - jsxc: Cleanup unneeded overrides - tahoe: Cleanup unnecessary overrides Tests performed: - For all apps affected, test enable/disable button works and submitting configuration form works: with changes updates message and without changes 'settings unchanged' message. - avahi - bind - cockpit - SKIP: coquelicot - datetime - deluge - SKIP: diaspora - ejabberd - gitweb - i2p - infinoted - ikiwiki - matrixsynapse - mediawiki - minetest - minidlna - mldonkey - mumble - pagekite - privoxy - quassel - radicale - roundcube - SKIP: samba - searx - SKIP: shaarli - shadowsocks - ssh - tahoe - transmission - FAIL: tt-rss (not installable) - wireguard - Deluge test that configuration changes when app is disabled work - Quassel test that setting the domain works when app is diabled - Transmission test that setting the domain works when app is diabled - Ikiwiki create form works properly - Enable/disable button appears as expected when enabled and when disabled - Enable/disable button works without Javascript - Functional tests work for affected apps, Tor and OpenVPN - AppForm is removed from developer documentation - Forms reference - Customizing tutorial - Test all apps using directory select form - Transmission - Deluge - Visit each template that overrides block configuration and ensure that it is loaded properly and the display is as expected. - All apps that use AppView that are not tested above should not have an enable/disable button. That is JSXC, update, config, firewall, storage, users. Signed-off-by: Alice Kile <buoyantair@protonmail.com> Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Veiko Aasa <veiko17@disroot.org>
81 lines
2.7 KiB
Python
81 lines
2.7 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Views for the diaspora module
|
|
"""
|
|
|
|
from django.contrib import messages
|
|
from django.shortcuts import redirect
|
|
from django.urls import reverse_lazy
|
|
from django.utils.translation import ugettext as _
|
|
from django.views.generic import FormView
|
|
|
|
from plinth.forms import DomainSelectionForm
|
|
from plinth.modules import diaspora, names
|
|
from plinth.views import AppView
|
|
|
|
from .forms import DiasporaAppForm
|
|
|
|
|
|
class DiasporaSetupView(FormView):
|
|
"""Show diaspora setup page."""
|
|
template_name = 'diaspora-pre-setup.html'
|
|
form_class = DomainSelectionForm
|
|
description = diaspora.app.info.description
|
|
title = diaspora.app.info.name
|
|
success_url = reverse_lazy('diaspora:index')
|
|
|
|
def form_valid(self, form):
|
|
domain_name = form.cleaned_data['domain_name']
|
|
diaspora.setup_domain_name(domain_name)
|
|
|
|
return super().form_valid(form)
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context['description'] = self.description
|
|
context['title'] = self.title
|
|
context['domain_names'] = names.components.DomainName.list_names(
|
|
'https')
|
|
|
|
return context
|
|
|
|
|
|
class DiasporaAppView(AppView):
|
|
"""Show diaspora service page."""
|
|
form_class = DiasporaAppForm
|
|
app_id = 'diaspora'
|
|
template_name = 'diaspora-post-setup.html'
|
|
|
|
def dispatch(self, request, *args, **kwargs):
|
|
if not diaspora.is_setup():
|
|
return redirect('diaspora:setup')
|
|
return super().dispatch(request, *args, **kwargs)
|
|
|
|
def get_context_data(self, *args, **kwargs):
|
|
context = super().get_context_data(**kwargs)
|
|
context['domain_name'] = diaspora.get_configured_domain_name()
|
|
return context
|
|
|
|
def get_initial(self):
|
|
"""Return the status of the service to fill in the form."""
|
|
status = super().get_initial()
|
|
status['is_user_registrations_enabled'] = \
|
|
diaspora.is_user_registrations_enabled()
|
|
return status
|
|
|
|
def form_valid(self, form):
|
|
"""Enable/disable user registrations"""
|
|
old_registration = form.initial['is_user_registrations_enabled']
|
|
new_registration = form.cleaned_data['is_user_registrations_enabled']
|
|
|
|
if old_registration != new_registration:
|
|
if new_registration:
|
|
diaspora.enable_user_registrations()
|
|
messages.success(self.request, _('User registrations enabled'))
|
|
else:
|
|
diaspora.disable_user_registrations()
|
|
messages.success(self.request,
|
|
_('User registrations disabled'))
|
|
|
|
return super().form_valid(form)
|