*: Use Django gettext functions instead of ugettext

- ugettext functions will be removed in Django 4.0. Each use emits a warning
when running with Django 3.2. Since we have warnings enabled in developer mode,
we see quite a few messages because of this.

- ugettext is already a simple alias of gettext. So, no regressions are
expected.

Tests:

- Accessing an affected app in UI with Django 3.2 and Django 2.2 works fine.

- Using Django 3.2 there are no warnings related to removal of ugettext
functions.

- Ran regular unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2021-09-15 17:07:50 -07:00 committed by James Valleroy
parent 9ebbc34f1e
commit 74214c18ae
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
201 changed files with 448 additions and 440 deletions

View File

@ -304,7 +304,7 @@ default.
### Marking text for translation
To mark text for translation, FreedomBox uses Django's translation strings. A
module should e.g. `from django.utils.translation import ugettext as _` and wrap
module should e.g. `from django.utils.translation import gettext as _` and wrap
user-facing text with `_()`. Use it like this:
```python

View File

@ -18,7 +18,7 @@ function normally.
.. code-block:: python3
:caption: ``__init__.py``
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import app as app_module

View File

@ -79,7 +79,7 @@ the Django's localization methods to make that happen.
.. code-block:: python3
:caption: ``__init__.py``
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
class TransmissionApp(app_module.App):
...
@ -95,8 +95,8 @@ the Django's localization methods to make that happen.
Notice that the app's name, description, etc. are wrapped in the ``_()`` method
call. This needs to be done for the rest of our app. We use the
:obj:`~django.utils.translation.ugettext_lazy` in some cases and we use the
regular :obj:`~django.utils.translation.ugettext` in other cases. This is
:obj:`~django.utils.translation.gettext_lazy` in some cases and we use the
regular :obj:`~django.utils.translation.gettext` in other cases. This is
because in the second case the :obj:`~django.utils.translation.gettext` lookup
is made once and reused for every user looking at the interface. These users may
each have a different language set for their interface. Lookup made for one

View File

@ -5,8 +5,8 @@ Django context processors to provide common data to templates.
import re
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_noop
from django.utils.translation import gettext as _
from django.utils.translation import gettext_noop
from plinth import cfg, menu
from plinth.utils import is_user_admin
@ -20,7 +20,7 @@ def common(request):
"""
# Allow a value in configuration file to be translated. Allow
# the brand name 'FreedomBox' itself to be translated.
ugettext_noop('FreedomBox')
gettext_noop('FreedomBox')
from plinth.notification import Notification
notifications_context = Notification.get_display_context(

View File

@ -8,7 +8,8 @@ import subprocess
import psutil
from django.utils.text import format_lazy
from django.utils.translation import ugettext as _, ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from plinth import action_utils, actions, app
@ -100,7 +101,7 @@ class Daemon(app.LeaderComponent):
"""Check if a daemon is running."""
result = 'passed' if self.is_running() else 'failed'
template = ugettext_lazy('Service {service_name} is running')
template = gettext_lazy('Service {service_name} is running')
testname = format_lazy(template, service_name=self.unit)
return [testname, result]
@ -126,12 +127,12 @@ def diagnose_port_listening(port, kind='tcp', listen_address=None):
result = _check_port(port, kind, listen_address)
if listen_address:
template = ugettext_lazy(
template = gettext_lazy(
'Listening on {kind} port {listen_address}:{port}')
testname = format_lazy(template, kind=kind,
listen_address=listen_address, port=port)
else:
template = ugettext_lazy('Listening on {kind} port {port}')
template = gettext_lazy('Listening on {kind} port {port}')
testname = format_lazy(template, kind=kind, port=port)
return [testname, 'passed' if result else 'failed']

View File

@ -12,7 +12,7 @@ from django.forms import CheckboxInput
from django.utils import translation
from django.utils.safestring import mark_safe
from django.utils.translation import get_language_info
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
import plinth

View File

@ -12,7 +12,7 @@ from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.shortcuts import render
from django.utils.deprecation import MiddlewareMixin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from stronghold.utils import is_view_func_public
import plinth

View File

@ -4,7 +4,7 @@ FreedomBox app for Apache server.
"""
import os
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -7,7 +7,7 @@ import re
import subprocess
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext_lazy
from plinth import action_utils, actions, app
@ -119,10 +119,10 @@ def diagnose_url(url, kind=None, env=None, check_certificate=True,
wrapper, expected_output)
if kind:
template = ugettext_lazy('Access URL {url} on tcp{kind}')
template = gettext_lazy('Access URL {url} on tcp{kind}')
testname = format_lazy(template, url=url, kind=kind)
else:
template = ugettext_lazy('Access URL {url}')
template = gettext_lazy('Access URL {url}')
testname = format_lazy(template, url=url)
return [testname, result]

View File

@ -3,7 +3,7 @@
FreedomBox app for service discovery.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -11,8 +11,8 @@ import re
import paramiko
from django.utils.text import get_valid_filename
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_noop
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from plinth import actions
from plinth import app as app_module
@ -193,18 +193,18 @@ def split_path(path):
def _show_schedule_setup_notification():
"""Show a notification hinting to setup a remote backup schedule."""
from plinth.notification import Notification
message = ugettext_noop(
message = gettext_noop(
'Enable an automatic backup schedule for data safety. Prefer an '
'encrypted remote backup location or an extra attached disk.')
data = {
'app_name': 'translate:' + ugettext_noop('Backups'),
'app_name': 'translate:' + gettext_noop('Backups'),
'app_icon': 'fa-files-o'
}
title = ugettext_noop('Enable a Backup Schedule')
title = gettext_noop('Enable a Backup Schedule')
actions_ = [{
'type': 'link',
'class': 'primary',
'text': ugettext_noop('Go to {app_name}'),
'text': gettext_noop('Go to {app_name}'),
'url': 'backups:index'
}, {
'type': 'dismiss'
@ -238,20 +238,20 @@ def _show_schedule_error_notification(repository, is_error, exception=None):
except KeyError:
error_count = 0
message = ugettext_noop(
message = gettext_noop(
'A scheduled backup failed. Past {error_count} attempts for backup '
'did not succeed. The latest error is: {error_message}')
data = {
'app_name': 'translate:' + ugettext_noop('Backups'),
'app_name': 'translate:' + gettext_noop('Backups'),
'app_icon': 'fa-files-o',
'error_count': error_count + 1 if is_error else 0,
'error_message': str(exception)
}
title = ugettext_noop('Error During Backup')
title = gettext_noop('Error During Backup')
actions_ = [{
'type': 'link',
'class': 'primary',
'text': ugettext_noop('Go to {app_name}'),
'text': gettext_noop('Go to {app_name}'),
'url': 'backups:index'
}, {
'type': 'dismiss'

View File

@ -12,8 +12,8 @@ from django import forms
from django.core.exceptions import ValidationError
from django.core.validators import (FileExtensionValidator,
validate_ipv46_address)
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext
from django.utils.translation import gettext_lazy as _
from plinth.modules.storage import get_mounts
from plinth.utils import format_lazy
@ -30,7 +30,7 @@ def _get_app_choices(components):
for component in components:
name = component.app.info.name
if not component.has_data:
name = ugettext('{app} (No data to backup)').format(
name = gettext('{app} (No data to backup)').format(
app=component.app.info.name)
choices.append((component.app_id, name))

View File

@ -13,7 +13,7 @@ import re
from uuid import uuid1
import paramiko
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions, cfg
from plinth.errors import ActionError

View File

@ -16,8 +16,8 @@ from django.http import Http404, StreamingHttpResponse
from django.shortcuts import redirect
from django.urls import reverse, reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from django.views.generic import FormView, TemplateView, View
from plinth.errors import PlinthError
@ -52,7 +52,7 @@ class ScheduleView(SuccessMessageMixin, FormView):
prefix = 'backups_schedule'
template_name = 'backups_schedule.html'
success_url = reverse_lazy('backups:index')
success_message = ugettext_lazy('Backup schedule updated.')
success_message = gettext_lazy('Backup schedule updated.')
def get_initial(self):
"""Return the values to fill in the form."""
@ -103,7 +103,7 @@ class CreateArchiveView(SuccessMessageMixin, FormView):
prefix = 'backups'
template_name = 'backups_form.html'
success_url = reverse_lazy('backups:index')
success_message = ugettext_lazy('Archive created.')
success_message = gettext_lazy('Archive created.')
def get_context_data(self, **kwargs):
"""Return additional context for rendering the template."""
@ -191,7 +191,7 @@ class BaseRestoreView(SuccessMessageMixin, FormView):
prefix = 'backups'
template_name = 'backups_restore.html'
success_url = reverse_lazy('backups:index')
success_message = ugettext_lazy('Restored files from backup.')
success_message = gettext_lazy('Restored files from backup.')
def get_form_kwargs(self):
"""Pass additional keyword args for instantiating the form."""

View File

@ -5,7 +5,7 @@ FreedomBox app for bepasty.
import json
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -4,7 +4,7 @@ Django forms for bepasty app.
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.modules import bepasty

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('bepasty'),

View File

@ -7,7 +7,7 @@ from django.contrib import messages
from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.decorators.http import require_POST
from django.views.generic import FormView

View File

@ -8,7 +8,7 @@ from collections import defaultdict
from pathlib import Path
import augeas
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -5,7 +5,7 @@ Forms for BIND module.
from django import forms
from django.core.validators import validate_ipv46_address
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
def validate_ips(ips):

View File

@ -4,7 +4,7 @@ Views for BIND module.
"""
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth.modules import bind, names

View File

@ -6,7 +6,7 @@ FreedomBox app for calibre e-book library.
import json
import re
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -6,7 +6,7 @@ Django form for configuring calibre.
from django import forms
from django.core import validators
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.modules import calibre

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('calibre'),

View File

@ -9,7 +9,7 @@ from django.http import Http404
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic.edit import FormView
from plinth import actions, views

View File

@ -4,7 +4,7 @@ FreedomBox app to configure Cockpit.
"""
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -3,7 +3,7 @@
Application manifest for cockpit.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('Cockpit'),

View File

@ -7,7 +7,7 @@ import os
import socket
import augeas
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -9,12 +9,12 @@ import re
from django import forms
from django.core import validators
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from plinth import cfg, frontpage
from plinth.utils import format_lazy
from plinth.modules.apache import get_users_with_website
from plinth.utils import format_lazy
from . import home_page_url2scid
@ -37,7 +37,7 @@ def get_homepage_choices():
for shortcut in shortcuts if shortcut.is_enabled()]
uws_choices = \
[(home_page_url2scid(url),
format_lazy(ugettext_lazy("{user}'s website"), user=user))
format_lazy(gettext_lazy("{user}'s website"), user=user))
for user, url in get_users_with_website().items()]
apache_default = ('apache-default', _('Apache Default'))
plinth = ('plinth', _('FreedomBox Service (Plinth)'))
@ -52,21 +52,21 @@ class ConfigurationForm(forms.Form):
# https://tools.ietf.org/html/rfc1123#section-2
# https://tools.ietf.org/html/rfc2181#section-11
hostname = forms.CharField(
label=ugettext_lazy('Hostname'), help_text=format_lazy(
ugettext_lazy(
label=gettext_lazy('Hostname'), help_text=format_lazy(
gettext_lazy(
'Hostname is the local name by which other devices on the '
'local network can reach your {box_name}. It must start and '
'end with an alphabet or a digit and have as interior '
'characters only alphabets, digits and hyphens. Total '
'length must be 63 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)), validators=[
box_name=gettext_lazy(cfg.box_name)), validators=[
validators.RegexValidator(HOSTNAME_REGEX,
ugettext_lazy('Invalid hostname'))
gettext_lazy('Invalid hostname'))
], strip=True)
domainname = forms.CharField(
label=ugettext_lazy('Domain Name'), help_text=format_lazy(
ugettext_lazy(
label=gettext_lazy('Domain Name'), help_text=format_lazy(
gettext_lazy(
'Domain name is the global name by which other devices on the '
'Internet can reach your {box_name}. It must consist of '
'labels separated by dots. Each label must start and end '
@ -74,16 +74,16 @@ class ConfigurationForm(forms.Form):
'only alphabets, digits and hyphens. Length of each label '
'must be 63 characters or less. Total length of domain name '
'must be 253 characters or less.'),
box_name=ugettext_lazy(cfg.box_name)), required=False, validators=[
box_name=gettext_lazy(cfg.box_name)), required=False, validators=[
validators.RegexValidator(
r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$',
ugettext_lazy('Invalid domain name')),
gettext_lazy('Invalid domain name')),
domain_label_validator
], strip=True)
homepage = forms.ChoiceField(
label=ugettext_lazy('Webserver Home Page'), help_text=format_lazy(
ugettext_lazy(
label=gettext_lazy('Webserver Home Page'), help_text=format_lazy(
gettext_lazy(
'Choose the default page that must be served when '
'someone visits your {box_name} on the web. A typical use '
'case is to set your blog or wiki as the home page when '
@ -91,11 +91,11 @@ class ConfigurationForm(forms.Form):
'page is set to something other than {box_name} Service '
'(Plinth), your users must explicitly type /plinth or '
'/freedombox to reach {box_name} Service (Plinth).'),
box_name=ugettext_lazy(cfg.box_name)), required=False,
box_name=gettext_lazy(cfg.box_name)), required=False,
choices=get_homepage_choices)
advanced_mode = forms.BooleanField(
label=ugettext_lazy('Show advanced apps and features'), required=False,
help_text=ugettext_lazy(
label=gettext_lazy('Show advanced apps and features'), required=False,
help_text=gettext_lazy(
'Show apps and features that require more technical '
'knowledge.'))

View File

@ -6,7 +6,7 @@ FreedomBox views for basic system configuration.
import logging
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions, views
from plinth.modules import config

View File

@ -8,7 +8,7 @@ import logging
import pathlib
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -5,7 +5,7 @@ Forms for Coturn app.
from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.modules import coturn
from plinth.modules.coturn.components import TurnConfiguration

View File

@ -4,7 +4,7 @@ Views for Coturn app.
"""
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
import plinth.modules.coturn as coturn
from plinth import views

View File

@ -5,7 +5,7 @@ FreedomBox app to configure system date and time.
import subprocess
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import app as app_module
from plinth import menu

View File

@ -7,7 +7,7 @@ import logging
import subprocess
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
logger = logging.getLogger(__name__)

View File

@ -6,7 +6,7 @@ FreedomBox app for configuring date and time.
import logging
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions
from plinth.views import AppView

View File

@ -3,7 +3,7 @@
FreedomBox app to configure a Deluge web client.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -3,7 +3,7 @@
Forms for Deluge app.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.modules.storage.forms import (DirectorySelectForm,
DirectoryValidator)

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('Deluge'),

View File

@ -6,7 +6,7 @@ Django views for Deluge.
import json
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions, views

View File

@ -10,8 +10,8 @@ import pathlib
import threading
import psutil
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_noop
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
from plinth import app as app_module
from plinth import cfg, daemon, glib, menu
@ -95,10 +95,10 @@ def run_on_all_enabled_modules():
# Four result strings returned by tests, mark for translation and
# translate later.
ugettext_noop('passed')
ugettext_noop('failed')
ugettext_noop('error')
ugettext_noop('warning')
gettext_noop('passed')
gettext_noop('failed')
gettext_noop('error')
gettext_noop('warning')
apps = []
@ -201,23 +201,23 @@ def _warn_about_low_ram_space(request):
if memory_info['free_bytes'] < 1024**3:
# Translators: This is the unit of computer storage Mebibyte similar to
# Megabyte.
memory_available_unit = ugettext_noop('MiB')
memory_available_unit = gettext_noop('MiB')
memory_available = memory_info['free_bytes'] / 1024**2
else:
# Translators: This is the unit of computer storage Gibibyte similar to
# Gigabyte.
memory_available_unit = ugettext_noop('GiB')
memory_available_unit = gettext_noop('GiB')
memory_available = memory_info['free_bytes'] / 1024**3
show = False
if memory_info['percent_used'] > 90:
severity = 'error'
advice_message = ugettext_noop(
advice_message = gettext_noop(
'You should disable some apps to reduce memory usage.')
show = True
elif memory_info['percent_used'] > 75:
severity = 'warning'
advice_message = ugettext_noop(
advice_message = gettext_noop(
'You should not install any new apps on this system.')
show = True
@ -228,14 +228,14 @@ def _warn_about_low_ram_space(request):
pass
return
message = ugettext_noop(
message = gettext_noop(
# xgettext:no-python-format
'System is low on memory: {percent_used}% used, {memory_available} '
'{memory_available_unit} free. {advice_message}')
title = ugettext_noop('Low Memory')
title = gettext_noop('Low Memory')
data = {
'app_icon': 'fa-heartbeat',
'app_name': 'translate:' + ugettext_noop('Diagnostics'),
'app_name': 'translate:' + gettext_noop('Diagnostics'),
'percent_used': f'{memory_info["percent_used"]:.1f}',
'memory_available': f'{memory_available:.1f}',
'memory_available_unit': 'translate:' + memory_available_unit,

View File

@ -7,7 +7,7 @@ import logging
from django.http import Http404
from django.template.response import TemplateResponse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.decorators.http import require_POST
from plinth.app import App

View File

@ -3,7 +3,7 @@
import os
import augeas
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -4,7 +4,7 @@ Forms for configuring diaspora*
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
class DiasporaAppForm(forms.Form):

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url
from plinth.modules import diaspora

View File

@ -6,7 +6,7 @@ Views for the diaspora module
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import FormView
from plinth.forms import DomainSelectionForm

View File

@ -3,7 +3,7 @@
FreedomBox app to configure ez-ipupdate client.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -5,8 +5,8 @@ Forms for the dynamicsdns module.
from django import forms
from django.core import validators
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from plinth import cfg
from plinth.utils import format_lazy
@ -26,98 +26,97 @@ class TrimmedCharField(forms.CharField):
class ConfigureForm(forms.Form):
"""Form to configure the Dynamic DNS client."""
help_update_url = \
ugettext_lazy('The Variables &lt;User&gt;, &lt;Pass&gt;, &lt;Ip&gt;, '
'&lt;Domain&gt; may be used within the URL. For details '
'see the update URL templates of the example providers.')
gettext_lazy('The Variables &lt;User&gt;, &lt;Pass&gt;, &lt;Ip&gt;, '
'&lt;Domain&gt; may be used within the URL. For details '
'see the update URL templates of the example providers.')
help_services = \
ugettext_lazy('Please choose an update protocol according to your '
'provider. If your provider does not support the GnuDIP '
'protocol or your provider is not listed you may use '
'the update URL of your provider.')
gettext_lazy('Please choose an update protocol according to your '
'provider. If your provider does not support the GnuDIP '
'protocol or your provider is not listed you may use '
'the update URL of your provider.')
help_server = \
ugettext_lazy('Please do not enter a URL here (like '
'"https://example.com/") but only the hostname of the '
'GnuDIP server (like "example.com").')
gettext_lazy('Please do not enter a URL here (like '
'"https://example.com/") but only the hostname of the '
'GnuDIP server (like "example.com").')
help_domain = format_lazy(
ugettext_lazy('The public domain name you want to use to reach your '
'{box_name}.'), box_name=ugettext_lazy(cfg.box_name))
gettext_lazy('The public domain name you want to use to reach your '
'{box_name}.'), box_name=gettext_lazy(cfg.box_name))
help_disable_ssl = \
ugettext_lazy('Use this option if your provider uses self signed '
'certificates.')
gettext_lazy('Use this option if your provider uses self signed '
'certificates.')
help_http_auth = \
ugettext_lazy('If this option is selected, your username and password '
'will be used for HTTP basic authentication.')
gettext_lazy('If this option is selected, your username and password '
'will be used for HTTP basic authentication.')
help_secret = \
ugettext_lazy('Leave this field empty if you want to keep your '
'current password.')
gettext_lazy('Leave this field empty if you want to keep your '
'current password.')
help_ip_url = format_lazy(
ugettext_lazy('Optional Value. If your {box_name} is not connected '
'directly to the Internet (i.e. connected to a NAT '
'router) this URL is used to determine the real '
'IP address. The URL should simply return the IP where '
'the client comes from (example: '
'http://myip.datasystems24.de).'),
box_name=ugettext_lazy(cfg.box_name))
gettext_lazy('Optional Value. If your {box_name} is not connected '
'directly to the Internet (i.e. connected to a NAT '
'router) this URL is used to determine the real '
'IP address. The URL should simply return the IP where '
'the client comes from (example: '
'http://myip.datasystems24.de).'),
box_name=gettext_lazy(cfg.box_name))
help_user = \
ugettext_lazy('The username that was used when the account was '
'created.')
gettext_lazy('The username that was used when the account was '
'created.')
provider_choices = (('GnuDIP', ugettext_lazy('GnuDIP')),
provider_choices = (('GnuDIP', gettext_lazy('GnuDIP')),
('noip', 'noip.com'), ('selfhost', 'selfhost.bz'),
('freedns', 'freedns.afraid.org'),
('other', ugettext_lazy('other update URL')))
('other', gettext_lazy('other update URL')))
enabled = forms.BooleanField(label=ugettext_lazy('Enable Dynamic DNS'),
enabled = forms.BooleanField(label=gettext_lazy('Enable Dynamic DNS'),
required=False)
service_type = forms.ChoiceField(label=ugettext_lazy('Service Type'),
service_type = forms.ChoiceField(label=gettext_lazy('Service Type'),
help_text=help_services,
choices=provider_choices)
dynamicdns_server = TrimmedCharField(
label=ugettext_lazy('GnuDIP Server Address'), required=False,
label=gettext_lazy('GnuDIP Server Address'), required=False,
help_text=help_server, validators=[
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
ugettext_lazy('Invalid server name'))
gettext_lazy('Invalid server name'))
])
dynamicdns_update_url = TrimmedCharField(label=ugettext_lazy('Update URL'),
dynamicdns_update_url = TrimmedCharField(label=gettext_lazy('Update URL'),
required=False,
help_text=help_update_url)
disable_SSL_cert_check = forms.BooleanField(
label=ugettext_lazy('Accept all SSL certificates'),
label=gettext_lazy('Accept all SSL certificates'),
help_text=help_disable_ssl, required=False)
use_http_basic_auth = forms.BooleanField(
label=ugettext_lazy('Use HTTP basic authentication'),
label=gettext_lazy('Use HTTP basic authentication'),
help_text=help_http_auth, required=False)
dynamicdns_domain = TrimmedCharField(
label=ugettext_lazy('Domain Name'), help_text=help_domain,
label=gettext_lazy('Domain Name'), help_text=help_domain,
required=False, validators=[
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
ugettext_lazy('Invalid domain name'))
gettext_lazy('Invalid domain name'))
])
dynamicdns_user = TrimmedCharField(label=ugettext_lazy('Username'),
dynamicdns_user = TrimmedCharField(label=gettext_lazy('Username'),
required=False, help_text=help_user)
dynamicdns_secret = TrimmedCharField(label=ugettext_lazy('Password'),
dynamicdns_secret = TrimmedCharField(label=gettext_lazy('Password'),
widget=forms.PasswordInput(),
required=False, help_text=help_secret)
showpw = forms.BooleanField(label=ugettext_lazy('Show password'),
showpw = forms.BooleanField(label=gettext_lazy('Show password'),
required=False)
dynamicdns_ipurl = TrimmedCharField(
label=ugettext_lazy('URL to look up public IP'), required=False,
label=gettext_lazy('URL to look up public IP'), required=False,
help_text=help_ip_url,
validators=[validators.URLValidator(schemes=['http', 'https', 'ftp'])])
use_ipv6 = forms.BooleanField(
label=ugettext_lazy('Use IPv6 instead of IPv4'),
required=False)
label=gettext_lazy('Use IPv6 instead of IPv4'), required=False)
def clean(self):
cleaned_data = super(ConfigureForm, self).clean()

View File

@ -8,8 +8,8 @@ import logging
from django.contrib import messages
from django.template.response import TemplateResponse
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from plinth import actions
from plinth.modules import dynamicdns
@ -23,13 +23,13 @@ EMPTYSTRING = 'none'
subsubmenu = [{
'url': reverse_lazy('dynamicdns:index'),
'text': ugettext_lazy('About')
'text': gettext_lazy('About')
}, {
'url': reverse_lazy('dynamicdns:configure'),
'text': ugettext_lazy('Configure')
'text': gettext_lazy('Configure')
}, {
'url': reverse_lazy('dynamicdns:statuspage'),
'text': ugettext_lazy('Status')
'text': gettext_lazy('Status')
}]

View File

@ -8,7 +8,8 @@ import logging
import pathlib
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module
from plinth import cfg, frontpage, menu

View File

@ -5,7 +5,7 @@ Forms for configuring Ejabberd.
from django import forms
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import cfg
from plinth.modules.coturn.forms import turn_uris_validator

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url
from plinth.modules.jsxc import manifest as jsxc_manifest

View File

@ -3,12 +3,12 @@
Views for the Ejabberd module
"""
from plinth.modules.coturn.components import TurnConfiguration
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions
from plinth.modules import coturn, ejabberd
from plinth.modules.coturn.components import TurnConfiguration
from plinth.views import AppView
from .forms import EjabberdForm

View File

@ -4,7 +4,7 @@
import logging
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
import plinth.app
import plinth.daemon
@ -16,8 +16,7 @@ from plinth.modules.config import get_domainname
from plinth.modules.firewall.components import Firewall
from plinth.modules.letsencrypt.components import LetsEncrypt
from . import audit
from . import manifest
from . import audit, manifest
version = 1

View File

@ -9,9 +9,10 @@ import pwd
import sqlite3
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.modules.email_server import lock
from . import models
map_db_schema_script = """
@ -49,7 +50,7 @@ def db_cursor():
def get(uid_number):
s = 'SELECT * FROM Alias WHERE uid_number=?'
with db_cursor() as cur:
rows = cur.execute(s, (uid_number,))
rows = cur.execute(s, (uid_number, ))
result = [models.Alias(**r) for r in rows]
return result

View File

@ -1,8 +1,8 @@
import re
from dataclasses import dataclass, field, InitVar
from dataclasses import InitVar, dataclass, field
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
email_positive_pattern = re.compile('^[a-zA-Z0-9-_\\.]+')

View File

@ -9,17 +9,17 @@ import select
import subprocess
import sys
import time
from types import SimpleNamespace
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.actions import superuser_run
from plinth.errors import ActionError
from plinth.modules.config import get_domainname
from plinth.modules.email_server import interproc, postconf
from . import models
from plinth.modules.email_server import interproc, postconf
EXIT_VALIDATION = 40

View File

@ -6,10 +6,10 @@ import pwd
import subprocess
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.actions import superuser_run
from plinth.errors import ActionError
from plinth.modules.email_server import interproc
logger = logging.getLogger(__name__)

View File

@ -4,11 +4,12 @@ configurations"""
import logging
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
import plinth.modules.email_server.aliases as aliases
import plinth.modules.email_server.postconf as postconf
from plinth import actions
import plinth.modules.email_server.postconf as postconf
import plinth.modules.email_server.aliases as aliases
from . import models
default_config = {
@ -47,7 +48,6 @@ default_smtps_options = {
'smtpd_relay_restrictions': 'permit_sasl_authenticated,reject'
}
MAILSRV_DIR = '/var/lib/plinth/mailsrv'
ETC_ALIASES = 'hash:/etc/aliases'
BEFORE_ALIASES = 'ldap:/etc/postfix/freedombox-username-to-uid-number.cf'

View File

@ -4,13 +4,13 @@ import json
import logging
import os
from django.utils.translation import ugettext_lazy as _
from plinth import actions
from django.utils.translation import gettext_lazy as _
from . import models
from plinth import actions
from plinth.modules.email_server.lock import Mutex
from plinth.modules.email_server.modconf import ConfigInjector
from . import models
config_path = '/etc/roundcube/config.inc.php'
boundary_pattern = '//[ ]*--[ ]*(BEGIN|END)[ ]+FREEDOMBOX CONFIG$'

View File

@ -6,13 +6,14 @@ import logging
import re
import subprocess
from django.utils.translation import ugettext_lazy as _
from plinth import actions
from django.utils.translation import gettext_lazy as _
from . import models
from plinth import actions
from plinth.modules.email_server import interproc, lock, postconf
from plinth.modules.email_server.modconf import ConfigInjector
from . import models
milter_config = {
'milter_mail_macros': 'i ' + ' '.join([
'{auth_type}', '{auth_authen}', '{auth_author}',

View File

@ -6,11 +6,12 @@ import logging
import os
import sys
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth.modules.email_server import interproc, postconf
from . import models
from plinth.modules.email_server import interproc, postconf
# Mozilla Guideline v5.6, Postfix 1.17.7, OpenSSL 1.1.1d, intermediate
# Generated 2021-08

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
class EmailServerForm(forms.Form):

View File

@ -1,5 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url
clients = [{

View File

@ -3,20 +3,18 @@ import io
import itertools
import pwd
import plinth.actions
import plinth.utils
from django.core.exceptions import ValidationError
from django.http import HttpResponseBadRequest
from django.shortcuts import redirect
from django.utils.html import escape
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView, View
import plinth.actions
import plinth.utils
from plinth.views import AppView, render_tabs
from . import aliases
from . import audit
from . import forms
from . import aliases, audit, forms
class TabMixin(View):

View File

@ -6,7 +6,7 @@ FreedomBox app to configure a firewall.
import contextlib
import logging
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -7,7 +7,7 @@ import logging
import re
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import app
from plinth.modules import firewall

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import cfg
from plinth.modules import first_boot

View File

@ -2,7 +2,7 @@
from django import http
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import TemplateView
from django.views.generic.edit import FormView

View File

@ -6,7 +6,7 @@ FreedomBox app to configure Gitweb.
import json
import os
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -10,7 +10,7 @@ from urllib.parse import urlparse
from django import forms
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth.modules import gitweb

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
CONFIG_FILE = '/etc/gitweb-freedombox.conf'
GIT_REPO_PATH = '/var/lib/git'

View File

@ -9,7 +9,7 @@ from django.http import Http404
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.generic import FormView
from plinth import actions, views

View File

@ -5,8 +5,8 @@ FreedomBox app for help pages.
import os
from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy
from django.utils.translation import ugettext_lazy as _
from plinth import app as app_module
from plinth import cfg, menu, web_server

View File

@ -12,7 +12,7 @@ from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.translation import get_language_from_request
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import __version__, actions, cfg
from plinth.modules.upgrades.views import (get_os_release,

View File

@ -3,7 +3,7 @@
FreedomBox app to configure I2P.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -3,7 +3,7 @@
Application manifest for I2P.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
_package_id = 'net.geti2p.i2p'
_download_url = 'https://geti2p.net/download'

View File

@ -3,7 +3,7 @@
Views for I2P application.
"""
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.views import AppView

View File

@ -4,7 +4,7 @@ FreedomBox app to configure ikiwiki.
"""
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -4,7 +4,7 @@ Forms for configuring ikiwiki
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
class IkiwikiCreateForm(forms.Form):

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('ikiwiki'),

View File

@ -7,7 +7,7 @@ from django.contrib import messages
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions, views
from plinth.modules import ikiwiki

View File

@ -4,7 +4,7 @@ FreedomBox app for infinoted.
"""
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import cfg
from plinth.utils import format_lazy

View File

@ -6,7 +6,7 @@ FreedomBox app to configure XMPP web client/jsxc.
import logging
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import app as app_module
from plinth import frontpage, menu

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('JSXC'),

View File

@ -7,7 +7,7 @@ import json
import logging
import pathlib
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -9,7 +9,7 @@ from django.contrib import messages
from django.shortcuts import redirect
from django.template.response import TemplateResponse
from django.urls import reverse_lazy
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.http import require_POST
from plinth.errors import ActionError

View File

@ -9,7 +9,7 @@ import pathlib
from typing import List
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from ruamel.yaml.util import load_yaml_guess_indent
from plinth import actions

View File

@ -5,9 +5,9 @@ Forms for the Matrix Synapse module.
from django import forms
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
from plinth.modules.coturn.forms import turn_uris_validator
from django.utils.translation import ugettext_lazy as _
from plinth.utils import format_lazy

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url

View File

@ -6,7 +6,7 @@ Views for the Matrix Synapse module.
from django.contrib import messages
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import FormView
from plinth import actions

View File

@ -6,7 +6,7 @@ FreedomBox app to configure MediaWiki.
import re
from urllib.parse import urlparse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth import app as app_module

View File

@ -8,7 +8,7 @@ import pathlib
from django import forms
from django.forms import Widget
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
def get_skins():

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
clients = [{
'name': _('MediaWiki'),

View File

@ -6,7 +6,7 @@ FreedomBox app for configuring MediaWiki.
import logging
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from plinth import actions, views
from plinth.modules import mediawiki

View File

@ -5,7 +5,7 @@ FreedomBox app for Minetest server.
import augeas
from django.urls import reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import app as app_module
from plinth import cfg, frontpage, menu

View File

@ -4,7 +4,7 @@ Forms for minetest module.
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
class MinetestForm(forms.Form):

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth.clients import store_url

View File

@ -4,7 +4,7 @@ Views for minetest module.
"""
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth.modules import names

Some files were not shown because too many files have changed in this diff Show More