mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Hide mediawiki frontpage shortcut when private mode is enabled
Signed-off-by: Hemanth Kumar Veeranki <hemanthveeranki@gmail.com> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
f83e22ba75
commit
a9fa28d3de
@ -98,7 +98,7 @@ def add_shortcut():
|
|||||||
"""Helper method to add a shortcut to the frontpage."""
|
"""Helper method to add a shortcut to the frontpage."""
|
||||||
frontpage.add_shortcut('mediawiki', name,
|
frontpage.add_shortcut('mediawiki', name,
|
||||||
short_description=short_description,
|
short_description=short_description,
|
||||||
url='/mediawiki', login_required=False)
|
url='/mediawiki', login_required=is_private_mode_enabled())
|
||||||
|
|
||||||
|
|
||||||
def is_enabled():
|
def is_enabled():
|
||||||
@ -125,18 +125,17 @@ def diagnose():
|
|||||||
results.extend(
|
results.extend(
|
||||||
action_utils.diagnose_url_on_all('https://{host}/mediawiki',
|
action_utils.diagnose_url_on_all('https://{host}/mediawiki',
|
||||||
check_certificate=False))
|
check_certificate=False))
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def get_public_registration_status():
|
def is_public_registration_enabled():
|
||||||
"""Return whether public registration is enabled."""
|
"""Return whether public registration is enabled."""
|
||||||
output = actions.superuser_run('mediawiki',
|
output = actions.superuser_run('mediawiki',
|
||||||
['public-registrations', 'status'])
|
['public-registrations', 'status'])
|
||||||
return output.strip() == 'enabled'
|
return output.strip() == 'enabled'
|
||||||
|
|
||||||
|
|
||||||
def get_private_mode_status():
|
def is_private_mode_enabled():
|
||||||
""" Return wheter private mode is enabled or disabled"""
|
""" Return wheter private mode is enabled or disabled"""
|
||||||
output = actions.superuser_run('mediawiki',
|
output = actions.superuser_run('mediawiki',
|
||||||
['private-mode', 'status'])
|
['private-mode', 'status'])
|
||||||
|
|||||||
@ -33,12 +33,12 @@ class MediaWikiForm(ServiceForm): # pylint: disable=W0232
|
|||||||
required=False, widget=forms.PasswordInput)
|
required=False, widget=forms.PasswordInput)
|
||||||
|
|
||||||
enable_public_registrations = forms.BooleanField(
|
enable_public_registrations = forms.BooleanField(
|
||||||
label=_('Enable public registrations'), required=False, help_text=_(
|
label=_('Enable public registrations'), required=False,
|
||||||
'If enabled, anyone on the internet will be able to '
|
help_text=_('If enabled, anyone on the internet will be able to '
|
||||||
'create an account on your MediaWiki instance.'))
|
'create an account on your MediaWiki instance.'))
|
||||||
|
|
||||||
enable_private_mode = forms.BooleanField(
|
enable_private_mode = forms.BooleanField(
|
||||||
label=_('Enable private mode'), required=False, help_text=_(
|
label=_('Enable private mode'), required=False,
|
||||||
'If enabled, Access will be restricted. Only people '
|
help_text=_('If enabled, access will be restricted. Only people '
|
||||||
'who have accounts can read/write to the wiki. '
|
'who have accounts can read/write to the wiki. '
|
||||||
'Public registrations will also be disabled.'))
|
'Public registrations will also be disabled.'))
|
||||||
|
|||||||
@ -23,10 +23,10 @@ import logging
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
from plinth import actions, views
|
from plinth import actions, views, frontpage
|
||||||
from plinth.modules import mediawiki
|
from plinth.modules import mediawiki
|
||||||
|
|
||||||
from . import get_public_registration_status, get_private_mode_status
|
from . import is_public_registration_enabled, is_private_mode_enabled, is_enabled, add_shortcut
|
||||||
from .forms import MediaWikiForm
|
from .forms import MediaWikiForm
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -46,8 +46,8 @@ class MediaWikiServiceView(views.ServiceView):
|
|||||||
"""Return the values to fill in the form."""
|
"""Return the values to fill in the form."""
|
||||||
initial = super().get_initial()
|
initial = super().get_initial()
|
||||||
initial.update({
|
initial.update({
|
||||||
'enable_public_registrations': get_public_registration_status(),
|
'enable_public_registrations': is_public_registration_enabled(),
|
||||||
'enable_private_mode': get_private_mode_status()
|
'enable_private_mode': is_private_mode_enabled()
|
||||||
})
|
})
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
@ -107,5 +107,6 @@ class MediaWikiServiceView(views.ServiceView):
|
|||||||
['private-mode', 'disable'])
|
['private-mode', 'disable'])
|
||||||
messages.success(self.request,
|
messages.success(self.request,
|
||||||
_('Private mode disabled'))
|
_('Private mode disabled'))
|
||||||
|
if is_enabled():
|
||||||
|
add_shortcut()
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user