dj32: remove use of force_bytes (#74843)
This commit is contained in:
parent
7b6df2d530
commit
9dc5a2d801
|
@ -3,8 +3,6 @@
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
|
|
||||||
from django.utils.encoding import force_bytes
|
|
||||||
|
|
||||||
from webtest import Upload
|
from webtest import Upload
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +23,7 @@ def test_synchronize_federations(settings, app, nanterre_classic_family, admin):
|
||||||
response = response.click(u'Synchroniser les fédérations')
|
response = response.click(u'Synchroniser les fédérations')
|
||||||
response = response.click(u'Nouvel import')
|
response = response.click(u'Nouvel import')
|
||||||
response.form.set('app_id', 'technocarte')
|
response.form.set('app_id', 'technocarte')
|
||||||
content = force_bytes('\n'.join(map(str, [f['kevin'].id + 1000, f['marie'].id + 1000, '99999'])))
|
content = ('\n'.join(map(str, [f['kevin'].id + 1000, f['marie'].id + 1000, '99999']))).encode()
|
||||||
response.form.set('csv_uploaded', Upload('federations.csv', content, 'application/octet-stream'))
|
response.form.set('csv_uploaded', Upload('federations.csv', content, 'application/octet-stream'))
|
||||||
response = response.form.submit().follow()
|
response = response.form.submit().follow()
|
||||||
assert len(response.pyquery('table#result-list tbody tr')) == 1
|
assert len(response.pyquery('table#result-list tbody tr')) == 1
|
||||||
|
|
|
@ -18,7 +18,6 @@ from hashlib import md5
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.db import models, connection
|
from django.db import models, connection
|
||||||
from django.utils.encoding import force_bytes
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.contrib.postgres.fields import JSONField
|
from django.contrib.postgres.fields import JSONField
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ class CommonSchema(models.Model):
|
||||||
|
|
||||||
def rebuild_string_index(self, cursor, table, path):
|
def rebuild_string_index(self, cursor, table, path):
|
||||||
expr = 'immutable_normalize((content%s))' % self.path_to_sql_expr(path)
|
expr = 'immutable_normalize((content%s))' % self.path_to_sql_expr(path)
|
||||||
key = md5(force_bytes(expr)).hexdigest()[:8]
|
key = md5(expr.encode()).hexdigest()[:8]
|
||||||
sql = ('CREATE INDEX zoo_entity_%s_gin_%s_dynamic_idx ON %s USING gin ((%s) '
|
sql = ('CREATE INDEX zoo_entity_%s_gin_%s_dynamic_idx ON %s USING gin ((%s) '
|
||||||
' gin_trgm_ops) WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
' gin_trgm_ops) WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
@ -84,7 +83,7 @@ class CommonSchema(models.Model):
|
||||||
|
|
||||||
def rebuild_string_date_time_index(self, cursor, table, path):
|
def rebuild_string_date_time_index(self, cursor, table, path):
|
||||||
expr = 'immutable_date(content%s)' % self.path_to_sql_expr(path)
|
expr = 'immutable_date(content%s)' % self.path_to_sql_expr(path)
|
||||||
key = md5(force_bytes(expr)).hexdigest()[:8]
|
key = md5(expr.encode()).hexdigest()[:8]
|
||||||
sql = ('CREATE INDEX zoo_entity_%s_%s_dynamic_idx ON %s (%s) '
|
sql = ('CREATE INDEX zoo_entity_%s_%s_dynamic_idx ON %s (%s) '
|
||||||
'WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
'WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
@ -99,7 +98,7 @@ class CommonSchema(models.Model):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(self)
|
raise NotImplementedError(self)
|
||||||
|
|
||||||
key = md5(force_bytes(expr)).hexdigest()[:8]
|
key = md5(expr.encode()).hexdigest()[:8]
|
||||||
gin_sql = ('CREATE INDEX zoo_entity_%s_gin_%s_dynamic_idx ON %s USING gin ((%s) '
|
gin_sql = ('CREATE INDEX zoo_entity_%s_gin_%s_dynamic_idx ON %s USING gin ((%s) '
|
||||||
'gin_trgm_ops) WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
'gin_trgm_ops) WHERE schema_id = %s' % (key, self.id, table, expr, self.id))
|
||||||
gist_sql = ('CREATE INDEX zoo_entity_%s_gist_%s_dynamic_idx ON %s USING gist ((%s)'
|
gist_sql = ('CREATE INDEX zoo_entity_%s_gist_%s_dynamic_idx ON %s USING gist ((%s)'
|
||||||
|
|
|
@ -24,7 +24,6 @@ from django.urls import reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import DatabaseError
|
from django.db import DatabaseError
|
||||||
from django.db.transaction import atomic
|
from django.db.transaction import atomic
|
||||||
from django.utils.encoding import force_bytes
|
|
||||||
|
|
||||||
from zoo.zoo_meta.models import EntitySchema
|
from zoo.zoo_meta.models import EntitySchema
|
||||||
from zoo.zoo_data.models import Job, Entity, Transaction, Log
|
from zoo.zoo_data.models import Job, Entity, Transaction, Log
|
||||||
|
|
Loading…
Reference in New Issue