mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +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
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth module to configure PageKite
|
||||
"""
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from . import utils
|
||||
from plinth import cfg
|
||||
from plinth.menu import main_menu
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
from . import utils
|
||||
|
||||
version = 1
|
||||
|
||||
@ -52,23 +51,17 @@ description = [
|
||||
'need this if your {box_name} services are unreachable from '
|
||||
'the rest of the Internet. This includes the following '
|
||||
'situations:'), box_name=_(cfg.box_name)),
|
||||
|
||||
format_lazy(
|
||||
_('{box_name} is behind a restricted firewall.'),
|
||||
box_name=_(cfg.box_name)),
|
||||
|
||||
_('{box_name} is behind a restricted firewall.'), box_name=_(
|
||||
cfg.box_name)),
|
||||
format_lazy(
|
||||
_('{box_name} is connected to a (wireless) router which you '
|
||||
'don\'t control.'), box_name=_(cfg.box_name)),
|
||||
|
||||
_('Your ISP does not provide you an external IP address and '
|
||||
'instead provides Internet connection through NAT.'),
|
||||
|
||||
_('Your ISP does not provide you a static IP address and your IP '
|
||||
'address changes evertime you connect to Internet.'),
|
||||
|
||||
_('Your ISP limits incoming connections.'),
|
||||
|
||||
format_lazy(
|
||||
_('PageKite works around NAT, firewalls and IP-address limitations '
|
||||
'by using a combination of tunnels and reverse proxies. You can '
|
||||
@ -82,7 +75,8 @@ description = [
|
||||
def init():
|
||||
"""Intialize the PageKite module"""
|
||||
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.
|
||||
utils.update_names_module(initial_registration=True)
|
||||
|
||||
@ -20,33 +20,40 @@ from django.http import HttpResponseRedirect
|
||||
from django.template.response import TemplateResponse
|
||||
from django.urls import reverse, reverse_lazy
|
||||
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 . import utils
|
||||
from .forms import ConfigurationForm, StandardServiceForm, \
|
||||
AddCustomServiceForm, DeleteCustomServiceForm, FirstBootForm
|
||||
from plinth import cfg
|
||||
from plinth.errors import DomainRegistrationError
|
||||
from plinth.modules import first_boot
|
||||
from plinth.modules import pagekite
|
||||
from plinth.modules import first_boot, pagekite
|
||||
|
||||
subsubmenu = [{'url': reverse_lazy('pagekite:index'),
|
||||
'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')}]
|
||||
from . import utils
|
||||
from .forms import (AddCustomServiceForm, ConfigurationForm,
|
||||
DeleteCustomServiceForm, FirstBootForm,
|
||||
StandardServiceForm)
|
||||
|
||||
subsubmenu = [{
|
||||
'url': reverse_lazy('pagekite:index'),
|
||||
'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):
|
||||
"""Serve introduction page"""
|
||||
return TemplateResponse(request, 'pagekite_introduction.html',
|
||||
{'title': pagekite.name,
|
||||
'description': pagekite.description,
|
||||
'subsubmenu': subsubmenu})
|
||||
return TemplateResponse(request, 'pagekite_introduction.html', {
|
||||
'title': pagekite.name,
|
||||
'description': pagekite.description,
|
||||
'subsubmenu': subsubmenu
|
||||
})
|
||||
|
||||
|
||||
class ContextMixin(object):
|
||||
@ -78,14 +85,15 @@ class CustomServiceView(ContextMixin, TemplateView):
|
||||
template_name = 'pagekite_custom_services.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(CustomServiceView, self).get_context_data(*args,
|
||||
**kwargs)
|
||||
context = super(CustomServiceView, self).get_context_data(
|
||||
*args, **kwargs)
|
||||
unused, custom_services = utils.get_pagekite_services()
|
||||
for service in custom_services:
|
||||
service['form'] = AddCustomServiceForm(initial=service)
|
||||
context['custom_services'] = [
|
||||
utils.prepare_service_for_display(service)
|
||||
for service in custom_services]
|
||||
for service in custom_services
|
||||
]
|
||||
context.update(utils.get_kite_details())
|
||||
return context
|
||||
|
||||
|
||||
@ -162,8 +162,9 @@ class Helper(object):
|
||||
"""Set a module's setup version."""
|
||||
from . import models
|
||||
|
||||
models.Module.objects.update_or_create(
|
||||
pk=self.module_name, defaults={'setup_version': version})
|
||||
models.Module.objects.update_or_create(pk=self.module_name, defaults={
|
||||
'setup_version': version
|
||||
})
|
||||
|
||||
|
||||
def init(module_name, module):
|
||||
@ -271,9 +272,7 @@ def _get_modules_for_regular_setup():
|
||||
|
||||
return False
|
||||
|
||||
return [name
|
||||
for name, module in all_modules
|
||||
if is_setup_required(module)]
|
||||
return [name for name, module in all_modules if is_setup_required(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."""
|
||||
global _is_first_setup
|
||||
modules = plinth.module_loader.loaded_modules.values()
|
||||
_is_first_setup = any(
|
||||
(module
|
||||
for module in modules
|
||||
if _is_module_essential(module) and
|
||||
_module_state_matches(module, 'needs-setup')))
|
||||
_is_first_setup = any((module for module in modules
|
||||
if _is_module_essential(module)
|
||||
and _module_state_matches(module, 'needs-setup')))
|
||||
|
||||
|
||||
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
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Plinth signals
|
||||
"""
|
||||
|
||||
from django.dispatch import Signal
|
||||
|
||||
|
||||
service_enabled = Signal(providing_args=['service_id', 'enabled'])
|
||||
pre_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'])
|
||||
post_hostname_change = Signal(providing_args=['old_hostname', 'new_hostname'])
|
||||
domainname_change = Signal(providing_args=['old_domainname', 'new_domainname'])
|
||||
domain_added = Signal(providing_args=['domain_type', 'name', 'description',
|
||||
'services'])
|
||||
domain_added = Signal(
|
||||
providing_args=['domain_type', 'name', 'description', 'services'])
|
||||
domain_removed = Signal(providing_args=['domain_type', 'name'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user