mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Add clients to ServiceView
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d3cddfa68c
commit
efa575b204
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
URLs for the Deluge module.
|
||||
"""
|
||||
@ -24,11 +23,12 @@ from django.conf.urls import url
|
||||
from plinth.modules import deluge
|
||||
from plinth.views import ServiceView
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/deluge/$', ServiceView.as_view(
|
||||
url(r'^apps/deluge/$',
|
||||
ServiceView.as_view(
|
||||
description=deluge.description,
|
||||
diagnostics_module_name="deluge",
|
||||
service_id=deluge.managed_services[0]
|
||||
), name='index'),
|
||||
clients=deluge.clients,
|
||||
service_id=deluge.managed_services[0]),
|
||||
name='index'),
|
||||
]
|
||||
|
||||
@ -70,17 +70,18 @@ class DiasporaServiceView(ServiceView):
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['domain_name'] = diaspora.get_configured_domain_name()
|
||||
context['clients'] = diaspora.clients
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the status of the service to fill in the form."""
|
||||
return {
|
||||
'is_enabled':
|
||||
self.service.is_enabled(),
|
||||
self.service.is_enabled(),
|
||||
'is_user_registrations_enabled':
|
||||
diaspora.is_user_registrations_enabled(),
|
||||
diaspora.is_user_registrations_enabled(),
|
||||
'is_running':
|
||||
self.service.is_running()
|
||||
self.service.is_running()
|
||||
}
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for configuring ikiwiki
|
||||
"""
|
||||
@ -32,13 +31,16 @@ from plinth.modules import ikiwiki
|
||||
|
||||
from .forms import IkiwikiCreateForm
|
||||
|
||||
|
||||
subsubmenu = [{'url': reverse_lazy('ikiwiki:index'),
|
||||
'text': ugettext_lazy('Configure')},
|
||||
{'url': reverse_lazy('ikiwiki:manage'),
|
||||
'text': ugettext_lazy('Manage')},
|
||||
{'url': reverse_lazy('ikiwiki:create'),
|
||||
'text': ugettext_lazy('Create')}]
|
||||
subsubmenu = [{
|
||||
'url': reverse_lazy('ikiwiki:index'),
|
||||
'text': ugettext_lazy('Configure')
|
||||
}, {
|
||||
'url': reverse_lazy('ikiwiki:manage'),
|
||||
'text': ugettext_lazy('Manage')
|
||||
}, {
|
||||
'url': reverse_lazy('ikiwiki:create'),
|
||||
'text': ugettext_lazy('Create')
|
||||
}]
|
||||
|
||||
|
||||
class IkiwikiServiceView(views.ServiceView):
|
||||
@ -52,6 +54,7 @@ class IkiwikiServiceView(views.ServiceView):
|
||||
"""Return the context data for rendering the template view."""
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['subsubmenu'] = subsubmenu
|
||||
context['clients'] = ikiwiki.clients
|
||||
return context
|
||||
|
||||
|
||||
@ -60,10 +63,11 @@ def manage(request):
|
||||
sites = actions.run('ikiwiki', ['get-sites']).split('\n')
|
||||
sites = [name for name in sites if name != '']
|
||||
|
||||
return TemplateResponse(request, 'ikiwiki_manage.html',
|
||||
{'title': _('Manage Wikis and Blogs'),
|
||||
'subsubmenu': subsubmenu,
|
||||
'sites': sites})
|
||||
return TemplateResponse(request, 'ikiwiki_manage.html', {
|
||||
'title': _('Manage Wikis and Blogs'),
|
||||
'subsubmenu': subsubmenu,
|
||||
'sites': sites
|
||||
})
|
||||
|
||||
|
||||
def create(request):
|
||||
@ -84,17 +88,21 @@ def create(request):
|
||||
|
||||
site = form.cleaned_data['name'].replace(' ', '')
|
||||
frontpage.add_shortcut(
|
||||
'ikiwiki_' + site, site, url='/ikiwiki/' + site,
|
||||
login_required=False, icon='ikiwiki')
|
||||
'ikiwiki_' + site,
|
||||
site,
|
||||
url='/ikiwiki/' + site,
|
||||
login_required=False,
|
||||
icon='ikiwiki')
|
||||
|
||||
return redirect(reverse_lazy('ikiwiki:manage'))
|
||||
else:
|
||||
form = IkiwikiCreateForm(prefix='ikiwiki')
|
||||
|
||||
return TemplateResponse(request, 'ikiwiki_create.html',
|
||||
{'title': _('Create Wiki or Blog'),
|
||||
'form': form,
|
||||
'subsubmenu': subsubmenu})
|
||||
return TemplateResponse(request, 'ikiwiki_create.html', {
|
||||
'title': _('Create Wiki or Blog'),
|
||||
'form': form,
|
||||
'subsubmenu': subsubmenu
|
||||
})
|
||||
|
||||
|
||||
def _create_wiki(request, name, admin_name, admin_password):
|
||||
@ -102,13 +110,12 @@ def _create_wiki(request, name, admin_name, admin_password):
|
||||
try:
|
||||
actions.superuser_run(
|
||||
'ikiwiki',
|
||||
['create-wiki', '--wiki_name', name,
|
||||
'--admin_name', admin_name],
|
||||
['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))
|
||||
messages.error(
|
||||
request, _('Could not create wiki: {error}').format(error=error))
|
||||
|
||||
|
||||
def _create_blog(request, name, admin_name, admin_password):
|
||||
@ -116,13 +123,12 @@ def _create_blog(request, name, admin_name, admin_password):
|
||||
try:
|
||||
actions.superuser_run(
|
||||
'ikiwiki',
|
||||
['create-blog', '--blog_name', name,
|
||||
'--admin_name', admin_name],
|
||||
['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))
|
||||
messages.error(
|
||||
request, _('Could not create blog: {error}').format(error=error))
|
||||
|
||||
|
||||
def delete(request, name):
|
||||
@ -137,12 +143,14 @@ def delete(request, name):
|
||||
messages.success(request, _('{name} deleted.').format(name=name))
|
||||
frontpage.remove_shortcut('ikiwiki_' + name)
|
||||
except actions.ActionError as error:
|
||||
messages.error(request, _('Could not delete {name}: {error}')
|
||||
.format(name=name, error=error))
|
||||
messages.error(request,
|
||||
_('Could not delete {name}: {error}').format(
|
||||
name=name, error=error))
|
||||
|
||||
return redirect(reverse_lazy('ikiwiki:manage'))
|
||||
|
||||
return TemplateResponse(request, 'ikiwiki_delete.html',
|
||||
{'title': _('Delete Wiki or Blog'),
|
||||
'subsubmenu': subsubmenu,
|
||||
'name': name})
|
||||
return TemplateResponse(request, 'ikiwiki_delete.html', {
|
||||
'title': _('Delete Wiki or Blog'),
|
||||
'subsubmenu': subsubmenu,
|
||||
'name': name
|
||||
})
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for infinoted.
|
||||
"""
|
||||
@ -32,7 +31,6 @@ from plinth.utils import format_lazy
|
||||
from plinth.views import ServiceView
|
||||
from .manifest import clients
|
||||
|
||||
|
||||
version = 1
|
||||
|
||||
service = None
|
||||
@ -47,7 +45,6 @@ short_description = _('Gobby Server')
|
||||
|
||||
description = [
|
||||
_('infinoted is a server for Gobby, a collaborative text editor.'),
|
||||
|
||||
format_lazy(
|
||||
_('To use it, <a href="https://gobby.github.io/">download Gobby</a>, '
|
||||
'desktop client and install it. Then start Gobby and select '
|
||||
@ -55,21 +52,25 @@ description = [
|
||||
box_name=_(cfg.box_name)),
|
||||
]
|
||||
|
||||
|
||||
clients = clients
|
||||
|
||||
|
||||
def init():
|
||||
"""Initialize the infinoted module."""
|
||||
menu = main_menu.get('apps')
|
||||
menu.add_urlname(name, 'glyphicon-pencil', 'infinoted:index', short_description)
|
||||
menu.add_urlname(name, 'glyphicon-pencil', 'infinoted:index',
|
||||
short_description)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
if setup_helper.get_state() != 'needs-setup':
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['infinoted-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['infinoted-plinth'],
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
@ -79,6 +80,7 @@ class InfinotedServiceView(ServiceView):
|
||||
service_id = managed_services[0]
|
||||
diagnostics_module_name = "infinoted"
|
||||
description = description
|
||||
clients = clients
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@ -88,19 +90,26 @@ def setup(helper, old_version=None):
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['infinoted-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['infinoted-plinth'],
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('infinoted', name,
|
||||
short_description=short_description, url=None,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('infinoted:index'),
|
||||
login_required=False)
|
||||
frontpage.add_shortcut(
|
||||
'infinoted',
|
||||
name,
|
||||
short_description=short_description,
|
||||
url=None,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('infinoted:index'),
|
||||
login_required=False)
|
||||
|
||||
|
||||
def enable():
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Views for the JSXC module
|
||||
"""
|
||||
@ -33,6 +32,7 @@ class JSXCServiceView(ServiceView):
|
||||
template_name = 'jsxc.html'
|
||||
description = jsxc.description
|
||||
show_status_block = False
|
||||
clients = jsxc.clients
|
||||
|
||||
|
||||
class JsxcView(TemplateView):
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Views for the Matrix Synapse module.
|
||||
"""
|
||||
@ -79,13 +78,15 @@ class MatrixSynapseServiceView(ServiceView):
|
||||
"""Add additional context data for template."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['domain_name'] = matrixsynapse.get_configured_domain_name()
|
||||
context['clients'] = matrixsynapse.clients
|
||||
return context
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the values to fill in the form."""
|
||||
initial = super().get_initial()
|
||||
initial.update({
|
||||
'enable_public_registration': get_public_registration_status()})
|
||||
'enable_public_registration': get_public_registration_status()
|
||||
})
|
||||
return initial
|
||||
|
||||
def form_valid(self, form):
|
||||
@ -112,13 +113,13 @@ class MatrixSynapseServiceView(ServiceView):
|
||||
if not pubreg_same:
|
||||
# note action public_registration restarts, if running now
|
||||
if new_config['enable_public_registration']:
|
||||
actions.superuser_run('matrixsynapse', ['public_registration',
|
||||
'enable'])
|
||||
actions.superuser_run('matrixsynapse',
|
||||
['public_registration', 'enable'])
|
||||
messages.success(self.request,
|
||||
_('Public registration enabled'))
|
||||
else:
|
||||
actions.superuser_run('matrixsynapse', ['public_registration',
|
||||
'disable'])
|
||||
actions.superuser_run('matrixsynapse',
|
||||
['public_registration', 'disable'])
|
||||
messages.success(self.request,
|
||||
_('Public registration disabled'))
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Views for minetest module.
|
||||
"""
|
||||
@ -23,20 +22,21 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import minetest
|
||||
from plinth.views import ServiceView
|
||||
|
||||
|
||||
from . import description, managed_services, get_configuration
|
||||
from .forms import MinetestForm
|
||||
|
||||
|
||||
class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
|
||||
class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
|
||||
"""A specialized view for configuring minetest."""
|
||||
service_id = managed_services[0]
|
||||
diagnostics_module_name = "minetest"
|
||||
description = description
|
||||
show_status_block = True
|
||||
form_class = MinetestForm
|
||||
clients = minetest.clients
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the values to fill in the form."""
|
||||
@ -51,34 +51,30 @@ class MinetestServiceView(ServiceView): # pylint: disable=too-many-ancestors
|
||||
|
||||
if old_config['max_players'] != data['max_players'] \
|
||||
and data['max_players'] != None:
|
||||
actions.superuser_run(
|
||||
'minetest',
|
||||
['configure', '--max_players', str(data['max_players'])])
|
||||
actions.superuser_run('minetest', [
|
||||
'configure', '--max_players',
|
||||
str(data['max_players'])
|
||||
])
|
||||
messages.success(self.request,
|
||||
_('Maximum players configuration updated'))
|
||||
|
||||
if old_config['creative_mode'] != data['creative_mode']:
|
||||
value = 'true' if data['creative_mode'] else 'false'
|
||||
actions.superuser_run(
|
||||
'minetest',
|
||||
['configure', '--creative_mode', value])
|
||||
actions.superuser_run('minetest',
|
||||
['configure', '--creative_mode', value])
|
||||
messages.success(self.request,
|
||||
_('Creative mode configuration updated'))
|
||||
|
||||
if old_config['enable_pvp'] != data['enable_pvp']:
|
||||
value = 'true' if data['enable_pvp'] else 'false'
|
||||
actions.superuser_run(
|
||||
'minetest',
|
||||
['configure', '--enable_pvp', value])
|
||||
messages.success(self.request,
|
||||
_('PVP configuration updated'))
|
||||
actions.superuser_run('minetest',
|
||||
['configure', '--enable_pvp', value])
|
||||
messages.success(self.request, _('PVP configuration updated'))
|
||||
|
||||
if old_config['enable_damage'] != data['enable_damage']:
|
||||
value = 'true' if data['enable_damage'] else 'false'
|
||||
actions.superuser_run(
|
||||
'minetest',
|
||||
['configure', '--enable_damage', value])
|
||||
messages.success(self.request,
|
||||
_('Damage configuration updated'))
|
||||
actions.superuser_run('minetest',
|
||||
['configure', '--enable_damage', value])
|
||||
messages.success(self.request, _('Damage configuration updated'))
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module to configure Mumble server
|
||||
"""
|
||||
@ -30,7 +29,6 @@ from plinth.menu import main_menu
|
||||
from plinth.views import ServiceView
|
||||
from .manifest import clients
|
||||
|
||||
|
||||
version = 1
|
||||
|
||||
name = _('Mumble')
|
||||
@ -46,7 +44,6 @@ managed_packages = ['mumble-server']
|
||||
description = [
|
||||
_('Mumble is an open source, low-latency, encrypted, high quality '
|
||||
'voice chat software.'),
|
||||
|
||||
_('You can connect to your Mumble server on the regular Mumble port '
|
||||
'64738. <a href="http://mumble.info">Clients</a> to connect to Mumble '
|
||||
'from your desktop and Android devices are available.')
|
||||
@ -60,15 +57,19 @@ reserved_usernames = ['mumble-server']
|
||||
def init():
|
||||
"""Intialize the Mumble module."""
|
||||
menu = main_menu.get('apps')
|
||||
menu.add_urlname(name, 'glyphicon-headphones', 'mumble:index', short_description)
|
||||
menu.add_urlname(name, 'glyphicon-headphones', 'mumble:index',
|
||||
short_description)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
if setup_helper.get_state() != 'needs-setup':
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['mumble-plinth'],
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['mumble-plinth'],
|
||||
is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
@ -78,6 +79,7 @@ class MumbleServiceView(ServiceView):
|
||||
service_id = managed_services[0]
|
||||
diagnostics_module_name = "mumble"
|
||||
description = description
|
||||
clients = clients
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@ -86,19 +88,24 @@ def setup(helper, old_version=None):
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['mumble-plinth'],
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['mumble-plinth'],
|
||||
is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('mumble', name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('mumble:index'),
|
||||
login_required=False)
|
||||
frontpage.add_shortcut(
|
||||
'mumble',
|
||||
name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('mumble:index'),
|
||||
login_required=False)
|
||||
|
||||
|
||||
def enable():
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for Quassel.
|
||||
"""
|
||||
@ -52,8 +51,8 @@ description = [
|
||||
'the client is disconnected. {box_name} can run the Quassel '
|
||||
'core service keeping you always online and one or more Quassel '
|
||||
'clients from a desktop or a mobile can be used to connect and '
|
||||
'disconnect from it.'), box_name=_(cfg.box_name)),
|
||||
|
||||
'disconnect from it.'),
|
||||
box_name=_(cfg.box_name)),
|
||||
_('You can connect to your Quassel core on the default Quassel port '
|
||||
'4242. Clients to connect to Quassel from your '
|
||||
'<a href="http://quassel-irc.org/downloads">desktop</a> and '
|
||||
@ -69,14 +68,19 @@ reserved_usernames = ['quasselcore']
|
||||
def init():
|
||||
"""Initialize the quassel module."""
|
||||
menu = main_menu.get('apps')
|
||||
menu.add_urlname(name, 'glyphicon-retweet', 'quassel:index', short_description)
|
||||
menu.add_urlname(name, 'glyphicon-retweet', 'quassel:index',
|
||||
short_description)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
if setup_helper.get_state() != 'needs-setup':
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['quassel-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['quassel-plinth'],
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
@ -86,6 +90,7 @@ class QuasselServiceView(ServiceView):
|
||||
service_id = managed_services[0]
|
||||
diagnostics_module_name = "quassel"
|
||||
description = description
|
||||
clients = clients
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@ -94,18 +99,24 @@ def setup(helper, old_version=None):
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], name, ports=['quassel-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['quassel-plinth'],
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('quassel', name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('quassel:index'),
|
||||
login_required=True)
|
||||
frontpage.add_shortcut(
|
||||
'quassel',
|
||||
name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('quassel:index'),
|
||||
login_required=True)
|
||||
|
||||
|
||||
def enable():
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Views for radicale module.
|
||||
"""
|
||||
@ -23,6 +22,7 @@ from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import radicale
|
||||
from plinth.views import ServiceView
|
||||
|
||||
from . import description, get_rights_value, managed_services
|
||||
@ -31,10 +31,11 @@ from .forms import RadicaleForm
|
||||
|
||||
class RadicaleServiceView(ServiceView):
|
||||
"""A specialized view for configuring radicale service."""
|
||||
service_id = managed_services[0]
|
||||
form_class = RadicaleForm
|
||||
diagnostics_module_name = 'radicale'
|
||||
clients = radicale.clients
|
||||
description = description
|
||||
diagnostics_module_name = 'radicale'
|
||||
form_class = RadicaleForm
|
||||
service_id = managed_services[0]
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the values to fill in the form."""
|
||||
@ -46,9 +47,9 @@ class RadicaleServiceView(ServiceView):
|
||||
"""Change the access control of Radicale service."""
|
||||
data = form.cleaned_data
|
||||
if get_rights_value() != data['access_rights']:
|
||||
actions.superuser_run(
|
||||
'radicale',
|
||||
['configure', '--rights_type', data['access_rights']])
|
||||
actions.superuser_run('radicale', [
|
||||
'configure', '--rights_type', data['access_rights']
|
||||
])
|
||||
messages.success(self.request,
|
||||
_('Access rights configuration updated'))
|
||||
return super().form_valid(form)
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for repro.
|
||||
"""
|
||||
@ -47,12 +46,10 @@ description = [
|
||||
'can use to let their presence known. It also acts as a proxy to '
|
||||
'federate SIP communications to other servers on the Internet similar '
|
||||
'to email.'),
|
||||
|
||||
_('To make SIP calls, a client application is needed. Available clients '
|
||||
'include <a href="https://jitsi.org/">Jitsi</a> (for computers) and '
|
||||
'<a href="https://f-droid.org/repository/browse/?fdid=com.csipsimple"> '
|
||||
'CSipSimple</a> (for Android phones).'),
|
||||
|
||||
_('<strong>Note:</strong> Before using repro, domains and users will '
|
||||
'need to be configured using the <a href="/repro/domains.html">'
|
||||
'web-based configuration panel</a>. Users in the <em>admin</em> group '
|
||||
@ -71,24 +68,29 @@ service = None
|
||||
def init():
|
||||
"""Initialize the repro module."""
|
||||
menu = main_menu.get('apps')
|
||||
menu.add_urlname(name, 'glyphicon-phone-alt', 'repro:index', short_description)
|
||||
menu.add_urlname(name, 'glyphicon-phone-alt', 'repro:index',
|
||||
short_description)
|
||||
|
||||
global service
|
||||
setup_helper = globals()['setup_helper']
|
||||
if setup_helper.get_state() != 'needs-setup':
|
||||
service = service_module.Service(
|
||||
managed_services[0], name,
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['sip', 'sips', 'rtp-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
class ReproServiceView(ServiceView):
|
||||
service_id = managed_services[0]
|
||||
diagnostics_module_name = "repro"
|
||||
clients = clients
|
||||
description = description
|
||||
diagnostics_module_name = "repro"
|
||||
service_id = managed_services[0]
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@ -98,19 +100,24 @@ def setup(helper, old_version=None):
|
||||
global service
|
||||
if service is None:
|
||||
service = service_module.Service(
|
||||
managed_services[0], name,
|
||||
managed_services[0],
|
||||
name,
|
||||
ports=['sip', 'sips', 'rtp-plinth'],
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
is_external=True,
|
||||
enable=enable,
|
||||
disable=disable)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('repro', name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('repro:index'),
|
||||
login_required=True)
|
||||
frontpage.add_shortcut(
|
||||
'repro',
|
||||
name,
|
||||
short_description=short_description,
|
||||
details=description,
|
||||
configure_url=reverse_lazy('repro:index'),
|
||||
login_required=True)
|
||||
|
||||
|
||||
def enable():
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
URLs for the reStore module.
|
||||
"""
|
||||
@ -24,10 +23,11 @@ from django.conf.urls import url
|
||||
from plinth.views import ServiceView
|
||||
from plinth.modules import restore
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/restore/$', ServiceView.as_view(
|
||||
url(r'^apps/restore/$',
|
||||
ServiceView.as_view(
|
||||
service_id=restore.managed_services[0],
|
||||
description=restore.description
|
||||
), name='index'),
|
||||
description=restore.description,
|
||||
clients=restore.clients),
|
||||
name='index'),
|
||||
]
|
||||
|
||||
@ -29,6 +29,7 @@ urlpatterns = [
|
||||
service_id=syncthing.managed_services[0],
|
||||
diagnostics_module_name='syncthing',
|
||||
description=syncthing.description,
|
||||
clients=syncthing.clients,
|
||||
show_status_block=True),
|
||||
name='index'),
|
||||
]
|
||||
|
||||
@ -32,6 +32,8 @@
|
||||
|
||||
{% block configuration %}
|
||||
|
||||
{% include "clients.html" with clients=clients %}
|
||||
|
||||
<h3>{% trans "Status" %}</h3>
|
||||
|
||||
{% if config_running %}
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module for configuring Tor.
|
||||
"""
|
||||
@ -28,7 +27,6 @@ from plinth import actions
|
||||
from plinth.errors import ActionError
|
||||
from plinth.modules import tor
|
||||
|
||||
|
||||
config_process = None
|
||||
|
||||
|
||||
@ -50,12 +48,14 @@ def index(request):
|
||||
else:
|
||||
form = TorForm(initial=status, prefix='tor')
|
||||
|
||||
return TemplateResponse(request, 'tor.html',
|
||||
{'title': tor.name,
|
||||
'description': tor.description,
|
||||
'status': status,
|
||||
'config_running': bool(config_process),
|
||||
'form': form})
|
||||
return TemplateResponse(request, 'tor.html', {
|
||||
'title': tor.name,
|
||||
'description': tor.description,
|
||||
'clients': tor.clients,
|
||||
'status': status,
|
||||
'config_running': bool(config_process),
|
||||
'form': form
|
||||
})
|
||||
|
||||
|
||||
def _apply_changes(request, old_status, new_status):
|
||||
@ -63,8 +63,10 @@ def _apply_changes(request, old_status, new_status):
|
||||
try:
|
||||
__apply_changes(request, old_status, new_status)
|
||||
except ActionError as exception:
|
||||
messages.error(request, _('Action error: {0} [{1}] [{2}]').format(
|
||||
exception.args[0], exception.args[1], exception.args[2]))
|
||||
messages.error(request,
|
||||
_('Action error: {0} [{1}] [{2}]').format(
|
||||
exception.args[0], exception.args[1],
|
||||
exception.args[2]))
|
||||
|
||||
|
||||
def __apply_changes(request, old_status, new_status):
|
||||
@ -111,8 +113,8 @@ def __apply_changes(request, old_status, new_status):
|
||||
needs_restart = True
|
||||
|
||||
if old_status['upstream_bridges'] != new_status['upstream_bridges']:
|
||||
arguments.extend(['--upstream-bridges',
|
||||
new_status['upstream_bridges']])
|
||||
arguments.extend(
|
||||
['--upstream-bridges', new_status['upstream_bridges']])
|
||||
needs_restart = True
|
||||
|
||||
if old_status['enabled'] != new_status['enabled']:
|
||||
|
||||
@ -34,6 +34,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class TransmissionServiceView(views.ServiceView):
|
||||
"""Serve configuration page."""
|
||||
clients = transmission.clients
|
||||
description = transmission.description
|
||||
diagnostics_module_name = 'transmission'
|
||||
form_class = TransmissionForm
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
URLs for the Tiny Tiny RSS module.
|
||||
"""
|
||||
@ -24,12 +23,13 @@ from django.conf.urls import url
|
||||
from plinth.views import ServiceView
|
||||
from plinth.modules import ttrss
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/ttrss/$', ServiceView.as_view(
|
||||
service_id=ttrss.managed_services[0],
|
||||
diagnostics_module_name="ttrss",
|
||||
description=ttrss.description,
|
||||
show_status_block=True
|
||||
), name='index'),
|
||||
url(r'^apps/ttrss/$',
|
||||
ServiceView.as_view(
|
||||
service_id=ttrss.managed_services[0],
|
||||
diagnostics_module_name="ttrss",
|
||||
description=ttrss.description,
|
||||
clients=ttrss.clients,
|
||||
show_status_block=True),
|
||||
name='index'),
|
||||
]
|
||||
|
||||
@ -20,18 +20,20 @@
|
||||
{% load i18n %}
|
||||
{% load plinth_extras %}
|
||||
|
||||
{% if module.clients %}
|
||||
<button type="button" class="btn btn-primary collapsed"
|
||||
data-toggle="collapse" data-target="#clients">
|
||||
Client Apps
|
||||
</button>
|
||||
{% if clients %}
|
||||
<p>
|
||||
<button type="button" class="btn btn-default collapsed"
|
||||
data-toggle="collapse" data-target="#clients">
|
||||
Client Apps
|
||||
</button>
|
||||
</p>
|
||||
|
||||
<div id="clients" class="collapse">
|
||||
{% if module.clients|has_web_clients %}
|
||||
{% if clients|has_web_clients %}
|
||||
<div class="clients-info">
|
||||
<p class="heading">{% trans "Web Clients" %}:
|
||||
<ul>
|
||||
{% for client in module.clients %}
|
||||
{% for client in clients %}
|
||||
{% if client|has_web_clients %}
|
||||
{% for platform in client.platforms %}
|
||||
{% if platform.type == 'web' %}
|
||||
@ -46,12 +48,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if module.clients|has_desktop_clients %}
|
||||
{% if clients|has_desktop_clients %}
|
||||
<div class="clients-info">
|
||||
{% load static %}
|
||||
<p class="heading">{% trans "Desktop Clients" %}:
|
||||
<ul>
|
||||
{% for client in module.clients %}
|
||||
{% for client in clients %}
|
||||
{% if client|has_desktop_clients %}
|
||||
<li class="col-md-12 col-xs-12"> <span> {{ client.name }} </span> </li>
|
||||
<div class ="row">
|
||||
@ -77,12 +79,12 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if module.clients|has_mobile_clients %}
|
||||
{% if clients|has_mobile_clients %}
|
||||
<div class="clients-info">
|
||||
{% load static %}
|
||||
<p class="heading">{% trans "Mobile Clients" %}:</p>
|
||||
<ul>
|
||||
{% for client in module.clients %}
|
||||
{% for client in clients %}
|
||||
{% if client|has_mobile_clients %}
|
||||
<li class="col-md-12 col-xs-12"><span>{{ client.name }}</span></li>
|
||||
<div class="row">
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% include "clients.html" with clients=clients %}
|
||||
|
||||
{% block status %}
|
||||
{% if show_status_block %}
|
||||
<h3>{% trans "Status" %}</h3>
|
||||
@ -75,7 +77,3 @@
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
<!-- TODO Must get a handle to the clients here somehow -->
|
||||
{% include "clients.html" with clients=service.clients %}
|
||||
|
||||
|
||||
@ -38,6 +38,8 @@
|
||||
<p>{{ paragraph|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
{% include "clients.html" with clients=setup_helper.module.clients %}
|
||||
|
||||
{% if not setup_helper.current_operation %}
|
||||
|
||||
{% if setup_helper.get_state == 'needs-setup' %}
|
||||
@ -119,6 +121,5 @@
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% include "clients.html" with module=setup_helper.module %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@ -65,9 +65,7 @@ def system_index(request):
|
||||
|
||||
class ServiceView(FormView):
|
||||
"""A generic view for configuring simple services."""
|
||||
service_id = None
|
||||
form_class = forms.ServiceForm
|
||||
template_name = 'service.html'
|
||||
clients = []
|
||||
# Set diagnostics_module_name to the module name to show diagnostics button
|
||||
diagnostics_module_name = ""
|
||||
# List of paragraphs describing the service
|
||||
@ -75,7 +73,10 @@ class ServiceView(FormView):
|
||||
# Display the 'status' block of the service.html template
|
||||
# This block uses information from service.is_running. This method is
|
||||
# optional, so allow not showing this block here.
|
||||
form_class = forms.ServiceForm
|
||||
show_status_block = True
|
||||
service_id = None
|
||||
template_name = 'service.html'
|
||||
|
||||
@property
|
||||
def success_url(self):
|
||||
@ -126,10 +127,9 @@ class ServiceView(FormView):
|
||||
"""Add service to the context data."""
|
||||
context = super().get_context_data(*args, **kwargs)
|
||||
context['service'] = self.service
|
||||
if self.diagnostics_module_name:
|
||||
context['diagnostics_module_name'] = self.diagnostics_module_name
|
||||
if self.description:
|
||||
context['description'] = self.description
|
||||
context['clients'] = self.clients
|
||||
context['diagnostics_module_name'] = self.diagnostics_module_name
|
||||
context['description'] = self.description
|
||||
context['show_status_block'] = self.show_status_block
|
||||
return context
|
||||
|
||||
|
||||
@ -125,7 +125,6 @@ footer license-info p{
|
||||
}
|
||||
|
||||
.clients-info li {
|
||||
float: left;
|
||||
padding-left: 15px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user