mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03: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>
114 lines
3.8 KiB
Python
114 lines
3.8 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
FreedomBox app for configuring ikiwiki.
|
|
"""
|
|
|
|
from django.contrib import messages
|
|
from django.shortcuts import redirect
|
|
from django.template.response import TemplateResponse
|
|
from django.urls import reverse_lazy
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from plinth import actions, views
|
|
from plinth.modules import ikiwiki
|
|
|
|
from .forms import IkiwikiCreateForm
|
|
|
|
|
|
class IkiwikiAppView(views.AppView):
|
|
"""Serve configuration page."""
|
|
app_id = 'ikiwiki'
|
|
template_name = 'ikiwiki_configure.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
"""Return the context data for rendering the template view."""
|
|
sites = ikiwiki.app.refresh_sites()
|
|
sites = [name for name in sites if name != '']
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
context['sites'] = sites
|
|
return context
|
|
|
|
|
|
def create(request):
|
|
"""Form to create a wiki or blog."""
|
|
form = None
|
|
|
|
if request.method == 'POST':
|
|
form = IkiwikiCreateForm(request.POST, prefix='ikiwiki')
|
|
if form.is_valid():
|
|
if form.cleaned_data['site_type'] == 'wiki':
|
|
_create_wiki(request, form.cleaned_data['name'],
|
|
form.cleaned_data['admin_name'],
|
|
form.cleaned_data['admin_password'])
|
|
elif form.cleaned_data['site_type'] == 'blog':
|
|
_create_blog(request, form.cleaned_data['name'],
|
|
form.cleaned_data['admin_name'],
|
|
form.cleaned_data['admin_password'])
|
|
|
|
ikiwiki.app.refresh_sites()
|
|
if ikiwiki.app.is_enabled():
|
|
ikiwiki.app.set_enabled(True)
|
|
|
|
return redirect(reverse_lazy('ikiwiki:index'))
|
|
else:
|
|
form = IkiwikiCreateForm(prefix='ikiwiki')
|
|
|
|
return TemplateResponse(request, 'ikiwiki_create.html', {
|
|
'title': ikiwiki.app.info.name,
|
|
'form': form
|
|
})
|
|
|
|
|
|
def _create_wiki(request, name, admin_name, admin_password):
|
|
"""Create wiki."""
|
|
try:
|
|
actions.superuser_run(
|
|
'ikiwiki',
|
|
['create-wiki', '--wiki_name', name, '--admin_name', admin_name],
|
|
input=admin_password.encode())
|
|
messages.success(request, _('Created wiki {name}.').format(name=name))
|
|
except actions.ActionError as error:
|
|
messages.error(request,
|
|
_('Could not create wiki: {error}').format(error=error))
|
|
|
|
|
|
def _create_blog(request, name, admin_name, admin_password):
|
|
"""Create blog."""
|
|
try:
|
|
actions.superuser_run(
|
|
'ikiwiki',
|
|
['create-blog', '--blog_name', name, '--admin_name', admin_name],
|
|
input=admin_password.encode())
|
|
messages.success(request, _('Created blog {name}.').format(name=name))
|
|
except actions.ActionError as error:
|
|
messages.error(request,
|
|
_('Could not create blog: {error}').format(error=error))
|
|
|
|
|
|
def delete(request, name):
|
|
"""Handle deleting wikis/blogs, showing a confirmation dialog first.
|
|
|
|
On GET, display a confirmation page.
|
|
On POST, delete the wiki/blog.
|
|
"""
|
|
title = ikiwiki.app.components['shortcut-ikiwiki-' + name].name
|
|
if request.method == 'POST':
|
|
try:
|
|
actions.superuser_run('ikiwiki', ['delete', '--name', name])
|
|
ikiwiki.app.remove_shortcut(name)
|
|
messages.success(request,
|
|
_('{title} deleted.').format(title=title))
|
|
except actions.ActionError as error:
|
|
messages.error(
|
|
request,
|
|
_('Could not delete {title}: {error}').format(
|
|
title=title, error=error))
|
|
|
|
return redirect(reverse_lazy('ikiwiki:index'))
|
|
|
|
return TemplateResponse(request, 'ikiwiki_delete.html', {
|
|
'title': ikiwiki.app.info.name,
|
|
'name': title
|
|
})
|