mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
YAPF formatting and optimization of imports
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
4826f70343
commit
63e67b5688
@ -14,18 +14,17 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Plinth module to configure PageKite
|
Plinth module to configure PageKite
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from . import utils
|
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth.menu import main_menu
|
from plinth.menu import main_menu
|
||||||
from plinth.utils import format_lazy
|
from plinth.utils import format_lazy
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
@ -52,23 +51,17 @@ description = [
|
|||||||
'need this if your {box_name} services are unreachable from '
|
'need this if your {box_name} services are unreachable from '
|
||||||
'the rest of the Internet. This includes the following '
|
'the rest of the Internet. This includes the following '
|
||||||
'situations:'), box_name=_(cfg.box_name)),
|
'situations:'), box_name=_(cfg.box_name)),
|
||||||
|
|
||||||
format_lazy(
|
format_lazy(
|
||||||
_('{box_name} is behind a restricted firewall.'),
|
_('{box_name} is behind a restricted firewall.'), box_name=_(
|
||||||
box_name=_(cfg.box_name)),
|
cfg.box_name)),
|
||||||
|
|
||||||
format_lazy(
|
format_lazy(
|
||||||
_('{box_name} is connected to a (wireless) router which you '
|
_('{box_name} is connected to a (wireless) router which you '
|
||||||
'don\'t control.'), box_name=_(cfg.box_name)),
|
'don\'t control.'), box_name=_(cfg.box_name)),
|
||||||
|
|
||||||
_('Your ISP does not provide you an external IP address and '
|
_('Your ISP does not provide you an external IP address and '
|
||||||
'instead provides Internet connection through NAT.'),
|
'instead provides Internet connection through NAT.'),
|
||||||
|
|
||||||
_('Your ISP does not provide you a static IP address and your IP '
|
_('Your ISP does not provide you a static IP address and your IP '
|
||||||
'address changes evertime you connect to Internet.'),
|
'address changes evertime you connect to Internet.'),
|
||||||
|
|
||||||
_('Your ISP limits incoming connections.'),
|
_('Your ISP limits incoming connections.'),
|
||||||
|
|
||||||
format_lazy(
|
format_lazy(
|
||||||
_('PageKite works around NAT, firewalls and IP-address limitations '
|
_('PageKite works around NAT, firewalls and IP-address limitations '
|
||||||
'by using a combination of tunnels and reverse proxies. You can '
|
'by using a combination of tunnels and reverse proxies. You can '
|
||||||
@ -82,7 +75,8 @@ description = [
|
|||||||
def init():
|
def init():
|
||||||
"""Intialize the PageKite module"""
|
"""Intialize the PageKite module"""
|
||||||
menu = main_menu.get('system')
|
menu = main_menu.get('system')
|
||||||
menu.add_urlname(name, 'glyphicon-flag', 'pagekite:index', short_description)
|
menu.add_urlname(name, 'glyphicon-flag', 'pagekite:index',
|
||||||
|
short_description)
|
||||||
|
|
||||||
# Register kite name with Name Services module.
|
# Register kite name with Name Services module.
|
||||||
utils.update_names_module(initial_registration=True)
|
utils.update_names_module(initial_registration=True)
|
||||||
|
|||||||
@ -20,33 +20,40 @@ from django.http import HttpResponseRedirect
|
|||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.urls import reverse, reverse_lazy
|
from django.urls import reverse, reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.views.generic import View, TemplateView
|
from django.views.generic import TemplateView, View
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
|
||||||
from . import utils
|
|
||||||
from .forms import ConfigurationForm, StandardServiceForm, \
|
|
||||||
AddCustomServiceForm, DeleteCustomServiceForm, FirstBootForm
|
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
from plinth.errors import DomainRegistrationError
|
from plinth.errors import DomainRegistrationError
|
||||||
from plinth.modules import first_boot
|
from plinth.modules import first_boot, pagekite
|
||||||
from plinth.modules import pagekite
|
|
||||||
|
|
||||||
subsubmenu = [{'url': reverse_lazy('pagekite:index'),
|
from . import utils
|
||||||
'text': _('About PageKite')},
|
from .forms import (AddCustomServiceForm, ConfigurationForm,
|
||||||
{'url': reverse_lazy('pagekite:configure'),
|
DeleteCustomServiceForm, FirstBootForm,
|
||||||
'text': _('Configure PageKite')},
|
StandardServiceForm)
|
||||||
{'url': reverse_lazy('pagekite:standard-services'),
|
|
||||||
'text': _('Standard Services')},
|
subsubmenu = [{
|
||||||
{'url': reverse_lazy('pagekite:custom-services'),
|
'url': reverse_lazy('pagekite:index'),
|
||||||
'text': _('Custom Services')}]
|
'text': _('About PageKite')
|
||||||
|
}, {
|
||||||
|
'url': reverse_lazy('pagekite:configure'),
|
||||||
|
'text': _('Configure PageKite')
|
||||||
|
}, {
|
||||||
|
'url': reverse_lazy('pagekite:standard-services'),
|
||||||
|
'text': _('Standard Services')
|
||||||
|
}, {
|
||||||
|
'url': reverse_lazy('pagekite:custom-services'),
|
||||||
|
'text': _('Custom Services')
|
||||||
|
}]
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
"""Serve introduction page"""
|
"""Serve introduction page"""
|
||||||
return TemplateResponse(request, 'pagekite_introduction.html',
|
return TemplateResponse(request, 'pagekite_introduction.html', {
|
||||||
{'title': pagekite.name,
|
'title': pagekite.name,
|
||||||
'description': pagekite.description,
|
'description': pagekite.description,
|
||||||
'subsubmenu': subsubmenu})
|
'subsubmenu': subsubmenu
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class ContextMixin(object):
|
class ContextMixin(object):
|
||||||
@ -78,14 +85,15 @@ class CustomServiceView(ContextMixin, TemplateView):
|
|||||||
template_name = 'pagekite_custom_services.html'
|
template_name = 'pagekite_custom_services.html'
|
||||||
|
|
||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
context = super(CustomServiceView, self).get_context_data(*args,
|
context = super(CustomServiceView, self).get_context_data(
|
||||||
**kwargs)
|
*args, **kwargs)
|
||||||
unused, custom_services = utils.get_pagekite_services()
|
unused, custom_services = utils.get_pagekite_services()
|
||||||
for service in custom_services:
|
for service in custom_services:
|
||||||
service['form'] = AddCustomServiceForm(initial=service)
|
service['form'] = AddCustomServiceForm(initial=service)
|
||||||
context['custom_services'] = [
|
context['custom_services'] = [
|
||||||
utils.prepare_service_for_display(service)
|
utils.prepare_service_for_display(service)
|
||||||
for service in custom_services]
|
for service in custom_services
|
||||||
|
]
|
||||||
context.update(utils.get_kite_details())
|
context.update(utils.get_kite_details())
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@ -162,8 +162,9 @@ class Helper(object):
|
|||||||
"""Set a module's setup version."""
|
"""Set a module's setup version."""
|
||||||
from . import models
|
from . import models
|
||||||
|
|
||||||
models.Module.objects.update_or_create(
|
models.Module.objects.update_or_create(pk=self.module_name, defaults={
|
||||||
pk=self.module_name, defaults={'setup_version': version})
|
'setup_version': version
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def init(module_name, module):
|
def init(module_name, module):
|
||||||
@ -271,9 +272,7 @@ def _get_modules_for_regular_setup():
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return [name
|
return [name for name, module in all_modules if is_setup_required(module)]
|
||||||
for name, module in all_modules
|
|
||||||
if is_setup_required(module)]
|
|
||||||
|
|
||||||
|
|
||||||
def _is_module_essential(module):
|
def _is_module_essential(module):
|
||||||
@ -290,11 +289,9 @@ def _set_is_first_setup():
|
|||||||
"""Set whether all essential modules have been setup at least once."""
|
"""Set whether all essential modules have been setup at least once."""
|
||||||
global _is_first_setup
|
global _is_first_setup
|
||||||
modules = plinth.module_loader.loaded_modules.values()
|
modules = plinth.module_loader.loaded_modules.values()
|
||||||
_is_first_setup = any(
|
_is_first_setup = any((module for module in modules
|
||||||
(module
|
if _is_module_essential(module)
|
||||||
for module in modules
|
and _module_state_matches(module, 'needs-setup')))
|
||||||
if _is_module_essential(module) and
|
|
||||||
_module_state_matches(module, 'needs-setup')))
|
|
||||||
|
|
||||||
|
|
||||||
def run_setup_on_modules(module_list, allow_install=True):
|
def run_setup_on_modules(module_list, allow_install=True):
|
||||||
|
|||||||
@ -14,14 +14,12 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Plinth signals
|
Plinth signals
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.dispatch import Signal
|
from django.dispatch import Signal
|
||||||
|
|
||||||
|
|
||||||
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
||||||
pre_module_loading = Signal()
|
pre_module_loading = Signal()
|
||||||
post_module_loading = Signal()
|
post_module_loading = Signal()
|
||||||
@ -29,6 +27,6 @@ post_setup = Signal(providing_args=['module_name'])
|
|||||||
pre_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
pre_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
||||||
post_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
post_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
||||||
domainname_change = Signal(providing_args=['old_domainname', 'new_domainname'])
|
domainname_change = Signal(providing_args=['old_domainname', 'new_domainname'])
|
||||||
domain_added = Signal(providing_args=['domain_type', 'name', 'description',
|
domain_added = Signal(
|
||||||
'services'])
|
providing_args=['domain_type', 'name', 'description', 'services'])
|
||||||
domain_removed = Signal(providing_args=['domain_type', 'name'])
|
domain_removed = Signal(providing_args=['domain_type', 'name'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user