Alice Kile 0b5b384651
app: Separate app enable/disable form from config form
- 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>
2020-03-29 09:42:31 +03:00

89 lines
2.8 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
FreedomBox app to configure XMPP web client/jsxc.
"""
import logging
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from plinth import app as app_module
from plinth import frontpage, menu
from plinth.modules.firewall.components import Firewall
from plinth.web_server import StaticFiles
from .manifest import backup, clients # noqa, pylint: disable=unused-import
version = 1
managed_packages = ['libjs-jsxc']
_description = [
_('JSXC is a web client for XMPP. Typically it is used with an XMPP '
'server running locally.'),
]
logger = logging.getLogger(__name__)
app = None
class JSXCApp(app_module.App):
"""FreedomBox app for JSXC."""
app_id = 'jsxc'
can_be_disabled = False
def __init__(self):
"""Create components for the app."""
super().__init__()
info = app_module.Info(app_id=self.app_id, version=version,
name=_('JSXC'), icon_filename='jsxc',
short_description=_('Chat Client'),
description=_description, clients=clients)
self.add(info)
menu_item = menu.Menu('menu-jsxc', info.name, info.short_description,
info.icon_filename, 'jsxc:index',
parent_url_name='apps')
self.add(menu_item)
shortcut = frontpage.Shortcut('shortcut-jsxc', name=info.name,
short_description=info.short_description,
icon=info.icon_filename,
url=reverse_lazy('jsxc:jsxc'),
clients=info.clients)
self.add(shortcut)
firewall = Firewall('firewall-jsxc', info.name,
ports=['http', 'https'], is_external=True)
self.add(firewall)
directory_map = {
'/static/jsxc/img': '/usr/share/libjs-jsxc/img/',
'/static/jsxc/libjs-jsxc/lib': '/usr/share/javascript/jsxc/lib/',
'/static/jsxc/libjs-jsxc/sound': '/usr/share/libjs-jsxc/sound/',
'/static/jsxc/libjs-jsxc/': '/usr/share/libjs-jsxc/css/',
}
static_files = StaticFiles('static-files-jsxc',
directory_map=directory_map)
self.add(static_files)
def init():
"""Initialize the JSXC module"""
global app
app = JSXCApp()
setup_helper = globals()['setup_helper']
if setup_helper.get_state() != 'needs-setup' and app.is_enabled():
app.set_enabled(True)
def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(managed_packages)
helper.call('post', app.enable)