Django 4.x: Replace removed features
force_text(), ugettext_lazy(), ungettext_lazy(), urlquote_plus() and is_ajax() are removed in 4.0. https: //docs.djangoproject.com/en/4.0/releases/4.0/ Co-Authored-By: manchandavishal <manchandavishal143@gmail.com> Change-Id: I9e43926cc3011b8b7321bbec59bebe915502eb4a
This commit is contained in:
parent
5a36a31de6
commit
d956d059f9
|
@ -16,10 +16,11 @@ import contextlib
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.messages import api as msg_api
|
from django.contrib.messages import api as msg_api
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from glanceclient.common import exceptions as glance_exc
|
from glanceclient.common import exceptions as glance_exc
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
|
from horizon.utils import http as http_utils
|
||||||
import muranoclient.client as client
|
import muranoclient.client as client
|
||||||
from muranoclient.common import exceptions as exc
|
from muranoclient.common import exceptions as exc
|
||||||
from muranoclient.glance import client as art_client
|
from muranoclient.glance import client as art_client
|
||||||
|
@ -34,8 +35,8 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
def _handle_message(request, message):
|
def _handle_message(request, message):
|
||||||
def horizon_message_already_queued(_message):
|
def horizon_message_already_queued(_message):
|
||||||
_message = force_text(_message)
|
_message = force_str(_message)
|
||||||
if request.is_ajax():
|
if http_utils.is_ajax(request):
|
||||||
for tag, msg, extra in request.horizon['async_messages']:
|
for tag, msg, extra in request.horizon['async_messages']:
|
||||||
if _message == msg:
|
if _message == msg:
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
from horizon import tabs
|
from horizon import tabs
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from muranodashboard.dynamic_ui import services
|
from muranodashboard.dynamic_ui import services
|
||||||
|
|
|
@ -17,6 +17,7 @@ import copy
|
||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
from urllib import parse
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from castellan.common import exception as castellan_exception
|
from castellan.common import exception as castellan_exception
|
||||||
|
@ -37,7 +38,7 @@ from django import shortcuts
|
||||||
from django.utils import decorators as django_dec
|
from django.utils import decorators as django_dec
|
||||||
from django.utils import html
|
from django.utils import html
|
||||||
from django.utils import http as http_utils
|
from django.utils import http as http_utils
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import list as list_view
|
from django.views.generic import list as list_view
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon.forms import views
|
from horizon.forms import views
|
||||||
|
@ -126,7 +127,9 @@ def get_categories_list(request):
|
||||||
def switch(request, environment_id,
|
def switch(request, environment_id,
|
||||||
redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
redirect_field_name=auth.REDIRECT_FIELD_NAME):
|
||||||
redirect_to = request.GET.get(redirect_field_name, '')
|
redirect_to = request.GET.get(redirect_field_name, '')
|
||||||
if not http_utils.is_safe_url(url=redirect_to, host=request.get_host()):
|
if (not http_utils.url_has_allowed_host_and_scheme(
|
||||||
|
url=redirect_to,
|
||||||
|
host=request.get_host())):
|
||||||
redirect_to = settings.LOGIN_REDIRECT_URL
|
redirect_to = settings.LOGIN_REDIRECT_URL
|
||||||
|
|
||||||
for env in get_available_environments(request):
|
for env in get_available_environments(request):
|
||||||
|
@ -622,7 +625,7 @@ class IndexView(generic_views.PageTitleMixin, list_view.ListView):
|
||||||
"""
|
"""
|
||||||
data = self.object_list
|
data = self.object_list
|
||||||
if data:
|
if data:
|
||||||
return http_utils.urlquote_plus(self.get_object_id(data[index]))
|
return parse.quote_plus(self.get_object_id(data[index]))
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import forms as horizon_forms
|
from horizon import forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.translation import ungettext_lazy
|
from django.utils.translation import ngettext_lazy
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import tables
|
from horizon import tables
|
||||||
from muranoclient.common import exceptions as exc
|
from muranoclient.common import exceptions as exc
|
||||||
|
@ -42,7 +42,7 @@ class DeleteCategory(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Delete Category",
|
u"Delete Category",
|
||||||
u"Delete Categories",
|
u"Delete Categories",
|
||||||
count
|
count
|
||||||
|
@ -50,7 +50,7 @@ class DeleteCategory(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Deleted Category",
|
u"Deleted Category",
|
||||||
u"Deleted Categories",
|
u"Deleted Categories",
|
||||||
count
|
count
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon.forms import views
|
from horizon.forms import views
|
||||||
from horizon import tables as horizon_tables
|
from horizon import tables as horizon_tables
|
||||||
from horizon.utils import functions as utils
|
from horizon.utils import functions as utils
|
||||||
|
|
|
@ -17,7 +17,7 @@ from muranodashboard.common import widgets
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core import validators
|
from django.core import validators
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class TriStateMultipleChoiceField(forms.ChoiceField):
|
class TriStateMultipleChoiceField(forms.ChoiceField):
|
||||||
|
|
|
@ -17,7 +17,7 @@ import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from neutronclient.common import exceptions as exc
|
from neutronclient.common import exceptions as exc
|
||||||
from openstack_dashboard.api import keystone
|
from openstack_dashboard.api import keystone
|
||||||
|
|
|
@ -16,7 +16,7 @@ import itertools as it
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_str
|
||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
|
|
||||||
from muranodashboard.common import utils
|
from muranodashboard.common import utils
|
||||||
|
@ -64,7 +64,7 @@ class Input(Widget):
|
||||||
def _format_value(self, value):
|
def _format_value(self, value):
|
||||||
if self.is_localized:
|
if self.is_localized:
|
||||||
value = formats.localize_input(value)
|
value = formats.localize_input(value)
|
||||||
return force_text(value)
|
return force_str(value)
|
||||||
|
|
||||||
def get_context(self, name, value, attrs=None):
|
def get_context(self, name, value, attrs=None):
|
||||||
context = {
|
context = {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
# Load the api rest services into Horizon
|
# Load the api rest services into Horizon
|
||||||
|
|
|
@ -22,9 +22,9 @@ from django import forms
|
||||||
from django.forms import widgets
|
from django.forms import widgets
|
||||||
from django.template import defaultfilters
|
from django.template import defaultfilters
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_str
|
||||||
from django.utils import html
|
from django.utils import html
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms as hz_forms
|
from horizon import forms as hz_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
@ -175,11 +175,11 @@ class CustomPropertiesField(forms.Field):
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
self.description = description
|
self.description = description
|
||||||
self.description_title = (description_title or
|
self.description_title = (description_title or
|
||||||
force_text(kwargs.get('label', '')))
|
force_str(kwargs.get('label', '')))
|
||||||
|
|
||||||
for arg in FIELD_ARGS_TO_ESCAPE:
|
for arg in FIELD_ARGS_TO_ESCAPE:
|
||||||
if kwargs.get(arg):
|
if kwargs.get(arg):
|
||||||
kwargs[arg] = html.escape(force_text(kwargs[arg]))
|
kwargs[arg] = html.escape(force_str(kwargs[arg]))
|
||||||
|
|
||||||
validators = []
|
validators = []
|
||||||
validators_js = []
|
validators_js = []
|
||||||
|
@ -191,11 +191,11 @@ class CustomPropertiesField(forms.Field):
|
||||||
error_messages = kwargs.get('error_messages', {})
|
error_messages = kwargs.get('error_messages', {})
|
||||||
if hasattr(validator, 'code') and \
|
if hasattr(validator, 'code') and \
|
||||||
validator.code in error_messages:
|
validator.code in error_messages:
|
||||||
regex_message = force_text(
|
regex_message = force_str(
|
||||||
error_messages[validator.code]
|
error_messages[validator.code]
|
||||||
)
|
)
|
||||||
validators_js. \
|
validators_js. \
|
||||||
append({'regex': force_text(validator.regex.pattern),
|
append({'regex': force_str(validator.regex.pattern),
|
||||||
'message': regex_message})
|
'message': regex_message})
|
||||||
else: # mixed list of regexpValidator and YAQL validators
|
else: # mixed list of regexpValidator and YAQL validators
|
||||||
expr = validator.get('expr')
|
expr = validator.get('expr')
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from yaql import legacy
|
from yaql import legacy
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ import os
|
||||||
import re
|
import re
|
||||||
import semantic_version
|
import semantic_version
|
||||||
|
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from yaql import legacy
|
from yaql import legacy
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ def condition_getter(request, kwargs):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
app = import_app(request, kwargs['app_id'])
|
app = import_app(request, kwargs['app_id'])
|
||||||
key = force_text(_get_form_name(len(app.forms) - 1, app.forms[-1]()))
|
key = force_str(_get_form_name(len(app.forms) - 1, app.forms[-1]()))
|
||||||
|
|
||||||
return {key: _func}
|
return {key: _func}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
# ---- Metadata Consts ---- #
|
# ---- Metadata Consts ---- #
|
||||||
|
|
|
@ -15,7 +15,7 @@ import ast
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms as horizon_forms
|
from horizon import forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ from django import http as django_http
|
||||||
from django import template
|
from django import template
|
||||||
from django.template import defaultfilters
|
from django.template import defaultfilters
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.translation import ungettext_lazy
|
from django.utils.translation import ngettext_lazy
|
||||||
|
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms
|
from horizon import forms
|
||||||
|
@ -126,7 +126,7 @@ class DeleteEnvironment(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Delete Environment",
|
u"Delete Environment",
|
||||||
u"Delete Environments",
|
u"Delete Environments",
|
||||||
count
|
count
|
||||||
|
@ -134,7 +134,7 @@ class DeleteEnvironment(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Started Deleting Environment",
|
u"Started Deleting Environment",
|
||||||
u"Started Deleting Environments",
|
u"Started Deleting Environments",
|
||||||
count
|
count
|
||||||
|
@ -172,7 +172,7 @@ class AbandonEnvironment(tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Abandon Environment",
|
u"Abandon Environment",
|
||||||
u"Abandon Environments",
|
u"Abandon Environments",
|
||||||
count
|
count
|
||||||
|
@ -180,7 +180,7 @@ class AbandonEnvironment(tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Abandoned Environment",
|
u"Abandoned Environment",
|
||||||
u"Abandoned Environments",
|
u"Abandoned Environments",
|
||||||
count
|
count
|
||||||
|
@ -218,7 +218,7 @@ class DeleteService(tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Delete Component",
|
u"Delete Component",
|
||||||
u"Delete Components",
|
u"Delete Components",
|
||||||
count
|
count
|
||||||
|
@ -226,7 +226,7 @@ class DeleteService(tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Started Deleting Component",
|
u"Started Deleting Component",
|
||||||
u"Started Deleting Components",
|
u"Started Deleting Components",
|
||||||
count
|
count
|
||||||
|
@ -258,7 +258,7 @@ class DeployEnvironment(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present_deploy(count):
|
def action_present_deploy(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Deploy Environment",
|
u"Deploy Environment",
|
||||||
u"Deploy Environments",
|
u"Deploy Environments",
|
||||||
count
|
count
|
||||||
|
@ -266,7 +266,7 @@ class DeployEnvironment(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past_deploy(count):
|
def action_past_deploy(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Started deploying Environment",
|
u"Started deploying Environment",
|
||||||
u"Started deploying Environments",
|
u"Started deploying Environments",
|
||||||
count
|
count
|
||||||
|
@ -274,7 +274,7 @@ class DeployEnvironment(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present_update(count):
|
def action_present_update(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Update Environment",
|
u"Update Environment",
|
||||||
# there can be cases when some of the envs are new and some are not
|
# there can be cases when some of the envs are new and some are not
|
||||||
# so it is better to just leave "Deploy" for multiple envs
|
# so it is better to just leave "Deploy" for multiple envs
|
||||||
|
@ -284,7 +284,7 @@ class DeployEnvironment(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past_update(count):
|
def action_past_update(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Updated Environment",
|
u"Updated Environment",
|
||||||
u"Deployed Environments",
|
u"Deployed Environments",
|
||||||
count
|
count
|
||||||
|
|
|
@ -17,7 +17,7 @@ import json
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from heat_dashboard.api import heat as heat_api
|
from heat_dashboard.api import heat as heat_api
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import json
|
||||||
from django import http
|
from django import http
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
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 import generic
|
from django.views import generic
|
||||||
from horizon import conf
|
from horizon import conf
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
|
|
|
@ -17,7 +17,7 @@ import json
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms as horizon_forms
|
from horizon import forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.translation import ungettext_lazy
|
from django.utils.translation import ngettext_lazy
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import tables
|
from horizon import tables
|
||||||
from openstack_dashboard.api import glance
|
from openstack_dashboard.api import glance
|
||||||
|
@ -37,7 +37,7 @@ class RemoveImageMetadata(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Delete Metadata",
|
u"Delete Metadata",
|
||||||
u"Delete Metadata",
|
u"Delete Metadata",
|
||||||
count
|
count
|
||||||
|
@ -45,7 +45,7 @@ class RemoveImageMetadata(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Deleted Metadata",
|
u"Deleted Metadata",
|
||||||
u"Deleted Metadata",
|
u"Deleted Metadata",
|
||||||
count
|
count
|
||||||
|
|
|
@ -16,7 +16,7 @@ import itertools
|
||||||
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon.forms import views
|
from horizon.forms import views
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
||||||
PANEL_GROUP = 'app-catalog_browse_group'
|
PANEL_GROUP = 'app-catalog_browse_group'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
||||||
PANEL_GROUP = 'app-catalog_manage_group'
|
PANEL_GROUP = 'app-catalog_manage_group'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
# The name of the panel group to be added to HORIZON_CONFIG. Required.
|
||||||
PANEL_GROUP = 'app-catalog_applications_group'
|
PANEL_GROUP = 'app-catalog_applications_group'
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
from django.core import validators
|
from django.core import validators
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import forms as horizon_forms
|
from horizon import forms as horizon_forms
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
from django.template import defaultfilters
|
from django.template import defaultfilters
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.utils.translation import ungettext_lazy
|
from django.utils.translation import ngettext_lazy
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
from horizon import tables
|
from horizon import tables
|
||||||
|
@ -86,7 +86,7 @@ class ToggleEnabled(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Toggle Active",
|
u"Toggle Active",
|
||||||
u"Toggle Active",
|
u"Toggle Active",
|
||||||
count
|
count
|
||||||
|
@ -94,7 +94,7 @@ class ToggleEnabled(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Toggled Active",
|
u"Toggled Active",
|
||||||
u"Toggled Active",
|
u"Toggled Active",
|
||||||
count
|
count
|
||||||
|
@ -122,7 +122,7 @@ class TogglePublicEnabled(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Toggle Public",
|
u"Toggle Public",
|
||||||
u"Toggle Public",
|
u"Toggle Public",
|
||||||
count
|
count
|
||||||
|
@ -130,7 +130,7 @@ class TogglePublicEnabled(tables.BatchAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Toggled Public",
|
u"Toggled Public",
|
||||||
u"Toggled Public",
|
u"Toggled Public",
|
||||||
count
|
count
|
||||||
|
@ -165,7 +165,7 @@ class DeletePackage(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_present(count):
|
def action_present(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Delete Package",
|
u"Delete Package",
|
||||||
u"Delete Packages",
|
u"Delete Packages",
|
||||||
count
|
count
|
||||||
|
@ -173,7 +173,7 @@ class DeletePackage(policy.PolicyTargetMixin, tables.DeleteAction):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def action_past(count):
|
def action_past(count):
|
||||||
return ungettext_lazy(
|
return ngettext_lazy(
|
||||||
u"Deleted Package",
|
u"Deleted Package",
|
||||||
u"Deleted Packages",
|
u"Deleted Packages",
|
||||||
count
|
count
|
||||||
|
|
|
@ -19,7 +19,7 @@ from django.core.files import storage
|
||||||
from django import http
|
from django import http
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
# django.contrib.formtools migration to django 1.8
|
# django.contrib.formtools migration to django 1.8
|
||||||
# https://docs.djangoproject.com/en/1.8/ref/contrib/formtools/
|
# https://docs.djangoproject.com/en/1.8/ref/contrib/formtools/
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -19,7 +19,7 @@ from unittest import mock
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.forms import formsets
|
from django.forms import formsets
|
||||||
from django import http
|
from django import http
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from horizon.forms import views as horizon_views
|
from horizon.forms import views as horizon_views
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class TestCatalogViews(unittest.TestCase):
|
||||||
mock_shortcuts.redirect.assert_called_once_with('redirect_to_foo')
|
mock_shortcuts.redirect.assert_called_once_with('redirect_to_foo')
|
||||||
mock_shortcuts.redirect.reset_mock()
|
mock_shortcuts.redirect.reset_mock()
|
||||||
|
|
||||||
mock_http_utls.is_safe_url.return_value = False
|
mock_http_utls.url_has_allowed_host_and_scheme.return_value = False
|
||||||
result = views.switch(self.mock_request, 'foo_env_id',
|
result = views.switch(self.mock_request, 'foo_env_id',
|
||||||
redirect_field_name='redirect')
|
redirect_field_name='redirect')
|
||||||
self.assertEqual('foo_redirect', result)
|
self.assertEqual('foo_redirect', result)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
from django.core import exceptions
|
from django.core import exceptions
|
||||||
from django.core import validators as django_validator
|
from django.core import validators as django_validator
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -29,8 +29,8 @@ class TestFields(unittest.TestCase):
|
||||||
super(TestFields, self).setUp()
|
super(TestFields, self).setUp()
|
||||||
self.request = mock.Mock()
|
self.request = mock.Mock()
|
||||||
self.request.user.service_region = None
|
self.request.user.service_region = None
|
||||||
self.request.is_ajax = mock.Mock(side_effect=False)
|
|
||||||
self.addCleanup(mock.patch.stopall)
|
self.addCleanup(mock.patch.stopall)
|
||||||
|
mock.patch('horizon.utils.http.is_ajax', return_value=True).start()
|
||||||
|
|
||||||
@mock.patch.object(fields, 'LOG')
|
@mock.patch.object(fields, 'LOG')
|
||||||
def test_fields_with_initial_request(self, mock_log):
|
def test_fields_with_initial_request(self, mock_log):
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from muranoclient.common import exceptions as exc
|
from muranoclient.common import exceptions as exc
|
||||||
from muranodashboard.environments import forms as env_forms
|
from muranodashboard.environments import forms as env_forms
|
||||||
|
|
|
@ -17,7 +17,7 @@ import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from muranoclient.common import exceptions as exc
|
from muranoclient.common import exceptions as exc
|
||||||
from muranodashboard.environments import tables
|
from muranodashboard.environments import tables
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import base64
|
import base64
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django import http
|
from django import http
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
@ -171,10 +171,10 @@ class TestDetailServiceView(unittest.TestCase):
|
||||||
}
|
}
|
||||||
self.mock_request = mock.Mock(GET={})
|
self.mock_request = mock.Mock(GET={})
|
||||||
self.mock_request.user.service_catalog = None
|
self.mock_request.user.service_catalog = None
|
||||||
self.mock_request.is_ajax.return_value = True
|
|
||||||
self.mock_request.horizon = {
|
self.mock_request.horizon = {
|
||||||
'async_messages': [('tag', 'msg', 'extra')]
|
'async_messages': [('tag', 'msg', 'extra')]
|
||||||
}
|
}
|
||||||
|
mock.patch('horizon.utils.http.is_ajax', return_value=True).start()
|
||||||
self.detail_service_view.request = self.mock_request
|
self.detail_service_view.request = self.mock_request
|
||||||
|
|
||||||
self.assertEqual(env_tabs.ServicesTabs,
|
self.assertEqual(env_tabs.ServicesTabs,
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from muranodashboard.images import forms
|
from muranodashboard.images import forms
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from muranoclient.common import exceptions as exc
|
from muranoclient.common import exceptions as exc
|
||||||
from muranodashboard.packages import tables
|
from muranodashboard.packages import tables
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
from django.core.files import storage
|
from django.core.files import storage
|
||||||
from django import http
|
from django import http
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,9 @@ class TestApi(helpers.APITestCase):
|
||||||
'Unable to communicate to murano-api server.',
|
'Unable to communicate to murano-api server.',
|
||||||
'test_extra')]
|
'test_extra')]
|
||||||
mock_request = mock.MagicMock()
|
mock_request = mock.MagicMock()
|
||||||
mock_request.is_ajax.return_value = True
|
|
||||||
mock_request.horizon.__getitem__.return_value = async_messages
|
mock_request.horizon.__getitem__.return_value = async_messages
|
||||||
|
mock_is_ajax = mock.patch(
|
||||||
|
'horizon.utils.http.is_ajax', return_value=True).start()
|
||||||
try:
|
try:
|
||||||
with api.handled_exceptions(mock_request):
|
with api.handled_exceptions(mock_request):
|
||||||
raise api.exc.CommunicationError()
|
raise api.exc.CommunicationError()
|
||||||
|
@ -116,7 +117,7 @@ class TestApi(helpers.APITestCase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
mock_exc.handle.assert_called_once_with(mock_request, ignore=True)
|
mock_exc.handle.assert_called_once_with(mock_request, ignore=True)
|
||||||
self.assertTrue(mock_request.is_ajax.called)
|
self.assertTrue(mock_is_ajax.called)
|
||||||
self.assertTrue(mock_request.horizon.__getitem__.called)
|
self.assertTrue(mock_request.horizon.__getitem__.called)
|
||||||
|
|
||||||
def test_muranoclient(self):
|
def test_muranoclient(self):
|
||||||
|
|
Loading…
Reference in New Issue