mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
pagekite: cosmetic: yapf and isort changes
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
cff9a61f09
commit
867b8f3f63
@ -16,17 +16,19 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
from django import forms
|
|
||||||
from django.contrib import messages
|
|
||||||
from django.core import validators
|
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
from django.utils.translation import ugettext as _, ugettext_lazy
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from . import utils
|
from django import forms
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.core import validators
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.utils.translation import ugettext_lazy
|
||||||
|
|
||||||
from plinth.errors import ActionError
|
from plinth.errors import ActionError
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -68,21 +70,19 @@ class ConfigurationForm(forms.Form):
|
|||||||
label=ugettext_lazy('Server domain'), required=False,
|
label=ugettext_lazy('Server domain'), required=False,
|
||||||
help_text=ugettext_lazy(
|
help_text=ugettext_lazy(
|
||||||
'Select your pagekite server. Set "pagekite.net" to use '
|
'Select your pagekite server. Set "pagekite.net" to use '
|
||||||
'the default pagekite.net server.'),
|
'the default pagekite.net server.'), widget=forms.TextInput())
|
||||||
widget=forms.TextInput())
|
|
||||||
server_port = forms.IntegerField(
|
server_port = forms.IntegerField(
|
||||||
label=ugettext_lazy('Server port'), required=False,
|
label=ugettext_lazy('Server port'), required=False,
|
||||||
help_text=ugettext_lazy('Port of your pagekite server (default: 80)'))
|
help_text=ugettext_lazy('Port of your pagekite server (default: 80)'))
|
||||||
kite_name = TrimmedCharField(
|
kite_name = TrimmedCharField(
|
||||||
label=ugettext_lazy('Kite name'),
|
label=ugettext_lazy('Kite name'),
|
||||||
help_text=ugettext_lazy('Example: mybox.pagekite.me'),
|
help_text=ugettext_lazy('Example: mybox.pagekite.me'), validators=[
|
||||||
validators=[
|
|
||||||
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
||||||
ugettext_lazy('Invalid kite name'))])
|
ugettext_lazy('Invalid kite name'))
|
||||||
|
])
|
||||||
|
|
||||||
kite_secret = TrimmedCharField(
|
kite_secret = TrimmedCharField(
|
||||||
label=ugettext_lazy('Kite secret'),
|
label=ugettext_lazy('Kite secret'), help_text=ugettext_lazy(
|
||||||
help_text=ugettext_lazy(
|
|
||||||
'A secret associated with the kite or the default secret '
|
'A secret associated with the kite or the default secret '
|
||||||
'for your account if no secret is set on the kite.'))
|
'for your account if no secret is set on the kite.'))
|
||||||
|
|
||||||
@ -139,9 +139,8 @@ class StandardServiceForm(forms.Form):
|
|||||||
help_text = service['help_text'].format(kite['kite_name'])
|
help_text = service['help_text'].format(kite['kite_name'])
|
||||||
else:
|
else:
|
||||||
help_text = service['help_text']
|
help_text = service['help_text']
|
||||||
self.fields[name] = forms.BooleanField(label=service['label'],
|
self.fields[name] = forms.BooleanField(
|
||||||
help_text=help_text,
|
label=service['label'], help_text=help_text, required=False)
|
||||||
required=False)
|
|
||||||
|
|
||||||
def save(self, request):
|
def save(self, request):
|
||||||
formdata = self.cleaned_data
|
formdata = self.cleaned_data
|
||||||
@ -151,12 +150,15 @@ class StandardServiceForm(forms.Form):
|
|||||||
service = json.dumps(service)
|
service = json.dumps(service)
|
||||||
if formdata[service_name]:
|
if formdata[service_name]:
|
||||||
utils.run(['add-service', '--service', service])
|
utils.run(['add-service', '--service', service])
|
||||||
messages.success(request, _('Service enabled: {name}')
|
messages.success(
|
||||||
.format(name=service_name))
|
request,
|
||||||
|
_('Service enabled: {name}').format(name=service_name))
|
||||||
else:
|
else:
|
||||||
utils.run(['remove-service', '--service', service])
|
utils.run(['remove-service', '--service', service])
|
||||||
messages.success(request, _('Service disabled: {name}')
|
messages.success(
|
||||||
.format(name=service_name))
|
request,
|
||||||
|
_('Service disabled: {name}').format(
|
||||||
|
name=service_name))
|
||||||
|
|
||||||
# Update kite services registered with Name Services module.
|
# Update kite services registered with Name Services module.
|
||||||
utils.update_names_module()
|
utils.update_names_module()
|
||||||
@ -165,8 +167,8 @@ class StandardServiceForm(forms.Form):
|
|||||||
class BaseCustomServiceForm(forms.Form):
|
class BaseCustomServiceForm(forms.Form):
|
||||||
"""Basic form functionality to handle a custom service"""
|
"""Basic form functionality to handle a custom service"""
|
||||||
choices = [('http', 'http'), ('https', 'https'), ('raw', 'raw')]
|
choices = [('http', 'http'), ('https', 'https'), ('raw', 'raw')]
|
||||||
protocol = forms.ChoiceField(
|
protocol = forms.ChoiceField(choices=choices,
|
||||||
choices=choices, label=ugettext_lazy('protocol'))
|
label=ugettext_lazy('protocol'))
|
||||||
frontend_port = forms.IntegerField(
|
frontend_port = forms.IntegerField(
|
||||||
min_value=0, max_value=65535,
|
min_value=0, max_value=65535,
|
||||||
label=ugettext_lazy('external (frontend) port'), required=True)
|
label=ugettext_lazy('external (frontend) port'), required=True)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user