Django 4.x: Address RemovedInDjango40Warning
force_text() is deprecated in favor of force_str() and urlquote() is deprecated in favor of urllib.parse.quote() in Django 4.0. For more please refer [1]. [1] https: //docs.djangoproject.com/en/4.0/releases/4.0/ Co-Authored-By: manchandavishal <manchandavishal143@gmail.com> Change-Id: Ibc97402b735c3ddbdd7a2174e14353dad34cbc22
This commit is contained in:
parent
0c57fd76c4
commit
ec1d07f7e6
|
@ -389,7 +389,7 @@ class CheckboxSelectMultiple(forms.CheckboxSelectMultiple):
|
|||
final_attrs = self.build_attrs(attrs, name=name)
|
||||
output = []
|
||||
initial_service = uuidutils.generate_uuid()
|
||||
str_values = set([encoding.force_text(v) for v in value])
|
||||
str_values = set([encoding.force_str(v) for v in value])
|
||||
for i, (option_value, option_label) in enumerate(
|
||||
itertools.chain(self.choices, choices)):
|
||||
current_service = option_value.split(':')[0]
|
||||
|
@ -398,10 +398,10 @@ class CheckboxSelectMultiple(forms.CheckboxSelectMultiple):
|
|||
output.append("</ul>")
|
||||
service_description = _("%s processes: ") % current_service
|
||||
service_description = html.conditional_escape(
|
||||
encoding.force_text(service_description))
|
||||
encoding.force_str(service_description))
|
||||
output.append("<label>%s</label>" % service_description)
|
||||
initial_service = current_service
|
||||
output.append(encoding.force_text("<ul>"))
|
||||
output.append(encoding.force_str("<ul>"))
|
||||
if has_id:
|
||||
final_attrs = dict(final_attrs, id='%s_%s' % (attrs['id'], i))
|
||||
label_for = ' for="%s"' % final_attrs['id']
|
||||
|
@ -410,10 +410,10 @@ class CheckboxSelectMultiple(forms.CheckboxSelectMultiple):
|
|||
|
||||
cb = forms.CheckboxInput(
|
||||
final_attrs, check_test=lambda value: value in str_values)
|
||||
option_value = encoding.force_text(option_value)
|
||||
option_value = encoding.force_str(option_value)
|
||||
rendered_cb = cb.render(name, option_value)
|
||||
option_label = html.conditional_escape(
|
||||
encoding.force_text(option_label))
|
||||
encoding.force_str(option_label))
|
||||
output.append(
|
||||
'<li><label%s>%s %s</label></li>' %
|
||||
(label_for, rendered_cb, option_label))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
from django import template
|
||||
from django.template import defaultfilters
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
|
@ -83,7 +83,7 @@ class ChoosePluginForm(forms.SelfHandlingForm):
|
|||
tmpl = template.loader.get_template(self.help_text_template)
|
||||
text += tmpl.render(extra_context, self.request)
|
||||
else:
|
||||
text += defaultfilters.linebreaks(force_text(self.help_text))
|
||||
text += defaultfilters.linebreaks(force_str(self.help_text))
|
||||
return defaultfilters.safe(text)
|
||||
|
||||
class Meta(object):
|
||||
|
|
|
@ -17,7 +17,7 @@ import uuid
|
|||
from django.forms import widgets
|
||||
from django import template
|
||||
from django.template import defaultfilters
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
@ -333,7 +333,7 @@ class JobBinaryCreateForm(forms.SelfHandlingForm):
|
|||
tmpl = template.loader.get_template(self.help_text_template)
|
||||
text += tmpl.render(extra_context, self.request)
|
||||
else:
|
||||
text += defaultfilters.linebreaks(force_text(self.help_text))
|
||||
text += defaultfilters.linebreaks(force_str(self.help_text))
|
||||
return defaultfilters.safe(text)
|
||||
|
||||
class Meta(object):
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from urllib import parse
|
||||
|
||||
from django.http import Http404 # noqa
|
||||
from django.urls import reverse
|
||||
from django.utils import http
|
||||
|
@ -176,7 +178,7 @@ class JobsTable(sahara_table.SaharaPaginateTabbedTable):
|
|||
job_template_id = job_execution.job_id
|
||||
return reverse("horizon:project:data_processing."
|
||||
"jobs:jt-details",
|
||||
args=(http.urlquote(job_template_id),))
|
||||
args=(parse.quote(job_template_id),))
|
||||
else:
|
||||
# No link should be generated for a deleted Job.
|
||||
return None
|
||||
|
@ -191,7 +193,7 @@ class JobsTable(sahara_table.SaharaPaginateTabbedTable):
|
|||
if job_execution.cluster_name:
|
||||
return reverse(
|
||||
"horizon:project:data_processing.clusters:cluster-details",
|
||||
args=(http.urlquote(job_execution.cluster_id),))
|
||||
args=(parse.quote(job_execution.cluster_id),))
|
||||
else:
|
||||
# No link should be generated for a deleted Cluster.
|
||||
return None
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
from django import template
|
||||
from django.template import defaultfilters
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from horizon import exceptions
|
||||
|
@ -78,7 +78,7 @@ class ChoosePluginForm(forms.SelfHandlingForm):
|
|||
tmpl = template.loader.get_template(self.help_text_template)
|
||||
text += tmpl.render(extra_context, self.request)
|
||||
else:
|
||||
text += defaultfilters.linebreaks(force_text(self.help_text))
|
||||
text += defaultfilters.linebreaks(force_str(self.help_text))
|
||||
return defaultfilters.safe(text)
|
||||
|
||||
class Meta(object):
|
||||
|
@ -107,8 +107,8 @@ class ChooseJobTypeForm(forms.SelfHandlingForm):
|
|||
try:
|
||||
hlps = helpers.Helpers(request)
|
||||
job_type = context["guide_job_type"]
|
||||
if force_text(request.session.get("guide_job_type")) != (
|
||||
force_text(helpers.JOB_TYPE_MAP[job_type][0])):
|
||||
if force_str(request.session.get("guide_job_type")) != (
|
||||
force_str(helpers.JOB_TYPE_MAP[job_type][0])):
|
||||
hlps.reset_job_guide()
|
||||
request.session["guide_job_type"] = (
|
||||
helpers.JOB_TYPE_MAP[job_type][0])
|
||||
|
|
Loading…
Reference in New Issue