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:
Joseph Nuthalapati authored and Sunil Mohan Adapa committed 2018-01-30 10:49:20 +05:30
1 parent 4826f70343
commit 63e67b5688
4 files changed
+43 -46

No files matched your search

+5 -11
View File
@@ -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)
+29 -21
View File
@@ -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