From 21ca12990e2bdc3e8ef1778560c67d009a5b54df Mon Sep 17 00:00:00 2001 From: LeandroJatai Date: Mon, 15 Jul 2024 22:40:29 -0300 Subject: [PATCH] fix: force_text to force_str --- sapl/compilacao/models.py | 4 ++-- sapl/compilacao/views.py | 8 ++++---- sapl/crispy_layout_mixin.py | 12 ++++++------ sapl/crud/base.py | 6 +++--- sapl/materia/views.py | 2 +- sapl/norma/views.py | 4 ++-- sapl/protocoloadm/tests/test_protocoloadm.py | 8 ++++---- sapl/sessao/views.py | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/sapl/compilacao/models.py b/sapl/compilacao/models.py index da5d6b8b0..d6ada3d5a 100644 --- a/sapl/compilacao/models.py +++ b/sapl/compilacao/models.py @@ -9,7 +9,7 @@ from django.http.response import Http404 from django.template import defaultfilters from django.utils import timezone from django.utils.decorators import classonlymethod -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from image_cropping.fields import ImageCropField, ImageRatioField @@ -953,7 +953,7 @@ def imagem_upload_path(instance, filename): class Dispositivo(BaseModel, TimestampedMixin): - TEXTO_PADRAO_DISPOSITIVO_REVOGADO = force_text(_('(Revogado)')) + TEXTO_PADRAO_DISPOSITIVO_REVOGADO = force_str(_('(Revogado)')) INTERVALO_ORDEM = 1000 ordem = models.PositiveIntegerField( diff --git a/sapl/compilacao/views.py b/sapl/compilacao/views.py index da6b2c7c0..5422ffb57 100644 --- a/sapl/compilacao/views.py +++ b/sapl/compilacao/views.py @@ -21,7 +21,7 @@ from django.http.response import (HttpResponse, HttpResponseRedirect, from django.shortcuts import get_object_or_404, redirect from django.urls import reverse, reverse_lazy from django.utils.dateparse import parse_date -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from django.views.generic.base import TemplateView from django.views.generic.detail import DetailView @@ -1975,18 +1975,18 @@ class ActionDispositivoCreateMixin(ActionsCommonsMixin): result = [ { - 'tipo_insert': force_text("{} {}".format(_('Inserir Após'), base.tipo_dispositivo.nome)), + 'tipo_insert': force_str("{} {}".format(_('Inserir Após'), base.tipo_dispositivo.nome)), 'icone': '↷ ', 'action': 'json_add_next', 'itens': []}, { - 'tipo_insert': force_text("{} {}".format(_('Inserir em'), base.tipo_dispositivo.nome)), + 'tipo_insert': force_str("{} {}".format(_('Inserir em'), base.tipo_dispositivo.nome)), 'icone': '⇲ ', 'action': 'json_add_in', 'itens': [] }, { - 'tipo_insert': force_text(_('Inserir Antes')), + 'tipo_insert': force_str(_('Inserir Antes')), 'icone': '↶ ', 'action': 'json_add_prior', 'itens': [] diff --git a/sapl/crispy_layout_mixin.py b/sapl/crispy_layout_mixin.py index f234b2dc1..8328b0b2a 100644 --- a/sapl/crispy_layout_mixin.py +++ b/sapl/crispy_layout_mixin.py @@ -7,7 +7,7 @@ from django import template from django.contrib.contenttypes.models import ContentType from django.urls import reverse, reverse_lazy from django.utils import formats -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext as _ import yaml @@ -40,7 +40,7 @@ def form_actions(more=[Div(css_class='clearfix')], label=_('Salvar'), name='salvar', css_class='float-right', disabled=True): - if disabled and force_text(label) != 'Pesquisar': + if disabled and force_str(label) != 'Pesquisar': doubleclick = 'this.form.submit();this.disabled=true;' else: doubleclick = 'return true;' @@ -301,10 +301,10 @@ class CrispyLayoutFormMixin: def fk_urlify_for_list(self, obj, field): value = getattr(obj, field) return reverse( - '%s:%s_detail' % ( - value._meta.app_config.name, - value._meta.model_name), - kwargs={'pk': value.id}), + '%s:%s_detail' % ( + value._meta.app_config.name, + value._meta.model_name), + kwargs={'pk': value.id}), def m2m_urlize_for_detail(self, obj, fieldname): diff --git a/sapl/crud/base.py b/sapl/crud/base.py index 875c76c88..28446f695 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -15,7 +15,7 @@ from django.http.response import Http404 from django.shortcuts import redirect from django.urls import reverse from django.utils.decorators import classonlymethod -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from django.views.generic import (CreateView, DeleteView, DetailView, ListView, UpdateView) @@ -433,9 +433,9 @@ class CrudListView(PermissionRequiredContainerCrudMixin, ListView): hook = 'hook_header_{}'.format(''.join(fn)) if hasattr(self, hook): header = getattr(self, hook)() - s.append(force_text(header)) + s.append(force_str(header)) else: - s.append(force_text(f.verbose_name)) + s.append(force_str(f.verbose_name)) else: hook = 'hook_header_{}'.format(''.join(fn)) if hasattr(self, hook): diff --git a/sapl/materia/views.py b/sapl/materia/views.py index c8239c38f..a492ba8f2 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -24,7 +24,7 @@ from django.shortcuts import render from django.template import loader from django.urls import reverse from django.utils import formats, timezone -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, ListView, TemplateView, UpdateView from django.views.generic.base import RedirectView diff --git a/sapl/norma/views.py b/sapl/norma/views.py index 668069a2f..0938d1e78 100644 --- a/sapl/norma/views.py +++ b/sapl/norma/views.py @@ -12,7 +12,7 @@ from django.template import loader from django.urls import reverse from django.urls.base import reverse_lazy from django.utils import timezone -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from django.views.generic import TemplateView, UpdateView from django.views.generic.edit import FormView @@ -353,7 +353,7 @@ class NormaCrud(Crud): return HttpResponseRedirect(url) def hook_header_epigrafe(self, *args, **kwargs): - return force_text(_('Epigrafe')) + return force_str(_('Epigrafe')) def hook_epigrafe(self, obj, ss, url): diff --git a/sapl/protocoloadm/tests/test_protocoloadm.py b/sapl/protocoloadm/tests/test_protocoloadm.py index 9d747f983..d466eb631 100644 --- a/sapl/protocoloadm/tests/test_protocoloadm.py +++ b/sapl/protocoloadm/tests/test_protocoloadm.py @@ -2,7 +2,7 @@ from datetime import date, timedelta from django.urls import reverse from django.utils import timezone -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.translation import gettext_lazy as _ from model_bakery import baker from urllib.parse import urlencode @@ -168,7 +168,7 @@ def test_create_tramitacao(admin_client): 'data_tramitacao': date(2016, 8, 21)}, follow=True) - msg = force_text(_('A origem da nova tramitação deve ser igual ao ' + msg = force_str(_('A origem da nova tramitação deve ser igual ao ' 'destino da última adicionada!')) # Verifica se a origem da nova tramitacao é igual ao destino da última @@ -209,7 +209,7 @@ def test_create_tramitacao(admin_client): days=1)}, follow=True) - msg = force_text(_('A data de tramitação deve ser ' + + msg = force_str(_('A data de tramitação deve ser ' + 'menor ou igual a data de hoje!')) # Verifica se a data da tramitação é menor do que a data de hoje @@ -230,7 +230,7 @@ def test_create_tramitacao(admin_client): 'data_encaminhamento': date(2016, 8, 20)}, follow=True) - msg = force_text(_('A data de encaminhamento deve ser ' + + msg = force_str(_('A data de encaminhamento deve ser ' + 'maior que a data de tramitação!')) # Verifica se a data da encaminhamento é menor do que a data de tramitacao diff --git a/sapl/sessao/views.py b/sapl/sessao/views.py index b01759ebc..ebba2d2aa 100755 --- a/sapl/sessao/views.py +++ b/sapl/sessao/views.py @@ -17,7 +17,7 @@ from django.urls.base import reverse_lazy from django.utils import timezone from django.utils.datastructures import MultiValueDictKeyError from django.utils.decorators import method_decorator -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.html import strip_tags from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt @@ -4007,7 +4007,7 @@ class PesquisarSessaoPlenariaView(MultiFormatOutputMixin, FilterView): return kwargs def hook_header_(self): - return force_text(_('Título')) + return force_str(_('Título')) def hook_(self, obj): return str(obj) @@ -5281,7 +5281,7 @@ class CorrespondenciaCrud(MasterDetailCrud): return qs def hook_header_numero_ordem(self, *args, **kwargs): - return force_text(_('Ordem / Tipo')) if not self.request.user.is_anonymous else force_text(_('Tipo')) + return force_str(_('Ordem / Tipo')) if not self.request.user.is_anonymous else force_str(_('Tipo')) def hook_numero_ordem(self, obj, ss, url): if not self.request.user.is_anonymous: