replaced force_text with equivalent force_str (#68183)
This commit is contained in:
parent
f77ad1bc2d
commit
54eafdbb62
|
@ -16,7 +16,7 @@
|
|||
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.views.generic import DetailView, View
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
|
||||
|
@ -36,7 +36,7 @@ class BookingView(SingleObjectMixin, View):
|
|||
try:
|
||||
form.is_valid()
|
||||
except ValueError as exc:
|
||||
messages.error(request, force_text(exc))
|
||||
messages.error(request, force_str(exc))
|
||||
redirect_url = '%s?%s' % (cell.page.get_online_url(), request.GET.urlencode())
|
||||
return HttpResponseRedirect(redirect_url)
|
||||
data = form.cleaned_data
|
||||
|
|
|
@ -28,7 +28,7 @@ from django.http import (
|
|||
HttpResponseRedirect,
|
||||
)
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import View
|
||||
from rest_framework import permissions
|
||||
|
@ -130,7 +130,7 @@ def dashboard_auto_tile(request, *args, **kwargs):
|
|||
return HttpResponseNotAllowed(['post'])
|
||||
|
||||
try:
|
||||
request_body = json.loads(force_text(request.body))
|
||||
request_body = json.loads(force_str(request.body))
|
||||
except json.JSONDecodeError:
|
||||
return HttpResponseBadRequest('bad json request: "%s"' % request.body)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ from django.template.defaultfilters import date as format_date
|
|||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.dates import WEEKDAYS
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -646,7 +646,7 @@ class ChartNgCell(CellBase):
|
|||
value = hours_string
|
||||
else:
|
||||
value = _('Less than an hour')
|
||||
return force_text(value)
|
||||
return force_str(value)
|
||||
|
||||
return format_duration
|
||||
elif measure == 'percent':
|
||||
|
|
|
@ -40,7 +40,7 @@ from django.shortcuts import get_object_or_404
|
|||
from django.template.response import TemplateResponse
|
||||
from django.urls import reverse
|
||||
from django.utils import dateparse
|
||||
from django.utils.encoding import force_text, smart_text
|
||||
from django.utils.encoding import force_str, smart_text
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
@ -138,7 +138,7 @@ class AddBasketItemApiView(View):
|
|||
return HttpResponseForbidden()
|
||||
|
||||
try:
|
||||
request_body = json.loads(force_text(request.body))
|
||||
request_body = json.loads(force_str(request.body))
|
||||
except json.JSONDecodeError:
|
||||
return BadRequestJsonResponse('bad json request: "%s"' % request.body)
|
||||
|
||||
|
@ -247,7 +247,7 @@ class RemoveBasketItemApiView(View):
|
|||
return HttpResponseForbidden()
|
||||
|
||||
try:
|
||||
request_body = json.loads(force_text(request.body))
|
||||
request_body = json.loads(force_str(request.body))
|
||||
except json.JSONDecodeError:
|
||||
return BadRequestJsonResponse('bad json request: "%s"' % request.body)
|
||||
|
||||
|
@ -311,7 +311,7 @@ class ValidateTransactionApiView(View):
|
|||
)
|
||||
except eopayment.ResponseError as e:
|
||||
logger.error('failed in validation operation: %s', e)
|
||||
return JsonResponse({'err': 1, 'e': force_text(e)})
|
||||
return JsonResponse({'err': 1, 'e': force_str(e)})
|
||||
|
||||
logger.info('bank validation result: %r', result)
|
||||
operation = TransactionOperation(
|
||||
|
@ -348,7 +348,7 @@ class CancelTransactionApiView(View):
|
|||
result = transaction.make_eopayment(request=request).backend.cancel(amount, transaction.bank_data)
|
||||
except eopayment.ResponseError as e:
|
||||
logger.error('failed in cancel operation: %s', e)
|
||||
return JsonResponse({'err': 1, 'e': force_text(e)})
|
||||
return JsonResponse({'err': 1, 'e': force_str(e)})
|
||||
|
||||
logger.info('bank cancellation result: %r', result)
|
||||
operation = TransactionOperation(
|
||||
|
@ -683,7 +683,7 @@ class CallbackView(PaymentView):
|
|||
request.method,
|
||||
backend_response,
|
||||
)
|
||||
return HttpResponseBadRequest(force_text(e))
|
||||
return HttpResponseBadRequest(force_str(e))
|
||||
logger.info('lingo: received synchronous payment notification for %s', transaction)
|
||||
return HttpResponse()
|
||||
|
||||
|
@ -691,7 +691,7 @@ class CallbackView(PaymentView):
|
|||
return self.handle_callback(request, request.environ['QUERY_STRING'], **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return self.handle_callback(request, force_text(request.body), **kwargs)
|
||||
return self.handle_callback(request, force_str(request.body), **kwargs)
|
||||
|
||||
@csrf_exempt
|
||||
def dispatch(self, *args, **kwargs):
|
||||
|
@ -708,7 +708,7 @@ class ReturnView(PaymentView):
|
|||
|
||||
def post(self, request, *args, **kwargs):
|
||||
return self.handle_return(
|
||||
request, force_text(request.body) or request.environ['QUERY_STRING'], **kwargs
|
||||
request, force_str(request.body) or request.environ['QUERY_STRING'], **kwargs
|
||||
)
|
||||
|
||||
def handle_return(self, request, backend_response, **kwargs):
|
||||
|
@ -910,7 +910,7 @@ class SelfInvoiceView(View):
|
|||
else:
|
||||
msg = _('Sorry, no invoice were found with that number and amount.')
|
||||
if request.GET.get('ajax') == 'on':
|
||||
return JsonResponse({'url': url, 'msg': msg and force_text(msg)})
|
||||
return JsonResponse({'url': url, 'msg': msg and force_str(msg)})
|
||||
if url:
|
||||
return HttpResponseRedirect(url)
|
||||
messages.warning(request, msg)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django import forms
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.text import slugify
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
@ -58,7 +58,7 @@ class MapLayerForm(forms.ModelForm):
|
|||
# new widget for icon field
|
||||
self.fields['icon'].widget = IconRadioSelect()
|
||||
self.fields['icon'].choices = list(
|
||||
sorted(self.fields['icon'].choices, key=lambda x: slugify(force_text(x[1])))
|
||||
sorted(self.fields['icon'].choices, key=lambda x: slugify(force_str(x[1])))
|
||||
)
|
||||
if self.instance.kind == 'geojson':
|
||||
todelete_fields = ['tiles_template_url', 'tiles_attribution', 'tiles_default']
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import transaction
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from rest_framework import authentication, permissions, serializers, status
|
||||
from rest_framework.generics import GenericAPIView
|
||||
from rest_framework.response import Response
|
||||
|
@ -96,7 +96,7 @@ class Add(GenericAPIView):
|
|||
)
|
||||
notification_ids.append(notification.public_id)
|
||||
except ValueError as e:
|
||||
response = {'err': 1, 'err_desc': {'id': [force_text(e)]}}
|
||||
response = {'err': 1, 'err_desc': {'id': [force_str(e)]}}
|
||||
return Response(response, status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
data = {}
|
||||
|
|
|
@ -20,7 +20,7 @@ from django.conf import settings
|
|||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.timezone import now, timedelta
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
@ -145,7 +145,7 @@ class Notification(models.Model):
|
|||
|
||||
if id:
|
||||
try:
|
||||
id = force_text(id)
|
||||
id = force_str(id)
|
||||
except Exception as e:
|
||||
raise ValueError('id must be convertible to unicode', e)
|
||||
if not re.match(cls.ID_RE, id):
|
||||
|
|
|
@ -25,7 +25,7 @@ from django.core import serializers
|
|||
from django.core.files.base import ContentFile
|
||||
from django.core.files.storage import default_storage
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from py_vapid import Vapid
|
||||
|
||||
|
@ -73,7 +73,7 @@ class PwaSettings(models.Model):
|
|||
vapid = Vapid()
|
||||
vapid.generate_keys()
|
||||
self.push_notifications_infos = {
|
||||
'private_key': force_text(vapid.private_pem()),
|
||||
'private_key': force_str(vapid.private_pem()),
|
||||
}
|
||||
elif not self.push_notifications:
|
||||
self.push_notifications_infos = {}
|
||||
|
@ -91,7 +91,7 @@ class PwaSettings(models.Model):
|
|||
serialized_settings = json.loads(serializers.serialize('json', [obj]))
|
||||
result = serialized_settings[0].get('fields')
|
||||
if obj.application_icon:
|
||||
result['icon:base64'] = force_text(base64.encodebytes(obj.application_icon.read()))
|
||||
result['icon:base64'] = force_str(base64.encodebytes(obj.application_icon.read()))
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
|
@ -171,7 +171,7 @@ class PwaNavigationEntry(models.Model):
|
|||
)
|
||||
)[0]
|
||||
if self.icon:
|
||||
serialized_entry['icon:base64'] = force_text(base64.encodebytes(self.icon.read()))
|
||||
serialized_entry['icon:base64'] = force_str(base64.encodebytes(self.icon.read()))
|
||||
del serialized_entry['model']
|
||||
del serialized_entry['pk']
|
||||
return serialized_entry
|
||||
|
|
|
@ -21,7 +21,7 @@ from cryptography.hazmat.primitives import serialization
|
|||
from django.conf import settings
|
||||
from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, JsonResponse
|
||||
from django.template.loader import TemplateDoesNotExist, get_template
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.generic import TemplateView
|
||||
from py_vapid import Vapid
|
||||
|
@ -50,7 +50,7 @@ def js_response(request, template_name, **kwargs):
|
|||
if settings.PWA_VAPID_PUBLIK_KEY: # legacy
|
||||
pwa_vapid_public_key = settings.PWA_VAPID_PUBLIK_KEY
|
||||
elif hasattr(serialization.Encoding, 'X962'):
|
||||
pwa_vapid_public_key = force_text(
|
||||
pwa_vapid_public_key = force_str(
|
||||
base64.urlsafe_b64encode(
|
||||
Vapid.from_pem(pwa_settings.push_notifications_infos['private_key'].encode('ascii'))
|
||||
.private_key.public_key()
|
||||
|
@ -92,7 +92,7 @@ def subscribe_push(request, *args, **kwargs):
|
|||
return HttpResponseForbidden()
|
||||
|
||||
try:
|
||||
subscription_data = json.loads(force_text(request.body))
|
||||
subscription_data = json.loads(force_str(request.body))
|
||||
except json.JSONDecodeError:
|
||||
return HttpResponseBadRequest('bad json request: "%s"' % request.body)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ from django import forms
|
|||
from django.conf import settings
|
||||
from django.core import validators
|
||||
from django.forms.widgets import TextInput
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
|
||||
|
||||
class RichTextField(ckeditor.fields.RichTextField):
|
||||
|
@ -52,7 +52,7 @@ class RichTextFormField(ckeditor.fields.RichTextFormField):
|
|||
|
||||
|
||||
def templatable_url_validator(value):
|
||||
value = force_text(value)
|
||||
value = force_str(value)
|
||||
if '{{' in value or '{%' in value:
|
||||
# leave templates alone
|
||||
return
|
||||
|
|
|
@ -56,7 +56,7 @@ from django.template import (
|
|||
from django.test.client import RequestFactory
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import force_text, smart_bytes
|
||||
from django.utils.encoding import force_str, smart_bytes
|
||||
from django.utils.html import strip_tags
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.text import slugify
|
||||
|
@ -859,9 +859,9 @@ class CellBase(models.Model, metaclass=CellMeta):
|
|||
label = self.get_verbose_name()
|
||||
additional_label = self.get_additional_label()
|
||||
if label and additional_label:
|
||||
return '%s (%s)' % (label, re.sub(r'\r?\n', ' ', force_text(additional_label)))
|
||||
return '%s (%s)' % (label, re.sub(r'\r?\n', ' ', force_str(additional_label)))
|
||||
else:
|
||||
return force_text(label)
|
||||
return force_str(label)
|
||||
|
||||
@classmethod
|
||||
def get_verbose_name(cls):
|
||||
|
@ -2124,13 +2124,13 @@ class JsonCellBase(CellBase):
|
|||
)
|
||||
except requests.RequestException as e:
|
||||
extra_context[data_key + '_status'] = -1
|
||||
extra_context[data_key + '_error'] = force_text(e)
|
||||
extra_context[data_key + '_error'] = force_str(e)
|
||||
extra_context[data_key + '_exception'] = e
|
||||
logger = logging.getLogger(__name__)
|
||||
if log_errors:
|
||||
logger.warning('error on request %r: %s', url, force_text(e))
|
||||
logger.warning('error on request %r: %s', url, force_str(e))
|
||||
else:
|
||||
logger.debug('error on request %r: %s', url, force_text(e))
|
||||
logger.debug('error on request %r: %s', url, force_str(e))
|
||||
continue
|
||||
extra_context[data_key + '_status'] = json_response.status_code
|
||||
if json_response.status_code // 100 == 2:
|
||||
|
@ -2316,7 +2316,7 @@ class ConfigJsonCell(JsonCellBase):
|
|||
parameters = JSONField(blank=True, default=dict)
|
||||
|
||||
def __str__(self):
|
||||
return force_text(_('%s (JSON Cell)') % self.get_label())
|
||||
return force_str(_('%s (JSON Cell)') % self.get_label())
|
||||
|
||||
@classmethod
|
||||
def get_cell_types(cls):
|
||||
|
|
|
@ -37,7 +37,7 @@ from django.http import (
|
|||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.template import engines
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.timezone import localtime
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -156,7 +156,7 @@ class SiteImportView(FormView):
|
|||
except tarfile.TarError:
|
||||
try:
|
||||
fd.seek(0)
|
||||
json_site = json.loads(force_text(fd.read()))
|
||||
json_site = json.loads(force_str(fd.read()))
|
||||
except ValueError:
|
||||
form.add_error('site_file', _('File is not in the expected TAR or JSON format.'))
|
||||
return self.form_invalid(form)
|
||||
|
@ -171,7 +171,7 @@ class SiteImportView(FormView):
|
|||
else:
|
||||
pages = import_site_tar(fd, request=self.request)
|
||||
except ImportSiteError as e:
|
||||
form.add_error('site_file', force_text(e))
|
||||
form.add_error('site_file', force_str(e))
|
||||
return self.form_invalid(form)
|
||||
else:
|
||||
for page in pages:
|
||||
|
@ -957,7 +957,7 @@ def menu_json(request):
|
|||
json_str = json.dumps(
|
||||
[
|
||||
{
|
||||
'label': force_text(label),
|
||||
'label': force_str(label),
|
||||
'slug': slug,
|
||||
'url': request.build_absolute_uri(reverse('combo-manager-homepage')),
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ from ckeditor.image import pillow_backend
|
|||
from django.forms.utils import flatatt
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import get_language
|
||||
|
@ -43,7 +43,7 @@ def ckeditor_render(self, name, value, attrs=None, renderer=None):
|
|||
|
||||
# Force to text to evaluate possible lazy objects
|
||||
external_plugin_resources = [
|
||||
[force_text(a), force_text(b), force_text(c)] for a, b, c in self.external_plugin_resources
|
||||
[force_str(a), force_str(b), force_str(c)] for a, b, c in self.external_plugin_resources
|
||||
]
|
||||
|
||||
return mark_safe(
|
||||
|
@ -51,7 +51,7 @@ def ckeditor_render(self, name, value, attrs=None, renderer=None):
|
|||
'ckeditor/widget.html',
|
||||
{
|
||||
'final_attrs': flatatt(final_attrs),
|
||||
'value': conditional_escape(force_text(value)),
|
||||
'value': conditional_escape(force_str(value)),
|
||||
'id': final_attrs['id'],
|
||||
'config': ckeditor.widgets.json_encode(self.config),
|
||||
'external_plugin_resources': ckeditor.widgets.json_encode(external_plugin_resources),
|
||||
|
|
|
@ -41,7 +41,7 @@ except ImportError:
|
|||
from django.template import Template, TemplateSyntaxError, defaultfilters
|
||||
from django.template.defaultfilters import stringfilter
|
||||
from django.utils import dateparse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.timezone import is_naive, make_aware
|
||||
|
||||
from combo.apps.dashboard.models import DashboardCell, Tile
|
||||
|
@ -333,7 +333,7 @@ def has_role(user, groupname):
|
|||
|
||||
@register.filter
|
||||
def split(string, separator=' '):
|
||||
return (force_text(string) or '').split(separator)
|
||||
return (force_str(string) or '').split(separator)
|
||||
|
||||
|
||||
@register.filter
|
||||
|
@ -341,17 +341,17 @@ def strip(string, chars=None):
|
|||
if not string:
|
||||
return ''
|
||||
if chars:
|
||||
return force_text(string).strip(force_text(chars))
|
||||
return force_str(string).strip(force_str(chars))
|
||||
else:
|
||||
return force_text(string).strip()
|
||||
return force_str(string).strip()
|
||||
|
||||
|
||||
@register.filter
|
||||
def removeprefix(string, prefix):
|
||||
if not string:
|
||||
return ''
|
||||
value = force_text(string)
|
||||
prefix = force_text(prefix)
|
||||
value = force_str(string)
|
||||
prefix = force_str(prefix)
|
||||
if prefix and value.startswith(prefix):
|
||||
return value[len(prefix) :]
|
||||
return value
|
||||
|
@ -361,8 +361,8 @@ def removeprefix(string, prefix):
|
|||
def removesuffix(string, suffix):
|
||||
if not string:
|
||||
return ''
|
||||
value = force_text(string)
|
||||
suffix = force_text(suffix)
|
||||
value = force_str(string)
|
||||
suffix = force_str(suffix)
|
||||
if suffix and value.endswith(suffix):
|
||||
return value[: -len(suffix)]
|
||||
return value
|
||||
|
@ -413,12 +413,12 @@ def get_page(page_slug):
|
|||
|
||||
@register.filter
|
||||
def startswith(string, substring):
|
||||
return string and force_text(string).startswith(force_text(substring))
|
||||
return string and force_str(string).startswith(force_str(substring))
|
||||
|
||||
|
||||
@register.filter
|
||||
def endswith(string, substring):
|
||||
return string and force_text(string).endswith(force_text(substring))
|
||||
return string and force_str(string).endswith(force_str(substring))
|
||||
|
||||
|
||||
def parse_float(value):
|
||||
|
|
|
@ -40,7 +40,7 @@ from django.shortcuts import render, resolve_url
|
|||
from django.template import engines
|
||||
from django.template.loader import TemplateDoesNotExist, get_template
|
||||
from django.utils import lorem_ipsum, timezone
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
@ -142,9 +142,7 @@ def ajax_page_cell(request, page_pk, cell_reference):
|
|||
except PostException as e:
|
||||
exception = e
|
||||
if not request.is_ajax():
|
||||
messages.error(
|
||||
request, force_text(e) if force_text(e) != 'None' else _('Error sending data.')
|
||||
)
|
||||
messages.error(request, force_str(e) if force_str(e) != 'None' else _('Error sending data.'))
|
||||
|
||||
if action_response:
|
||||
response = HttpResponse(
|
||||
|
@ -159,7 +157,7 @@ def ajax_page_cell(request, page_pk, cell_reference):
|
|||
|
||||
response = render_cell(request, cell)
|
||||
if exception:
|
||||
response['x-error-message'] = force_text(exception)
|
||||
response['x-error-message'] = force_str(exception)
|
||||
return response
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import binascii
|
|||
from Cryptodome import Random
|
||||
from Cryptodome.Cipher import AES
|
||||
from Cryptodome.Protocol.KDF import PBKDF2
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
|
||||
|
||||
class DecryptionError(Exception):
|
||||
|
@ -34,7 +34,7 @@ def aes_hex_encrypt(key, data):
|
|||
aes_key = PBKDF2(key, iv)
|
||||
aes = AES.new(aes_key, AES.MODE_CFB, iv)
|
||||
crypted = aes.encrypt(data)
|
||||
return force_text(b'%s%s' % (binascii.hexlify(iv[:2]), binascii.hexlify(crypted)))
|
||||
return force_str(b'%s%s' % (binascii.hexlify(iv[:2]), binascii.hexlify(crypted)))
|
||||
|
||||
|
||||
def aes_hex_decrypt(key, payload, raise_on_error=True):
|
||||
|
@ -54,4 +54,4 @@ def aes_hex_decrypt(key, payload, raise_on_error=True):
|
|||
return None
|
||||
aes_key = PBKDF2(key, iv)
|
||||
aes = AES.new(aes_key, AES.MODE_CFB, iv)
|
||||
return force_text(aes.decrypt(crypted), 'utf-8')
|
||||
return force_str(aes.decrypt(crypted), 'utf-8')
|
||||
|
|
|
@ -18,7 +18,7 @@ import re
|
|||
|
||||
from django.conf import settings
|
||||
from django.template import Context, Template, TemplateSyntaxError, VariableDoesNotExist
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.http import quote
|
||||
|
||||
|
||||
|
@ -67,6 +67,6 @@ def get_templated_url(url, context=None):
|
|||
return '['
|
||||
if varname not in template_vars:
|
||||
raise TemplateError('unknown variable %s' % varname)
|
||||
return force_text(template_vars[varname])
|
||||
return force_str(template_vars[varname])
|
||||
|
||||
return re.sub(r'(\[.+?\])', repl, url)
|
||||
|
|
|
@ -17,7 +17,7 @@ from django.test import override_settings
|
|||
from django.test.client import RequestFactory
|
||||
from django.test.utils import CaptureQueriesContext
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from django.utils.timezone import now
|
||||
|
||||
from combo.data.library import get_cell_classes
|
||||
|
@ -50,7 +50,7 @@ def context():
|
|||
|
||||
def mock_json_response(content, **kwargs):
|
||||
content = force_bytes(content)
|
||||
text = force_text(content)
|
||||
text = force_str(content)
|
||||
return mock.Mock(content=content, text=text, json=lambda: json.loads(text), **kwargs)
|
||||
|
||||
|
||||
|
@ -79,7 +79,7 @@ def test_media():
|
|||
app_label = 'data'
|
||||
|
||||
cells = [TextCelleWithMedia() for i in range(3)]
|
||||
assert '/static/coincoin.js' in force_text(sum((cell.media for cell in cells), Media()))
|
||||
assert '/static/coincoin.js' in force_str(sum((cell.media for cell in cells), Media()))
|
||||
|
||||
|
||||
def test_additional_label():
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.core.files import File
|
|||
from django.core.files.storage import default_storage
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import CommandError
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
|
||||
from combo.apps.assets.models import Asset
|
||||
from combo.apps.assets.utils import clean_assets_files
|
||||
|
@ -304,13 +304,13 @@ def test_import_export_pwa_settings(app):
|
|||
|
||||
# check with a change in icon file content
|
||||
data = json.loads(output)
|
||||
data['pwa']['settings']['icon:base64'] = force_text(base64.encodebytes(b'TEST'))
|
||||
data['pwa']['settings']['icon:base64'] = force_str(base64.encodebytes(b'TEST'))
|
||||
import_site(data=data)
|
||||
assert PwaSettings.objects.get().application_icon.read() == b'TEST'
|
||||
|
||||
# check with a change in icon file name
|
||||
data = json.loads(output)
|
||||
data['pwa']['settings']['icon:base64'] = force_text(base64.encodebytes(b'TEST2'))
|
||||
data['pwa']['settings']['icon:base64'] = force_str(base64.encodebytes(b'TEST2'))
|
||||
data['pwa']['settings']['application_icon'] = 'pwa/test2.png'
|
||||
import_site(data=data)
|
||||
assert os.path.basename(PwaSettings.objects.get().application_icon.file.name) == 'test2.png'
|
||||
|
@ -339,7 +339,7 @@ def test_import_export_pwa_navigation(app, some_data):
|
|||
|
||||
# check with a change in icon file content
|
||||
data = json.loads(output)
|
||||
data['pwa']['navigation'][1]['icon:base64'] = force_text(base64.encodebytes(b'TEST'))
|
||||
data['pwa']['navigation'][1]['icon:base64'] = force_str(base64.encodebytes(b'TEST'))
|
||||
import_site(data=data)
|
||||
assert PwaNavigationEntry.objects.all().count() == 2
|
||||
assert PwaNavigationEntry.objects.get(order=1).icon.read() == b'TEST'
|
||||
|
@ -347,7 +347,7 @@ def test_import_export_pwa_navigation(app, some_data):
|
|||
# check with a change in icon file name
|
||||
data = json.loads(output)
|
||||
data['pwa']['navigation'][1]['fields']['icon'] = 'pwa/test2.png'
|
||||
data['pwa']['navigation'][1]['icon:base64'] = force_text(base64.encodebytes(b'TEST2'))
|
||||
data['pwa']['navigation'][1]['icon:base64'] = force_str(base64.encodebytes(b'TEST2'))
|
||||
import_site(data=data)
|
||||
assert PwaNavigationEntry.objects.all().count() == 2
|
||||
assert os.path.basename(PwaNavigationEntry.objects.get(order=1).icon.file.name) == 'test2.png'
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.core.management import call_command
|
|||
from django.test import override_settings
|
||||
from django.test.client import RequestFactory
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
from django.utils.timezone import now, timedelta
|
||||
from requests.exceptions import ConnectionError
|
||||
from requests.models import Response
|
||||
|
@ -390,7 +390,7 @@ def test_anonymous_successful_item_payment(mock_get, mock_pay_invoice, app, remo
|
|||
assert 'item' in form.fields
|
||||
assert form['item'].value == 'F201601'
|
||||
assert 'regie' in form.fields
|
||||
assert form['regie'].value == force_text(remote_regie.pk)
|
||||
assert form['regie'].value == force_str(remote_regie.pk)
|
||||
|
||||
form['email'] = 'ghost@buster.com'
|
||||
|
||||
|
@ -602,7 +602,7 @@ def test_remote_item_payment_failure(mock_post, mock_get, mock_pay_invoice, app,
|
|||
assert 'item' in form.fields
|
||||
assert form['item'].value == 'F201601'
|
||||
assert 'regie' in form.fields
|
||||
assert form['regie'].value == force_text(remote_regie.pk)
|
||||
assert form['regie'].value == force_str(remote_regie.pk)
|
||||
|
||||
form['email'] = 'test@example.net'
|
||||
resp = form.submit()
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.contrib.auth.models import User
|
|||
from django.test import Client
|
||||
from django.test.client import RequestFactory
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.timezone import now
|
||||
from mellon.models import UserSAMLIdentifier
|
||||
|
||||
|
@ -151,7 +151,7 @@ def test_notification_ws(john_doe):
|
|||
def notify(data, count, check_id=None):
|
||||
resp = client.post(reverse('api-notification-add'), json.dumps(data), content_type='application/json')
|
||||
assert resp.status_code == 200
|
||||
result = json.loads(force_text(resp.content))
|
||||
result = json.loads(force_str(resp.content))
|
||||
assert result['err'] == 0
|
||||
if 'id' in data:
|
||||
assert check_id is not None and result['data']['id'] == check_id
|
||||
|
@ -203,18 +203,18 @@ def test_notification_ws(john_doe):
|
|||
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(force_text(resp.content))['new'] == 3
|
||||
assert json.loads(force_text(resp.content))['total'] == 3
|
||||
assert json.loads(force_str(resp.content))['new'] == 3
|
||||
assert json.loads(force_str(resp.content))['total'] == 3
|
||||
resp = client.get(reverse('api-notification-ack', kwargs={'notification_id': '%s' % (notif_id - 5)}))
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(force_text(resp.content))['new'] == 2
|
||||
assert json.loads(force_text(resp.content))['total'] == 3
|
||||
assert json.loads(force_str(resp.content))['new'] == 2
|
||||
assert json.loads(force_str(resp.content))['total'] == 3
|
||||
resp = client.get(reverse('api-notification-forget', kwargs={'notification_id': '%s' % (notif_id - 5)}))
|
||||
resp = client.get(reverse('api-notification-count'))
|
||||
assert resp.status_code == 200
|
||||
assert json.loads(force_text(resp.content))['new'] == 2
|
||||
assert json.loads(force_text(resp.content))['total'] == 2
|
||||
assert json.loads(force_str(resp.content))['new'] == 2
|
||||
assert json.loads(force_str(resp.content))['total'] == 2
|
||||
|
||||
|
||||
def test_notification_ws_badrequest(john_doe):
|
||||
|
@ -225,7 +225,7 @@ def test_notification_ws_badrequest(john_doe):
|
|||
content_type='application/json',
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
result = json.loads(force_text(resp.content))
|
||||
result = json.loads(force_str(resp.content))
|
||||
assert result['err'] == 1
|
||||
assert message in list(result['err_desc'].values())[0][0]
|
||||
|
||||
|
@ -270,7 +270,7 @@ def test_notification_id_and_origin(john_doe):
|
|||
def notify(data):
|
||||
resp = client.post(reverse('api-notification-add'), json.dumps(data), content_type='application/json')
|
||||
|
||||
return json.loads(force_text(resp.content))
|
||||
return json.loads(force_str(resp.content))
|
||||
|
||||
result = notify({'summary': 'foo', 'id': '1'})
|
||||
assert result['err'] == 1
|
||||
|
|
Loading…
Reference in New Issue