Use python3-style super()
In python3, super() does not always require a class and self reference. In other words, super() is enough for most cases. This is much simpler and it is time to switch it to the newer style. pylint provides a check for this. Let's enable 'super-with-arguments' check. NOTE: _prepare_mappings() method of FormRegion in openstack_dashboard/test/integration_tests/regions/forms.py is refactored. super() (without explicit class and self referece) does not work when a subclass method calls a same method in a parent class multiple times. It looks better to prepare a separate method to provide a common logic. Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
This commit is contained in:
parent
74df97f57c
commit
e5d09edc20
@ -56,8 +56,6 @@ disable=
|
|||||||
inconsistent-return-statements, # TODO
|
inconsistent-return-statements, # TODO
|
||||||
interface-not-implemented,
|
interface-not-implemented,
|
||||||
no-self-use,
|
no-self-use,
|
||||||
# python3 way: Let's do it once we have a consensus.
|
|
||||||
super-with-arguments, # TODO
|
|
||||||
too-many-ancestors,
|
too-many-ancestors,
|
||||||
too-many-arguments,
|
too-many-arguments,
|
||||||
too-many-branches,
|
too-many-branches,
|
||||||
|
@ -108,7 +108,7 @@ class HorizonComponent(object):
|
|||||||
policy_rules = tuple()
|
policy_rules = tuple()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(HorizonComponent, self).__init__()
|
super().__init__()
|
||||||
if not self.slug:
|
if not self.slug:
|
||||||
raise ImproperlyConfigured('Every %s must have a slug.'
|
raise ImproperlyConfigured('Every %s must have a slug.'
|
||||||
% self.__class__)
|
% self.__class__)
|
||||||
@ -476,7 +476,7 @@ class Dashboard(Registry, HorizonComponent):
|
|||||||
return "<Dashboard: %s>" % self.slug
|
return "<Dashboard: %s>" % self.slug
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Dashboard, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._panel_groups = None
|
self._panel_groups = None
|
||||||
|
|
||||||
def get_panel(self, panel):
|
def get_panel(self, panel):
|
||||||
@ -1023,8 +1023,7 @@ class HorizonSite(Site):
|
|||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if not cls._instance:
|
if not cls._instance:
|
||||||
cls._instance = super(HorizonSite, cls).__new__(cls,
|
cls._instance = super().__new__(cls, *args, **kwargs)
|
||||||
*args, **kwargs)
|
|
||||||
return cls._instance
|
return cls._instance
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class ResourceBrowser(html.HTMLElement):
|
|||||||
breadcrumb_url = None
|
breadcrumb_url = None
|
||||||
|
|
||||||
def __init__(self, request, tables_dict=None, attrs=None, **kwargs):
|
def __init__(self, request, tables_dict=None, attrs=None, **kwargs):
|
||||||
super(ResourceBrowser, self).__init__()
|
super().__init__()
|
||||||
self.name = self.name or self.__class__.__name__
|
self.name = self.name or self.__class__.__name__
|
||||||
self.verbose_name = self.verbose_name or self.name.title()
|
self.verbose_name = self.verbose_name or self.name.title()
|
||||||
self.request = request
|
self.request = request
|
||||||
|
@ -20,7 +20,7 @@ from horizon.utils import html
|
|||||||
class Breadcrumb(html.HTMLElement):
|
class Breadcrumb(html.HTMLElement):
|
||||||
def __init__(self, request, template, root,
|
def __init__(self, request, template, root,
|
||||||
subfolder_path, url, attr=None):
|
subfolder_path, url, attr=None):
|
||||||
super(Breadcrumb, self).__init__()
|
super().__init__()
|
||||||
self.template = template
|
self.template = template
|
||||||
self.request = request
|
self.request = request
|
||||||
self.root = root
|
self.root = root
|
||||||
|
@ -32,7 +32,7 @@ class ResourceBrowserView(MultiTableView):
|
|||||||
self.table_classes = (self.browser_class.navigation_table_class,
|
self.table_classes = (self.browser_class.navigation_table_class,
|
||||||
self.browser_class.content_table_class)
|
self.browser_class.content_table_class)
|
||||||
self.navigation_selection = False
|
self.navigation_selection = False
|
||||||
super(ResourceBrowserView, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
@memoized.memoized_method
|
@memoized.memoized_method
|
||||||
def get_browser(self):
|
def get_browser(self):
|
||||||
@ -45,7 +45,7 @@ class ResourceBrowserView(MultiTableView):
|
|||||||
return browser
|
return browser
|
||||||
|
|
||||||
def get_tables(self):
|
def get_tables(self):
|
||||||
tables = super(ResourceBrowserView, self).get_tables()
|
tables = super().get_tables()
|
||||||
# Tells the navigation table what is selected.
|
# Tells the navigation table what is selected.
|
||||||
navigation_table = tables[
|
navigation_table = tables[
|
||||||
self.browser_class.navigation_table_class._meta.name]
|
self.browser_class.navigation_table_class._meta.name]
|
||||||
@ -55,7 +55,7 @@ class ResourceBrowserView(MultiTableView):
|
|||||||
return tables
|
return tables
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ResourceBrowserView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
browser = self.get_browser()
|
browser = self.get_browser()
|
||||||
context["%s_browser" % browser.name] = browser
|
context["%s_browser" % browser.name] = browser
|
||||||
return context
|
return context
|
||||||
@ -78,7 +78,7 @@ class AngularIndexView(generic.TemplateView):
|
|||||||
page_title = None
|
page_title = None
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AngularIndexView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["title"] = self.title
|
context["title"] = self.title
|
||||||
context["csrf_http"] = settings.CSRF_COOKIE_HTTPONLY
|
context["csrf_http"] = settings.CSRF_COOKIE_HTTPONLY
|
||||||
if self.page_title is None:
|
if self.page_title is None:
|
||||||
@ -97,7 +97,7 @@ class AngularDetailsView(generic.TemplateView):
|
|||||||
template_name = 'angular.html'
|
template_name = 'angular.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AngularDetailsView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
# some parameters are needed for navigation side bar and breadcrumb.
|
# some parameters are needed for navigation side bar and breadcrumb.
|
||||||
title = _("Horizon")
|
title = _("Horizon")
|
||||||
context["title"] = title
|
context["title"] = title
|
||||||
|
@ -22,7 +22,7 @@ class HorizonStaticFinder(AppDirectoriesFinder):
|
|||||||
"""Static files finder that also looks into the directory of each panel."""
|
"""Static files finder that also looks into the directory of each panel."""
|
||||||
|
|
||||||
def __init__(self, app_names=None, *args, **kwargs):
|
def __init__(self, app_names=None, *args, **kwargs):
|
||||||
super(HorizonStaticFinder, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
app_configs = apps.get_app_configs()
|
app_configs = apps.get_app_configs()
|
||||||
for app_config in app_configs:
|
for app_config in app_configs:
|
||||||
if 'openstack_dashboard' in app_config.path:
|
if 'openstack_dashboard' in app_config.path:
|
||||||
|
@ -108,7 +108,7 @@ class ServiceCatalogException(HorizonException):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, service_name):
|
def __init__(self, service_name):
|
||||||
message = _('Invalid service catalog: %s') % service_name
|
message = _('Invalid service catalog: %s') % service_name
|
||||||
super(ServiceCatalogException, self).__init__(message)
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
class AlreadyExists(HorizonException):
|
class AlreadyExists(HorizonException):
|
||||||
|
@ -26,7 +26,7 @@ class SelfHandlingMixin(object):
|
|||||||
if not hasattr(self, "handle"):
|
if not hasattr(self, "handle"):
|
||||||
raise NotImplementedError("%s does not define a handle method."
|
raise NotImplementedError("%s does not define a handle method."
|
||||||
% self.__class__.__name__)
|
% self.__class__.__name__)
|
||||||
super(SelfHandlingMixin, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class SelfHandlingForm(SelfHandlingMixin, forms.Form):
|
class SelfHandlingForm(SelfHandlingMixin, forms.Form):
|
||||||
@ -56,6 +56,6 @@ class DateForm(forms.Form):
|
|||||||
end = forms.DateField(input_formats=("%Y-%m-%d",))
|
end = forms.DateField(input_formats=("%Y-%m-%d",))
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DateForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['start'].widget.attrs['data-date-format'] = "yyyy-mm-dd"
|
self.fields['start'].widget.attrs['data-date-format'] = "yyyy-mm-dd"
|
||||||
self.fields['end'].widget.attrs['data-date-format'] = "yyyy-mm-dd"
|
self.fields['end'].widget.attrs['data-date-format'] = "yyyy-mm-dd"
|
||||||
|
@ -80,10 +80,10 @@ class IPField(fields.Field):
|
|||||||
self.min_mask = kwargs.pop("mask_range_from", 0)
|
self.min_mask = kwargs.pop("mask_range_from", 0)
|
||||||
self.version = kwargs.pop('version', IPv4)
|
self.version = kwargs.pop('version', IPv4)
|
||||||
|
|
||||||
super(IPField, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
super(IPField, self).validate(value)
|
super().validate(value)
|
||||||
if not value and not self.required:
|
if not value and not self.required:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class IPField(fields.Field):
|
|||||||
raise ValidationError(self.invalid_mask_message)
|
raise ValidationError(self.invalid_mask_message)
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
super(IPField, self).clean(value)
|
super().clean(value)
|
||||||
return str(getattr(self, "ip", ""))
|
return str(getattr(self, "ip", ""))
|
||||||
|
|
||||||
|
|
||||||
@ -120,13 +120,13 @@ class MultiIPField(IPField):
|
|||||||
if value:
|
if value:
|
||||||
addresses = value.split(',')
|
addresses = value.split(',')
|
||||||
for ip in addresses:
|
for ip in addresses:
|
||||||
super(MultiIPField, self).validate(ip)
|
super().validate(ip)
|
||||||
self.addresses.append(ip)
|
self.addresses.append(ip)
|
||||||
else:
|
else:
|
||||||
super(MultiIPField, self).validate(value)
|
super().validate(value)
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
super(MultiIPField, self).clean(value)
|
super().clean(value)
|
||||||
return str(','.join(getattr(self, "addresses", [])))
|
return str(','.join(getattr(self, "addresses", [])))
|
||||||
|
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class MACAddressField(fields.Field):
|
|||||||
.. xxxx.xxxx.xxxx
|
.. xxxx.xxxx.xxxx
|
||||||
"""
|
"""
|
||||||
def validate(self, value):
|
def validate(self, value):
|
||||||
super(MACAddressField, self).validate(value)
|
super().validate(value)
|
||||||
|
|
||||||
if not value:
|
if not value:
|
||||||
return
|
return
|
||||||
@ -153,7 +153,7 @@ class MACAddressField(fields.Field):
|
|||||||
code="invalid_mac")
|
code="invalid_mac")
|
||||||
|
|
||||||
def clean(self, value):
|
def clean(self, value):
|
||||||
super(MACAddressField, self).clean(value)
|
super().clean(value)
|
||||||
return str(getattr(self, "mac_address", ""))
|
return str(getattr(self, "mac_address", ""))
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ class SelectWidget(widgets.Widget):
|
|||||||
self.data_attrs = data_attrs
|
self.data_attrs = data_attrs
|
||||||
self.transform = transform
|
self.transform = transform
|
||||||
self.transform_html_attrs = transform_html_attrs
|
self.transform_html_attrs = transform_html_attrs
|
||||||
super(SelectWidget, self).__init__(attrs)
|
super().__init__(attrs)
|
||||||
|
|
||||||
def render(self, name, value, attrs=None, renderer=None):
|
def render(self, name, value, attrs=None, renderer=None):
|
||||||
if value is None:
|
if value is None:
|
||||||
@ -356,7 +356,7 @@ class DynamicSelectWidget(SelectWidget):
|
|||||||
add_item_url = self.get_add_item_url()
|
add_item_url = self.get_add_item_url()
|
||||||
if add_item_url is not None:
|
if add_item_url is not None:
|
||||||
self.attrs[self._data_add_url_attr] = add_item_url
|
self.attrs[self._data_add_url_attr] = add_item_url
|
||||||
return super(DynamicSelectWidget, self).render(*args, **kwargs)
|
return super().render(*args, **kwargs)
|
||||||
|
|
||||||
def get_add_item_url(self):
|
def get_add_item_url(self):
|
||||||
if callable(self.add_item_link):
|
if callable(self.add_item_link):
|
||||||
@ -393,7 +393,7 @@ class DynamicChoiceField(fields.ChoiceField):
|
|||||||
add_item_link_args=None,
|
add_item_link_args=None,
|
||||||
*args,
|
*args,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
super(DynamicChoiceField, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.widget.add_item_link = add_item_link
|
self.widget.add_item_link = add_item_link
|
||||||
self.widget.add_item_link_args = add_item_link_args
|
self.widget.add_item_link_args = add_item_link_args
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ class ThemableCheckboxInput(widgets.CheckboxInput):
|
|||||||
|
|
||||||
return html.format_html(
|
return html.format_html(
|
||||||
u'<div class="themable-checkbox">{}<label for="{}"></label></div>',
|
u'<div class="themable-checkbox">{}<label for="{}"></label></div>',
|
||||||
super(ThemableCheckboxInput, self).render(name, value, attrs),
|
super().render(name, value, attrs),
|
||||||
label_for
|
label_for
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ class ThemableCheckboxChoiceInput(ChoiceInput):
|
|||||||
input_type = 'checkbox'
|
input_type = 'checkbox'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ThemableCheckboxChoiceInput, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
# NOTE(e0ne): Django sets default value to None
|
# NOTE(e0ne): Django sets default value to None
|
||||||
if self.value:
|
if self.value:
|
||||||
self.value = set(force_text(v) for v in self.value)
|
self.value = set(force_text(v) for v in self.value)
|
||||||
@ -601,7 +601,7 @@ class ExternalFileField(fields.FileField):
|
|||||||
paired with ExternalUploadMeta metaclass embedded into the Form class.
|
paired with ExternalUploadMeta metaclass embedded into the Form class.
|
||||||
"""
|
"""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ExternalFileField, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.widget.attrs.update({'data-external-upload': 'true'})
|
self.widget.attrs.update({'data-external-upload': 'true'})
|
||||||
|
|
||||||
|
|
||||||
@ -651,5 +651,4 @@ class ExternalUploadMeta(forms.DeclarativeFieldsMetaclass):
|
|||||||
new_attrs[new_attr_name] = hidden_field
|
new_attrs[new_attr_name] = hidden_field
|
||||||
meth_name = 'clean_' + new_attr_name
|
meth_name = 'clean_' + new_attr_name
|
||||||
new_attrs[meth_name] = make_clean_method(new_attr_name)
|
new_attrs[meth_name] = make_clean_method(new_attr_name)
|
||||||
return super(ExternalUploadMeta, cls).__new__(
|
return super().__new__(cls, name, bases, new_attrs)
|
||||||
cls, name, bases, new_attrs)
|
|
||||||
|
@ -46,13 +46,13 @@ class ModalBackdropMixin(object):
|
|||||||
modal_backdrop = 'static'
|
modal_backdrop = 'static'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ModalBackdropMixin, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
config = settings.HORIZON_CONFIG
|
config = settings.HORIZON_CONFIG
|
||||||
if 'modal_backdrop' in config:
|
if 'modal_backdrop' in config:
|
||||||
self.modal_backdrop = config['modal_backdrop']
|
self.modal_backdrop = config['modal_backdrop']
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ModalBackdropMixin, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['modal_backdrop'] = self.modal_backdrop
|
context['modal_backdrop'] = self.modal_backdrop
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class ModalFormMixin(ModalBackdropMixin):
|
|||||||
return template
|
return template
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ModalFormMixin, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
if self.request.is_ajax():
|
if self.request.is_ajax():
|
||||||
context['hide'] = True
|
context['hide'] = True
|
||||||
if ADD_TO_FIELD_HEADER in self.request.META:
|
if ADD_TO_FIELD_HEADER in self.request.META:
|
||||||
@ -140,7 +140,7 @@ class ModalFormView(ModalFormMixin, views.HorizonFormView):
|
|||||||
cancel_url = None
|
cancel_url = None
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ModalFormView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['modal_id'] = self.modal_id
|
context['modal_id'] = self.modal_id
|
||||||
context['modal_header'] = self.modal_header
|
context['modal_header'] = self.modal_header
|
||||||
context['form_id'] = self.form_id
|
context['form_id'] = self.form_id
|
||||||
|
@ -59,7 +59,7 @@ class Command(TemplateCommand):
|
|||||||
"Python module and cannot be used as an app "
|
"Python module and cannot be used as an app "
|
||||||
"name. Please try another name." % dash_name)
|
"name. Please try another name." % dash_name)
|
||||||
|
|
||||||
super(Command, self).handle('dash', dash_name, **options)
|
super().handle('dash', dash_name, **options)
|
||||||
|
|
||||||
target = options.pop("target", None)
|
target = options.pop("target", None)
|
||||||
if not target:
|
if not target:
|
||||||
|
@ -92,7 +92,7 @@ class Command(TemplateCommand):
|
|||||||
"Python module and cannot be used as an app "
|
"Python module and cannot be used as an app "
|
||||||
"name. Please try another name." % panel_name)
|
"name. Please try another name." % panel_name)
|
||||||
|
|
||||||
super(Command, self).handle('panel', panel_name, target, **options)
|
super().handle('panel', panel_name, target, **options)
|
||||||
|
|
||||||
if not target:
|
if not target:
|
||||||
target = os.path.join(os.curdir, panel_name)
|
target = os.path.join(os.curdir, panel_name)
|
||||||
|
@ -76,8 +76,7 @@ class BaseActionMetaClass(type):
|
|||||||
def __call__(cls, *args, **kwargs):
|
def __call__(cls, *args, **kwargs):
|
||||||
cls.base_options.update(kwargs)
|
cls.base_options.update(kwargs)
|
||||||
# Adding cls.base_options to each init call.
|
# Adding cls.base_options to each init call.
|
||||||
klass = super(BaseActionMetaClass, cls).__call__(
|
klass = super().__call__(*args, **cls.base_options)
|
||||||
*args, **cls.base_options)
|
|
||||||
return klass
|
return klass
|
||||||
|
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ class BaseAction(html.HTMLElement, metaclass=BaseActionMetaClass):
|
|||||||
"""Common base class for all ``Action`` classes."""
|
"""Common base class for all ``Action`` classes."""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(BaseAction, self).__init__()
|
super().__init__()
|
||||||
self.datum = kwargs.get('datum', None)
|
self.datum = kwargs.get('datum', None)
|
||||||
self.table = kwargs.get('table', None)
|
self.table = kwargs.get('table', None)
|
||||||
self.handles_multiple = kwargs.get('handles_multiple', False)
|
self.handles_multiple = kwargs.get('handles_multiple', False)
|
||||||
@ -258,7 +257,7 @@ class Action(BaseAction):
|
|||||||
|
|
||||||
def __init__(self, single_func=None, multiple_func=None, handle_func=None,
|
def __init__(self, single_func=None, multiple_func=None, handle_func=None,
|
||||||
attrs=None, **kwargs):
|
attrs=None, **kwargs):
|
||||||
super(Action, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
self.method = kwargs.get('method', "POST")
|
self.method = kwargs.get('method', "POST")
|
||||||
self.requires_input = kwargs.get('requires_input', True)
|
self.requires_input = kwargs.get('requires_input', True)
|
||||||
@ -344,7 +343,7 @@ class LinkAction(BaseAction):
|
|||||||
ajax = False
|
ajax = False
|
||||||
|
|
||||||
def __init__(self, attrs=None, **kwargs):
|
def __init__(self, attrs=None, **kwargs):
|
||||||
super(LinkAction, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.method = kwargs.get('method', "GET")
|
self.method = kwargs.get('method', "GET")
|
||||||
self.bound_url = kwargs.get('bound_url', None)
|
self.bound_url = kwargs.get('bound_url', None)
|
||||||
self.name = kwargs.get('name', self.name)
|
self.name = kwargs.get('name', self.name)
|
||||||
@ -377,7 +376,7 @@ class LinkAction(BaseAction):
|
|||||||
action_dict)
|
action_dict)
|
||||||
|
|
||||||
def associate_with_table(self, table):
|
def associate_with_table(self, table):
|
||||||
super(LinkAction, self).associate_with_table(table)
|
super().associate_with_table(table)
|
||||||
if self.ajax:
|
if self.ajax:
|
||||||
self.attrs['data-update-url'] = self.get_ajax_update_url()
|
self.attrs['data-update-url'] = self.get_ajax_update_url()
|
||||||
|
|
||||||
@ -468,7 +467,7 @@ class FilterAction(BaseAction):
|
|||||||
name = "filter"
|
name = "filter"
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(FilterAction, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.method = kwargs.get('method', "POST")
|
self.method = kwargs.get('method', "POST")
|
||||||
self.name = kwargs.get('name', self.name)
|
self.name = kwargs.get('name', self.name)
|
||||||
self.verbose_name = kwargs.get('verbose_name', _("Filter"))
|
self.verbose_name = kwargs.get('verbose_name', _("Filter"))
|
||||||
@ -560,7 +559,7 @@ class FixedFilterAction(FilterAction):
|
|||||||
"""A filter action with fixed buttons."""
|
"""A filter action with fixed buttons."""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(FixedFilterAction, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.filter_type = kwargs.get('filter_type', "fixed")
|
self.filter_type = kwargs.get('filter_type', "fixed")
|
||||||
self.needs_preloading = kwargs.get('needs_preloading', True)
|
self.needs_preloading = kwargs.get('needs_preloading', True)
|
||||||
|
|
||||||
@ -654,7 +653,7 @@ class BatchAction(Action):
|
|||||||
default_message_level = "success"
|
default_message_level = "success"
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(BatchAction, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
action_present_method = callable(getattr(self, 'action_present', None))
|
action_present_method = callable(getattr(self, 'action_present', None))
|
||||||
action_past_method = callable(getattr(self, 'action_past', None))
|
action_past_method = callable(getattr(self, 'action_past', None))
|
||||||
@ -687,7 +686,7 @@ class BatchAction(Action):
|
|||||||
action = request.GET.get('action')
|
action = request.GET.get('action')
|
||||||
if action != 'row_update' and not self.table.data and not datum:
|
if action != 'row_update' and not self.table.data and not datum:
|
||||||
return False
|
return False
|
||||||
return super(BatchAction, self)._allowed(request, datum)
|
return super()._allowed(request, datum)
|
||||||
|
|
||||||
def _get_action_name(self, items=None, past=False):
|
def _get_action_name(self, items=None, past=False):
|
||||||
"""Retreive action name based on the number of items and `past` flag.
|
"""Retreive action name based on the number of items and `past` flag.
|
||||||
@ -746,7 +745,7 @@ class BatchAction(Action):
|
|||||||
|
|
||||||
def get_default_attrs(self):
|
def get_default_attrs(self):
|
||||||
"""Returns a list of the default HTML attributes for the action."""
|
"""Returns a list of the default HTML attributes for the action."""
|
||||||
attrs = super(BatchAction, self).get_default_attrs()
|
attrs = super().get_default_attrs()
|
||||||
attrs.update({'data-batch-action': 'true'})
|
attrs.update({'data-batch-action': 'true'})
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
@ -869,7 +868,7 @@ class DeleteAction(BatchAction):
|
|||||||
name = "delete"
|
name = "delete"
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(DeleteAction, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.name = kwargs.get('name', self.name)
|
self.name = kwargs.get('name', self.name)
|
||||||
self.icon = "trash"
|
self.icon = "trash"
|
||||||
self.action_type = "danger"
|
self.action_type = "danger"
|
||||||
|
@ -305,7 +305,7 @@ class Column(html.HTMLElement):
|
|||||||
|
|
||||||
allowed_data_types = allowed_data_types or []
|
allowed_data_types = allowed_data_types or []
|
||||||
self.classes = list(classes or getattr(self, "classes", []))
|
self.classes = list(classes or getattr(self, "classes", []))
|
||||||
super(Column, self).__init__()
|
super().__init__()
|
||||||
self.attrs.update(attrs or {})
|
self.attrs.update(attrs or {})
|
||||||
|
|
||||||
if callable(transform):
|
if callable(transform):
|
||||||
@ -478,7 +478,7 @@ class Column(html.HTMLElement):
|
|||||||
|
|
||||||
if settings.INTEGRATION_TESTS_SUPPORT:
|
if settings.INTEGRATION_TESTS_SUPPORT:
|
||||||
def get_default_attrs(self):
|
def get_default_attrs(self):
|
||||||
attrs = super(Column, self).get_default_attrs()
|
attrs = super().get_default_attrs()
|
||||||
attrs.update({'data-selenium': self.name})
|
attrs.update({'data-selenium': self.name})
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ class WrappingColumn(Column):
|
|||||||
"""A column that wraps its contents. Useful for data like UUIDs or names"""
|
"""A column that wraps its contents. Useful for data like UUIDs or names"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(WrappingColumn, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.classes.append('word-break')
|
self.classes.append('word-break')
|
||||||
|
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ class Row(html.HTMLElement):
|
|||||||
ajax_cell_action_name = "cell_update"
|
ajax_cell_action_name = "cell_update"
|
||||||
|
|
||||||
def __init__(self, table, datum=None):
|
def __init__(self, table, datum=None):
|
||||||
super(Row, self).__init__()
|
super().__init__()
|
||||||
self.table = table
|
self.table = table
|
||||||
self.datum = datum
|
self.datum = datum
|
||||||
self.selected = False
|
self.selected = False
|
||||||
@ -709,7 +709,7 @@ class Cell(html.HTMLElement):
|
|||||||
|
|
||||||
def __init__(self, datum, column, row, attrs=None, classes=None):
|
def __init__(self, datum, column, row, attrs=None, classes=None):
|
||||||
self.classes = classes or getattr(self, "classes", [])
|
self.classes = classes or getattr(self, "classes", [])
|
||||||
super(Cell, self).__init__()
|
super().__init__()
|
||||||
self.attrs.update(attrs or {})
|
self.attrs.update(attrs or {})
|
||||||
|
|
||||||
self.datum = datum
|
self.datum = datum
|
||||||
|
@ -27,7 +27,7 @@ class FormsetCell(horizon_tables.Cell):
|
|||||||
"""A DataTable cell that knows about its field from the formset."""
|
"""A DataTable cell that knows about its field from the formset."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FormsetCell, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
try:
|
try:
|
||||||
self.field = (self.row.form or {})[self.column.name]
|
self.field = (self.row.form or {})[self.column.name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -46,7 +46,7 @@ class FormsetRow(horizon_tables.Row):
|
|||||||
|
|
||||||
def __init__(self, column, datum, form):
|
def __init__(self, column, datum, form):
|
||||||
self.form = form
|
self.form = form
|
||||||
super(FormsetRow, self).__init__(column, datum)
|
super().__init__(column, datum)
|
||||||
if not self.cells:
|
if not self.cells:
|
||||||
# We need to be able to handle empty rows, because there may
|
# We need to be able to handle empty rows, because there may
|
||||||
# be extra empty forms in a formset. The original DataTable breaks
|
# be extra empty forms in a formset. The original DataTable breaks
|
||||||
@ -72,7 +72,7 @@ class FormsetDataTableMixin(object):
|
|||||||
formset_class = None
|
formset_class = None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(FormsetDataTableMixin, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._formset = None
|
self._formset = None
|
||||||
|
|
||||||
# Override Meta settings, because we need custom Form and Cell classes,
|
# Override Meta settings, because we need custom Form and Cell classes,
|
||||||
@ -151,7 +151,7 @@ class FormsetDataTableMixin(object):
|
|||||||
# We need to support ``None`` when there are more forms than data.
|
# We need to support ``None`` when there are more forms than data.
|
||||||
if datum is None:
|
if datum is None:
|
||||||
return None
|
return None
|
||||||
return super(FormsetDataTableMixin, self).get_object_id(datum)
|
return super().get_object_id(datum)
|
||||||
|
|
||||||
|
|
||||||
class FormsetDataTable(FormsetDataTableMixin, horizon_tables.DataTable):
|
class FormsetDataTable(FormsetDataTableMixin, horizon_tables.DataTable):
|
||||||
|
@ -26,7 +26,7 @@ class MultiTableMixin(object):
|
|||||||
data_method_pattern = "get_%s_data"
|
data_method_pattern = "get_%s_data"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MultiTableMixin, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.table_classes = getattr(self, "table_classes", [])
|
self.table_classes = getattr(self, "table_classes", [])
|
||||||
self._data = {}
|
self._data = {}
|
||||||
self._tables = {}
|
self._tables = {}
|
||||||
@ -102,7 +102,7 @@ class MultiTableMixin(object):
|
|||||||
return self._tables
|
return self._tables
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(MultiTableMixin, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
tables = self.get_tables()
|
tables = self.get_tables()
|
||||||
for name, table in tables.items():
|
for name, table in tables.items():
|
||||||
context["%s_table" % name] = table
|
context["%s_table" % name] = table
|
||||||
@ -274,7 +274,7 @@ class DataTableView(MultiTableView):
|
|||||||
return self.table
|
return self.table
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DataTableView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
if hasattr(self, "table"):
|
if hasattr(self, "table"):
|
||||||
context[self.context_object_name] = self.table
|
context[self.context_object_name] = self.table
|
||||||
return context
|
return context
|
||||||
@ -354,7 +354,7 @@ class MixedDataTableView(DataTableView):
|
|||||||
type_string)
|
type_string)
|
||||||
|
|
||||||
def get_table(self):
|
def get_table(self):
|
||||||
self.table = super(MixedDataTableView, self).get_table()
|
self.table = super().get_table()
|
||||||
if not self.table._meta.mixed_data_type:
|
if not self.table._meta.mixed_data_type:
|
||||||
raise AttributeError('You must have at least two elements in '
|
raise AttributeError('You must have at least two elements in '
|
||||||
'the data_types attribute '
|
'the data_types attribute '
|
||||||
@ -365,7 +365,7 @@ class MixedDataTableView(DataTableView):
|
|||||||
|
|
||||||
class PagedTableMixin(object):
|
class PagedTableMixin(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PagedTableMixin, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._has_prev_data = False
|
self._has_prev_data = False
|
||||||
self._has_more_data = False
|
self._has_more_data = False
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ class PagedTableMixin(object):
|
|||||||
|
|
||||||
class PagedTableWithPageMenu(object):
|
class PagedTableWithPageMenu(object):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PagedTableWithPageMenu, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._current_page = 1
|
self._current_page = 1
|
||||||
self._number_of_pages = 0
|
self._number_of_pages = 0
|
||||||
self._total_of_entries = 0
|
self._total_of_entries = 0
|
||||||
@ -401,7 +401,7 @@ class PagedTableWithPageMenu(object):
|
|||||||
name = table.name
|
name = table.name
|
||||||
self._tables[name]._meta.current_page = self.current_page
|
self._tables[name]._meta.current_page = self.current_page
|
||||||
self._tables[name]._meta.number_of_pages = self.number_of_pages
|
self._tables[name]._meta.number_of_pages = self.number_of_pages
|
||||||
return super(PagedTableWithPageMenu, self).handle_table(table)
|
return super().handle_table(table)
|
||||||
|
|
||||||
def has_prev_data(self, table):
|
def has_prev_data(self, table):
|
||||||
return self._current_page > 1
|
return self._current_page > 1
|
||||||
|
@ -102,7 +102,7 @@ class TabGroup(html.HTMLElement):
|
|||||||
return self._active
|
return self._active
|
||||||
|
|
||||||
def __init__(self, request, **kwargs):
|
def __init__(self, request, **kwargs):
|
||||||
super(TabGroup, self).__init__()
|
super().__init__()
|
||||||
if not hasattr(self, "tabs"):
|
if not hasattr(self, "tabs"):
|
||||||
raise NotImplementedError('%s must declare a "tabs" attribute.'
|
raise NotImplementedError('%s must declare a "tabs" attribute.'
|
||||||
% self.__class__)
|
% self.__class__)
|
||||||
@ -187,7 +187,7 @@ class TabGroup(html.HTMLElement):
|
|||||||
|
|
||||||
Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``.
|
Defaults to ``["nav", "nav-tabs", "ajax-tabs"]``.
|
||||||
"""
|
"""
|
||||||
default_classes = super(TabGroup, self).get_default_classes()
|
default_classes = super().get_default_classes()
|
||||||
default_classes.extend(CSS_TAB_GROUP_CLASSES)
|
default_classes.extend(CSS_TAB_GROUP_CLASSES)
|
||||||
return default_classes
|
return default_classes
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ class Tab(html.HTMLElement):
|
|||||||
permissions = []
|
permissions = []
|
||||||
|
|
||||||
def __init__(self, tab_group, request=None):
|
def __init__(self, tab_group, request=None):
|
||||||
super(Tab, self).__init__()
|
super().__init__()
|
||||||
# Priority: constructor, class-defined, fallback
|
# Priority: constructor, class-defined, fallback
|
||||||
if not self.name:
|
if not self.name:
|
||||||
raise ValueError("%s must have a name." % self.__class__.__name__)
|
raise ValueError("%s must have a name." % self.__class__.__name__)
|
||||||
@ -393,7 +393,7 @@ class Tab(html.HTMLElement):
|
|||||||
If the tab is not enabled, the classes the class ``"disabled"``
|
If the tab is not enabled, the classes the class ``"disabled"``
|
||||||
will be added.
|
will be added.
|
||||||
"""
|
"""
|
||||||
default_classes = super(Tab, self).get_default_classes()
|
default_classes = super().get_default_classes()
|
||||||
if self.is_active():
|
if self.is_active():
|
||||||
default_classes.extend(CSS_ACTIVE_TAB_CLASSES)
|
default_classes.extend(CSS_ACTIVE_TAB_CLASSES)
|
||||||
if not self._enabled:
|
if not self._enabled:
|
||||||
@ -471,7 +471,7 @@ class TableTab(Tab):
|
|||||||
table_classes = []
|
table_classes = []
|
||||||
|
|
||||||
def __init__(self, tab_group, request):
|
def __init__(self, tab_group, request):
|
||||||
super(TableTab, self).__init__(tab_group, request)
|
super().__init__(tab_group, request)
|
||||||
if not self.table_classes:
|
if not self.table_classes:
|
||||||
class_name = self.__class__.__name__
|
class_name = self.__class__.__name__
|
||||||
raise NotImplementedError("You must define a table_class "
|
raise NotImplementedError("You must define a table_class "
|
||||||
@ -522,7 +522,7 @@ class TableTab(Tab):
|
|||||||
If only one table class is provided, a shortcut ``table`` context
|
If only one table class is provided, a shortcut ``table`` context
|
||||||
variable is also added containing the single table.
|
variable is also added containing the single table.
|
||||||
"""
|
"""
|
||||||
context = super(TableTab, self).get_context_data(request, **kwargs)
|
context = super().get_context_data(request, **kwargs)
|
||||||
# If the data hasn't been manually loaded before now,
|
# If the data hasn't been manually loaded before now,
|
||||||
# make certain it's loaded before setting the context.
|
# make certain it's loaded before setting the context.
|
||||||
self.load_table_data()
|
self.load_table_data()
|
||||||
|
@ -45,7 +45,7 @@ class TabView(views.HorizonTemplateView):
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Adds the ``tab_group`` variable to the context data."""
|
"""Adds the ``tab_group`` variable to the context data."""
|
||||||
context = super(TabView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
try:
|
try:
|
||||||
tab_group = self.get_tabs(self.request, **kwargs)
|
tab_group = self.get_tabs(self.request, **kwargs)
|
||||||
context["tab_group"] = tab_group
|
context["tab_group"] = tab_group
|
||||||
@ -73,7 +73,7 @@ class TabView(views.HorizonTemplateView):
|
|||||||
|
|
||||||
class TabbedTableView(tables.MultiTableMixin, TabView):
|
class TabbedTableView(tables.MultiTableMixin, TabView):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(TabbedTableView, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.table_classes = []
|
self.table_classes = []
|
||||||
self._table_dict = {}
|
self._table_dict = {}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ class WebDriver(firefox.webdriver.WebDriver):
|
|||||||
# called from WebDriver.__init__, retry __init__.
|
# called from WebDriver.__init__, retry __init__.
|
||||||
for i in range(self.CONNREFUSED_RETRY_COUNT + 1):
|
for i in range(self.CONNREFUSED_RETRY_COUNT + 1):
|
||||||
try:
|
try:
|
||||||
super(WebDriver, self).__init__(
|
super().__init__(
|
||||||
firefox_profile, FirefoxBinary(), timeout,
|
firefox_profile, FirefoxBinary(), timeout,
|
||||||
desired_capabilities, proxy)
|
desired_capabilities, proxy)
|
||||||
if i > 0:
|
if i > 0:
|
||||||
|
@ -118,14 +118,14 @@ class SessionStore(SessionBase):
|
|||||||
|
|
||||||
class RequestFactoryWithMessages(RequestFactory):
|
class RequestFactoryWithMessages(RequestFactory):
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
req = super(RequestFactoryWithMessages, self).get(*args, **kwargs)
|
req = super().get(*args, **kwargs)
|
||||||
req.user = User()
|
req.user = User()
|
||||||
req.session = SessionStore()
|
req.session = SessionStore()
|
||||||
req._messages = default_storage(req)
|
req._messages = default_storage(req)
|
||||||
return req
|
return req
|
||||||
|
|
||||||
def post(self, *args, **kwargs):
|
def post(self, *args, **kwargs):
|
||||||
req = super(RequestFactoryWithMessages, self).post(*args, **kwargs)
|
req = super().post(*args, **kwargs)
|
||||||
req.user = User()
|
req.user = User()
|
||||||
req.session = SessionStore()
|
req.session = SessionStore()
|
||||||
req._messages = default_storage(req)
|
req._messages = default_storage(req)
|
||||||
@ -143,7 +143,7 @@ class TestCase(django_test.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCase, self).setUp()
|
super().setUp()
|
||||||
self._setup_test_data()
|
self._setup_test_data()
|
||||||
self._setup_factory()
|
self._setup_factory()
|
||||||
self._setup_user()
|
self._setup_user()
|
||||||
@ -171,7 +171,7 @@ class TestCase(django_test.TestCase):
|
|||||||
self.request.session = self.client.session
|
self.request.session = self.client.session
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestCase, self).tearDown()
|
super().tearDown()
|
||||||
del os.environ["HORIZON_TEST_RUN"]
|
del os.environ["HORIZON_TEST_RUN"]
|
||||||
|
|
||||||
def set_permissions(self, permissions=None):
|
def set_permissions(self, permissions=None):
|
||||||
@ -250,7 +250,7 @@ class SeleniumTestCase(LiveServerTestCase):
|
|||||||
cls.vdisplay = xvfbwrapper.Xvfb(width=1280, height=720)
|
cls.vdisplay = xvfbwrapper.Xvfb(width=1280, height=720)
|
||||||
cls.vdisplay.start()
|
cls.vdisplay.start()
|
||||||
cls.selenium = WebDriver()
|
cls.selenium = WebDriver()
|
||||||
super(SeleniumTestCase, cls).setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@ -259,13 +259,13 @@ class SeleniumTestCase(LiveServerTestCase):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if hasattr(cls, 'vdisplay'):
|
if hasattr(cls, 'vdisplay'):
|
||||||
cls.vdisplay.stop()
|
cls.vdisplay.stop()
|
||||||
super(SeleniumTestCase, cls).tearDownClass()
|
super().tearDownClass()
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
socket.setdefaulttimeout(60)
|
socket.setdefaulttimeout(60)
|
||||||
self.selenium.implicitly_wait(30)
|
self.selenium.implicitly_wait(30)
|
||||||
self.ui = selenium_ui
|
self.ui = selenium_ui
|
||||||
super(SeleniumTestCase, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
|
|
||||||
class JasmineTests(SeleniumTestCase):
|
class JasmineTests(SeleniumTestCase):
|
||||||
@ -351,7 +351,7 @@ class update_settings(django_test_utils.override_settings):
|
|||||||
copied = copy.copy(value)
|
copied = copy.copy(value)
|
||||||
copied.update(new_value)
|
copied.update(new_value)
|
||||||
kwargs[key] = copied
|
kwargs[key] = copied
|
||||||
super(update_settings, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
class IsA(object):
|
class IsA(object):
|
||||||
@ -366,4 +366,4 @@ class IsA(object):
|
|||||||
class IsHttpRequest(IsA):
|
class IsHttpRequest(IsA):
|
||||||
"""Class to compare param is django.http.HttpRequest."""
|
"""Class to compare param is django.http.HttpRequest."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(IsHttpRequest, self).__init__(http.HttpRequest)
|
super().__init__(http.HttpRequest)
|
||||||
|
@ -41,7 +41,7 @@ class LazyLoadedTabsTests(test.SeleniumTestCase):
|
|||||||
select_all_selector = 'th.multi_select_column input[type=checkbox]'
|
select_all_selector = 'th.multi_select_column input[type=checkbox]'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(LazyLoadedTabsTests, self).setUp()
|
super().setUp()
|
||||||
wait = self.ui.WebDriverWait(self.selenium, 120)
|
wait = self.ui.WebDriverWait(self.selenium, 120)
|
||||||
self.get_element = self.selenium.find_element_by_css_selector
|
self.get_element = self.selenium.find_element_by_css_selector
|
||||||
self.get_elements = self.selenium.find_elements_by_css_selector
|
self.get_elements = self.selenium.find_elements_by_css_selector
|
||||||
|
@ -227,7 +227,7 @@ class ChoiceFieldForm(forms.SelfHandlingForm):
|
|||||||
transform_html_attrs=title_dic.get))
|
transform_html_attrs=title_dic.get))
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(ChoiceFieldForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
choices = ([('choice1', 'label1'),
|
choices = ([('choice1', 'label1'),
|
||||||
('choice2', 'label2')])
|
('choice2', 'label2')])
|
||||||
self.fields['test_choices'].choices = choices
|
self.fields['test_choices'].choices = choices
|
||||||
@ -241,7 +241,7 @@ class ChoiceFieldTests(test.TestCase):
|
|||||||
template = 'horizon/common/_form_fields.html'
|
template = 'horizon/common/_form_fields.html'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ChoiceFieldTests, self).setUp()
|
super().setUp()
|
||||||
self.form = ChoiceFieldForm(self.request)
|
self.form = ChoiceFieldForm(self.request)
|
||||||
|
|
||||||
def _render_form(self):
|
def _render_form(self):
|
||||||
@ -282,7 +282,7 @@ class ThemableChoiceFieldForm(forms.SelfHandlingForm):
|
|||||||
transform_html_attrs=title_dic.get))
|
transform_html_attrs=title_dic.get))
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(ThemableChoiceFieldForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
choices = ([('choice1', 'label1'),
|
choices = ([('choice1', 'label1'),
|
||||||
('choice2', 'label2')])
|
('choice2', 'label2')])
|
||||||
self.fields['test_choices'].choices = choices
|
self.fields['test_choices'].choices = choices
|
||||||
@ -296,7 +296,7 @@ class ThemableChoiceFieldTests(test.TestCase):
|
|||||||
template = 'horizon/common/_form_fields.html'
|
template = 'horizon/common/_form_fields.html'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ThemableChoiceFieldTests, self).setUp()
|
super().setUp()
|
||||||
self.form = ThemableChoiceFieldForm(self.request)
|
self.form = ThemableChoiceFieldForm(self.request)
|
||||||
|
|
||||||
def _render_form(self):
|
def _render_form(self):
|
||||||
|
@ -80,7 +80,7 @@ class FormErrorTests(test.TestCase):
|
|||||||
template = 'horizon/common/_form_fields.html'
|
template = 'horizon/common/_form_fields.html'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(FormErrorTests, self).setUp()
|
super().setUp()
|
||||||
# Note(Itxaka): We pass data to the form so its bound and has the
|
# Note(Itxaka): We pass data to the form so its bound and has the
|
||||||
# proper cleaned_data fields
|
# proper cleaned_data fields
|
||||||
self.form = FormForTesting(self.request, data={'fake': 'data'})
|
self.form = FormForTesting(self.request, data={'fake': 'data'})
|
||||||
|
@ -35,11 +35,11 @@ class MiddlewareTests(django_test.TestCase):
|
|||||||
self._timezone_backup = timezone.get_current_timezone_name()
|
self._timezone_backup = timezone.get_current_timezone_name()
|
||||||
self.factory = test.RequestFactoryWithMessages()
|
self.factory = test.RequestFactoryWithMessages()
|
||||||
self.get_response = mock.Mock()
|
self.get_response = mock.Mock()
|
||||||
super(MiddlewareTests, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
timezone.activate(self._timezone_backup)
|
timezone.activate(self._timezone_backup)
|
||||||
super(MiddlewareTests, self).tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
def test_redirect_login_fail_to_login(self):
|
def test_redirect_login_fail_to_login(self):
|
||||||
url = settings.LOGIN_URL
|
url = settings.LOGIN_URL
|
||||||
|
@ -33,7 +33,7 @@ class OperationLogMiddlewareTest(django_test.TestCase):
|
|||||||
http_referer = u'/dashboard/test_http_referer'
|
http_referer = u'/dashboard/test_http_referer'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(OperationLogMiddlewareTest, self).setUp()
|
super().setUp()
|
||||||
self.factory = test.RequestFactoryWithMessages()
|
self.factory = test.RequestFactoryWithMessages()
|
||||||
|
|
||||||
def test_middleware_not_used(self):
|
def test_middleware_not_used(self):
|
||||||
|
@ -340,11 +340,11 @@ class TabTests(test.TestCase):
|
|||||||
|
|
||||||
class TabExceptionTests(test.TestCase):
|
class TabExceptionTests(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TabExceptionTests, self).setUp()
|
super().setUp()
|
||||||
self._original_tabs = copy.copy(TabWithTableView.tab_group_class.tabs)
|
self._original_tabs = copy.copy(TabWithTableView.tab_group_class.tabs)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TabExceptionTests, self).tearDown()
|
super().tearDown()
|
||||||
TabWithTableView.tab_group_class.tabs = self._original_tabs
|
TabWithTableView.tab_group_class.tabs = self._original_tabs
|
||||||
|
|
||||||
@override_settings(SESSION_REFRESH=False)
|
@override_settings(SESSION_REFRESH=False)
|
||||||
|
@ -70,7 +70,7 @@ class RbacYesAccessPanel(horizon.Panel):
|
|||||||
class BaseHorizonTests(test.TestCase):
|
class BaseHorizonTests(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseHorizonTests, self).setUp()
|
super().setUp()
|
||||||
# Adjust our horizon config and register our custom dashboards/panels.
|
# Adjust our horizon config and register our custom dashboards/panels.
|
||||||
self.old_default_dash = settings.HORIZON_CONFIG['default_dashboard']
|
self.old_default_dash = settings.HORIZON_CONFIG['default_dashboard']
|
||||||
settings.HORIZON_CONFIG['default_dashboard'] = 'cats'
|
settings.HORIZON_CONFIG['default_dashboard'] = 'cats'
|
||||||
@ -93,7 +93,7 @@ class BaseHorizonTests(test.TestCase):
|
|||||||
self._discovered_panels[dash] = panels
|
self._discovered_panels[dash] = panels
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(BaseHorizonTests, self).tearDown()
|
super().tearDown()
|
||||||
# Restore our settings
|
# Restore our settings
|
||||||
settings.HORIZON_CONFIG['default_dashboard'] = self.old_default_dash
|
settings.HORIZON_CONFIG['default_dashboard'] = self.old_default_dash
|
||||||
settings.HORIZON_CONFIG['dashboards'] = self.old_dashboards
|
settings.HORIZON_CONFIG['dashboards'] = self.old_dashboards
|
||||||
@ -349,12 +349,12 @@ class HorizonTests(BaseHorizonTests):
|
|||||||
settings.SECURE_PROXY_SSL_HEADER = None
|
settings.SECURE_PROXY_SSL_HEADER = None
|
||||||
|
|
||||||
|
|
||||||
class GetUserHomeTests(BaseHorizonTests):
|
class GetUserHomeTests(test.TestCase):
|
||||||
"""Test get_user_home parameters."""
|
"""Test get_user_home parameters."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.orig_user_home = settings.HORIZON_CONFIG['user_home']
|
self.orig_user_home = settings.HORIZON_CONFIG['user_home']
|
||||||
super(BaseHorizonTests, self).setUp()
|
super().setUp()
|
||||||
self.original_username = "testname"
|
self.original_username = "testname"
|
||||||
self.test_user = User()
|
self.test_user = User()
|
||||||
self.test_user.username = self.original_username
|
self.test_user.username = self.original_username
|
||||||
@ -362,6 +362,7 @@ class GetUserHomeTests(BaseHorizonTests):
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
settings.HORIZON_CONFIG['user_home'] = self.orig_user_home
|
settings.HORIZON_CONFIG['user_home'] = self.orig_user_home
|
||||||
conf.HORIZON_CONFIG._setup()
|
conf.HORIZON_CONFIG._setup()
|
||||||
|
super().tearDown()
|
||||||
|
|
||||||
def test_using_callable(self):
|
def test_using_callable(self):
|
||||||
def themable_user_fnc(user):
|
def themable_user_fnc(user):
|
||||||
@ -399,7 +400,7 @@ class CustomPanelTests(BaseHorizonTests):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CustomPanelTests, self).setUp()
|
super().setUp()
|
||||||
settings.HORIZON_CONFIG['customization_module'] = \
|
settings.HORIZON_CONFIG['customization_module'] = \
|
||||||
'horizon.test.customization.cust_test1'
|
'horizon.test.customization.cust_test1'
|
||||||
# refresh config
|
# refresh config
|
||||||
@ -414,7 +415,7 @@ class CustomPanelTests(BaseHorizonTests):
|
|||||||
self._discovered_dashboards.append(Dogs)
|
self._discovered_dashboards.append(Dogs)
|
||||||
Dogs.register(Puppies)
|
Dogs.register(Puppies)
|
||||||
Cats.register(Tigers)
|
Cats.register(Tigers)
|
||||||
super(CustomPanelTests, self).tearDown()
|
super().tearDown()
|
||||||
settings.HORIZON_CONFIG.pop('customization_module')
|
settings.HORIZON_CONFIG.pop('customization_module')
|
||||||
# refresh config
|
# refresh config
|
||||||
conf.HORIZON_CONFIG._setup()
|
conf.HORIZON_CONFIG._setup()
|
||||||
@ -440,14 +441,14 @@ class CustomPermissionsTests(BaseHorizonTests):
|
|||||||
'horizon.test.customization.cust_test2'
|
'horizon.test.customization.cust_test2'
|
||||||
# refresh config
|
# refresh config
|
||||||
conf.HORIZON_CONFIG._setup()
|
conf.HORIZON_CONFIG._setup()
|
||||||
super(CustomPermissionsTests, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# Restore permissions
|
# Restore permissions
|
||||||
dogs = horizon.get_dashboard("dogs")
|
dogs = horizon.get_dashboard("dogs")
|
||||||
puppies = dogs.get_panel("puppies")
|
puppies = dogs.get_panel("puppies")
|
||||||
puppies.permissions = tuple([])
|
puppies.permissions = tuple([])
|
||||||
super(CustomPermissionsTests, self).tearDown()
|
super().tearDown()
|
||||||
settings.HORIZON_CONFIG.pop('customization_module')
|
settings.HORIZON_CONFIG.pop('customization_module')
|
||||||
# refresh config
|
# refresh config
|
||||||
conf.HORIZON_CONFIG._setup()
|
conf.HORIZON_CONFIG._setup()
|
||||||
@ -489,7 +490,7 @@ class CustomPermissionsTests(BaseHorizonTests):
|
|||||||
class RbacHorizonTests(test.TestCase):
|
class RbacHorizonTests(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(RbacHorizonTests, self).setUp()
|
super().setUp()
|
||||||
# Adjust our horizon config and register our custom dashboards/panels.
|
# Adjust our horizon config and register our custom dashboards/panels.
|
||||||
self.old_default_dash = settings.HORIZON_CONFIG['default_dashboard']
|
self.old_default_dash = settings.HORIZON_CONFIG['default_dashboard']
|
||||||
settings.HORIZON_CONFIG['default_dashboard'] = 'cats'
|
settings.HORIZON_CONFIG['default_dashboard'] = 'cats'
|
||||||
@ -513,7 +514,7 @@ class RbacHorizonTests(test.TestCase):
|
|||||||
self._discovered_panels[dash] = panels
|
self._discovered_panels[dash] = panels
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(RbacHorizonTests, self).tearDown()
|
super().tearDown()
|
||||||
# Restore our settings
|
# Restore our settings
|
||||||
settings.HORIZON_CONFIG['default_dashboard'] = self.old_default_dash
|
settings.HORIZON_CONFIG['default_dashboard'] = self.old_default_dash
|
||||||
settings.HORIZON_CONFIG['dashboards'] = self.old_dashboards
|
settings.HORIZON_CONFIG['dashboards'] = self.old_dashboards
|
||||||
|
@ -28,7 +28,7 @@ class ViewData(object):
|
|||||||
template_name = 'fake'
|
template_name = 'fake'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ViewData, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['object'] = {'name': 'myName'}
|
context['object'] = {'name': 'myName'}
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class ViewWithTransTitle(views.PageTitleMixin, generic.TemplateView):
|
|||||||
class PageTitleTests(test.TestCase):
|
class PageTitleTests(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(PageTitleTests, self).setUp()
|
super().setUp()
|
||||||
self.request = client.RequestFactory().get('fake')
|
self.request = client.RequestFactory().get('fake')
|
||||||
|
|
||||||
def _dispatch(self, viewClass):
|
def _dispatch(self, viewClass):
|
||||||
|
@ -184,14 +184,14 @@ class FullscreenWorkflowView(workflows.WorkflowView):
|
|||||||
|
|
||||||
class WorkflowsTests(test.TestCase):
|
class WorkflowsTests(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(WorkflowsTests, self).setUp()
|
super().setUp()
|
||||||
self.policy_patcher = mock.patch(
|
self.policy_patcher = mock.patch(
|
||||||
'openstack_auth.policy.check', lambda action, request: True)
|
'openstack_auth.policy.check', lambda action, request: True)
|
||||||
self.policy_check = self.policy_patcher.start()
|
self.policy_check = self.policy_patcher.start()
|
||||||
self.addCleanup(mock.patch.stopall)
|
self.addCleanup(mock.patch.stopall)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(WorkflowsTests, self).tearDown()
|
super().tearDown()
|
||||||
self._reset_workflow()
|
self._reset_workflow()
|
||||||
|
|
||||||
def _reset_workflow(self):
|
def _reset_workflow(self):
|
||||||
|
@ -23,4 +23,4 @@ class ObjDictWrapper(dict):
|
|||||||
self[item] = value
|
self[item] = value
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<ObjDictWrapper %s>' % super(ObjDictWrapper, self).__repr__()
|
return '<ObjDictWrapper %s>' % super().__repr__()
|
||||||
|
@ -40,8 +40,7 @@ class WrapperFindOverride(object):
|
|||||||
repeat = range(2)
|
repeat = range(2)
|
||||||
for i in repeat:
|
for i in repeat:
|
||||||
try:
|
try:
|
||||||
web_el = super(WrapperFindOverride, self).find_element(
|
web_el = super().find_element(by, value)
|
||||||
by, value)
|
|
||||||
except exceptions.NoSuchElementException:
|
except exceptions.NoSuchElementException:
|
||||||
if i == repeat[-1]:
|
if i == repeat[-1]:
|
||||||
raise
|
raise
|
||||||
@ -52,8 +51,7 @@ class WrapperFindOverride(object):
|
|||||||
repeat = range(2)
|
repeat = range(2)
|
||||||
for i in repeat:
|
for i in repeat:
|
||||||
try:
|
try:
|
||||||
web_els = super(WrapperFindOverride, self).find_elements(
|
web_els = super().find_elements(by, value)
|
||||||
by, value)
|
|
||||||
except exceptions.NoSuchElementException:
|
except exceptions.NoSuchElementException:
|
||||||
if i == repeat[-1]:
|
if i == repeat[-1]:
|
||||||
raise
|
raise
|
||||||
@ -77,7 +75,7 @@ class WebElementWrapper(WrapperFindOverride, webelement.WebElement):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, parent, id_, locator, src_element, index=None):
|
def __init__(self, parent, id_, locator, src_element, index=None):
|
||||||
super(WebElementWrapper, self).__init__(parent, id_)
|
super().__init__(parent, id_)
|
||||||
self.locator = locator
|
self.locator = locator
|
||||||
self.src_element = src_element
|
self.src_element = src_element
|
||||||
# in case element was looked up previously via find_elements
|
# in case element was looked up previously via find_elements
|
||||||
@ -102,7 +100,7 @@ class WebElementWrapper(WrapperFindOverride, webelement.WebElement):
|
|||||||
repeat = range(20)
|
repeat = range(20)
|
||||||
for i in repeat:
|
for i in repeat:
|
||||||
try:
|
try:
|
||||||
return super(WebElementWrapper, self)._execute(command, params)
|
return super()._execute(command, params)
|
||||||
except (exceptions.StaleElementReferenceException,
|
except (exceptions.StaleElementReferenceException,
|
||||||
exceptions.ElementClickInterceptedException):
|
exceptions.ElementClickInterceptedException):
|
||||||
if i == repeat[-1]:
|
if i == repeat[-1]:
|
||||||
|
@ -54,7 +54,7 @@ class AngularGettextHTMLParser(parser.HTMLParser):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AngularGettextHTMLParser, self).__init__(
|
super().__init__(
|
||||||
convert_charrefs=False
|
convert_charrefs=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class CsvDataMixin(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.out = io.StringIO()
|
self.out = io.StringIO()
|
||||||
super(CsvDataMixin, self).__init__()
|
super().__init__()
|
||||||
if hasattr(self, "columns"):
|
if hasattr(self, "columns"):
|
||||||
columns = [self.encode(col) for col in self.columns]
|
columns = [self.encode(col) for col in self.columns]
|
||||||
self.writer = csv.DictWriter(self.out, columns,
|
self.writer = csv.DictWriter(self.out, columns,
|
||||||
@ -65,7 +65,7 @@ class BaseCsvResponse(CsvDataMixin, HttpResponse):
|
|||||||
"""Base CSV response class. Provides handling of CSV data."""
|
"""Base CSV response class. Provides handling of CSV data."""
|
||||||
|
|
||||||
def __init__(self, request, template, context, content_type, **kwargs):
|
def __init__(self, request, template, context, content_type, **kwargs):
|
||||||
super(BaseCsvResponse, self).__init__()
|
super().__init__()
|
||||||
self['Content-Disposition'] = 'attachment; filename="%s"' % (
|
self['Content-Disposition'] = 'attachment; filename="%s"' % (
|
||||||
kwargs.get("filename", "export.csv"),)
|
kwargs.get("filename", "export.csv"),)
|
||||||
self['Content-Type'] = content_type
|
self['Content-Type'] = content_type
|
||||||
@ -97,7 +97,7 @@ class BaseCsvStreamingResponse(CsvDataMixin, StreamingHttpResponse):
|
|||||||
"""Base CSV Streaming class. Provides streaming response for CSV data."""
|
"""Base CSV Streaming class. Provides streaming response for CSV data."""
|
||||||
|
|
||||||
def __init__(self, request, template, context, content_type, **kwargs):
|
def __init__(self, request, template, context, content_type, **kwargs):
|
||||||
super(BaseCsvStreamingResponse, self).__init__()
|
super().__init__()
|
||||||
self['Content-Disposition'] = 'attachment; filename="%s"' % (
|
self['Content-Disposition'] = 'attachment; filename="%s"' % (
|
||||||
kwargs.get("filename", "export.csv"),)
|
kwargs.get("filename", "export.csv"),)
|
||||||
self['Content-Type'] = content_type
|
self['Content-Type'] = content_type
|
||||||
|
@ -22,4 +22,4 @@ class LazyTranslationEncoder(DjangoJSONEncoder):
|
|||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
if isinstance(obj, Promise):
|
if isinstance(obj, Promise):
|
||||||
return force_text(obj)
|
return force_text(obj)
|
||||||
return super(LazyTranslationEncoder, self).default(obj)
|
return super().default(obj)
|
||||||
|
@ -23,7 +23,7 @@ from scss.types import String
|
|||||||
|
|
||||||
class HorizonScssFilter(DjangoScssFilter):
|
class HorizonScssFilter(DjangoScssFilter):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(HorizonScssFilter, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.namespace = Namespace()
|
self.namespace = Namespace()
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PageTitleMixin(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
context = self.render_context_with_title(context)
|
context = self.render_context_with_title(context)
|
||||||
return super(PageTitleMixin, self).render_to_response(context)
|
return super().render_to_response(context)
|
||||||
|
|
||||||
|
|
||||||
def trace(name):
|
def trace(name):
|
||||||
@ -83,7 +83,7 @@ def trace(name):
|
|||||||
class HorizonTemplateView(PageTitleMixin, generic.TemplateView):
|
class HorizonTemplateView(PageTitleMixin, generic.TemplateView):
|
||||||
@trace('horizon.render_to_response')
|
@trace('horizon.render_to_response')
|
||||||
def render_to_response(self, context):
|
def render_to_response(self, context):
|
||||||
return super(HorizonTemplateView, self).render_to_response(context)
|
return super().render_to_response(context)
|
||||||
|
|
||||||
|
|
||||||
class HorizonFormView(PageTitleMixin, generic.FormView):
|
class HorizonFormView(PageTitleMixin, generic.FormView):
|
||||||
|
@ -42,11 +42,11 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class WorkflowContext(dict):
|
class WorkflowContext(dict):
|
||||||
def __init__(self, workflow, *args, **kwargs):
|
def __init__(self, workflow, *args, **kwargs):
|
||||||
super(WorkflowContext, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._workflow = workflow
|
self._workflow = workflow
|
||||||
|
|
||||||
def __setitem__(self, key, val):
|
def __setitem__(self, key, val):
|
||||||
super(WorkflowContext, self).__setitem__(key, val)
|
super().__setitem__(key, val)
|
||||||
return self._workflow._trigger_handlers(key)
|
return self._workflow._trigger_handlers(key)
|
||||||
|
|
||||||
def __delitem__(self, key):
|
def __delitem__(self, key):
|
||||||
@ -64,7 +64,7 @@ class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass):
|
|||||||
# Pop Meta for later processing
|
# Pop Meta for later processing
|
||||||
opts = attrs.pop("Meta", None)
|
opts = attrs.pop("Meta", None)
|
||||||
# Create our new class
|
# Create our new class
|
||||||
cls_ = super(ActionMetaclass, cls).__new__(cls, name, bases, attrs)
|
cls_ = super().__new__(cls, name, bases, attrs)
|
||||||
# Process options from Meta
|
# Process options from Meta
|
||||||
cls_.name = getattr(opts, "name", name)
|
cls_.name = getattr(opts, "name", name)
|
||||||
cls_.slug = getattr(opts, "slug", slugify(name))
|
cls_.slug = getattr(opts, "slug", slugify(name))
|
||||||
@ -151,9 +151,9 @@ class Action(forms.Form, metaclass=ActionMetaclass):
|
|||||||
|
|
||||||
def __init__(self, request, context, *args, **kwargs):
|
def __init__(self, request, context, *args, **kwargs):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
super(Action, self).__init__(request.POST, initial=context)
|
super().__init__(request.POST, initial=context)
|
||||||
else:
|
else:
|
||||||
super(Action, self).__init__(initial=context)
|
super().__init__(initial=context)
|
||||||
|
|
||||||
if not hasattr(self, "handle"):
|
if not hasattr(self, "handle"):
|
||||||
raise AttributeError("The action %s must define a handle method."
|
raise AttributeError("The action %s must define a handle method."
|
||||||
@ -313,7 +313,7 @@ class Step(object):
|
|||||||
return force_text(self.name)
|
return force_text(self.name)
|
||||||
|
|
||||||
def __init__(self, workflow):
|
def __init__(self, workflow):
|
||||||
super(Step, self).__init__()
|
super().__init__()
|
||||||
self.workflow = workflow
|
self.workflow = workflow
|
||||||
|
|
||||||
cls = self.__class__.__name__
|
cls = self.__class__.__name__
|
||||||
@ -478,7 +478,7 @@ class Step(object):
|
|||||||
|
|
||||||
class WorkflowMetaclass(type):
|
class WorkflowMetaclass(type):
|
||||||
def __new__(cls, name, bases, attrs):
|
def __new__(cls, name, bases, attrs):
|
||||||
super(WorkflowMetaclass, cls).__new__(cls, name, bases, attrs)
|
super().__new__(cls, name, bases, attrs)
|
||||||
attrs["_cls_registry"] = []
|
attrs["_cls_registry"] = []
|
||||||
return type.__new__(cls, name, bases, attrs)
|
return type.__new__(cls, name, bases, attrs)
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ class Workflow(html.HTMLElement, metaclass=WorkflowMetaclass):
|
|||||||
|
|
||||||
def __init__(self, request=None, context_seed=None, entry_point=None,
|
def __init__(self, request=None, context_seed=None, entry_point=None,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
super(Workflow, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if self.slug is None:
|
if self.slug is None:
|
||||||
raise AttributeError("The workflow %s must have a slug."
|
raise AttributeError("The workflow %s must have a slug."
|
||||||
% self.__class__.__name__)
|
% self.__class__.__name__)
|
||||||
|
@ -59,7 +59,7 @@ class WorkflowView(hz_views.ModalBackdropMixin, generic.TemplateView):
|
|||||||
step_errors = {}
|
step_errors = {}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(WorkflowView, self).__init__()
|
super().__init__()
|
||||||
if not self.workflow_class:
|
if not self.workflow_class:
|
||||||
raise AttributeError("You must set the workflow_class attribute "
|
raise AttributeError("You must set the workflow_class attribute "
|
||||||
"on %s." % self.__class__.__name__)
|
"on %s." % self.__class__.__name__)
|
||||||
@ -87,7 +87,7 @@ class WorkflowView(hz_views.ModalBackdropMixin, generic.TemplateView):
|
|||||||
This method should be overridden in subclasses to provide additional
|
This method should be overridden in subclasses to provide additional
|
||||||
context data to the template.
|
context data to the template.
|
||||||
"""
|
"""
|
||||||
context = super(WorkflowView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
workflow = self.get_workflow()
|
workflow = self.get_workflow()
|
||||||
workflow.verify_integrity()
|
workflow.verify_integrity()
|
||||||
context[self.context_object_name] = workflow
|
context[self.context_object_name] = workflow
|
||||||
|
@ -77,7 +77,7 @@ class Login(django_auth_forms.AuthenticationForm):
|
|||||||
widget=forms.PasswordInput(render_value=False))
|
widget=forms.PasswordInput(render_value=False))
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Login, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
fields_ordering = ['username', 'password', 'region']
|
fields_ordering = ['username', 'password', 'region']
|
||||||
if settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT:
|
if settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT:
|
||||||
last_domain = self.request.COOKIES.get('login_domain', None)
|
last_domain = self.request.COOKIES.get('login_domain', None)
|
||||||
@ -185,7 +185,7 @@ class DummyAuth(auth_plugin.BaseAuthPlugin):
|
|||||||
class Password(forms.Form):
|
class Password(forms.Form):
|
||||||
"""Form used for changing user's password without having to log in."""
|
"""Form used for changing user's password without having to log in."""
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Password, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields = collections.OrderedDict([
|
self.fields = collections.OrderedDict([
|
||||||
(
|
(
|
||||||
'region',
|
'region',
|
||||||
|
@ -37,7 +37,7 @@ class TestResponse(requests.Response):
|
|||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self._text = None
|
self._text = None
|
||||||
super(TestResponse, self).__init__()
|
super().__init__()
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
self.status_code = data.get('status_code', 200)
|
self.status_code = data.get('status_code', 200)
|
||||||
self.headers = data.get('headers', None)
|
self.headers = data.get('headers', None)
|
||||||
|
@ -995,7 +995,7 @@ class OpenStackAuthTestsV3WithMock(test.TestCase):
|
|||||||
'username': user.name}
|
'username': user.name}
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(OpenStackAuthTestsV3WithMock, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
if getattr(self, 'interface', None):
|
if getattr(self, 'interface', None):
|
||||||
override = self.settings(OPENSTACK_ENDPOINT_TYPE=self.interface)
|
override = self.settings(OPENSTACK_ENDPOINT_TYPE=self.interface)
|
||||||
|
@ -85,7 +85,7 @@ class UtilsTestCase(test.TestCase):
|
|||||||
class BehindProxyTestCase(test.TestCase):
|
class BehindProxyTestCase(test.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BehindProxyTestCase, self).setUp()
|
super().setUp()
|
||||||
self.request = http.HttpRequest()
|
self.request = http.HttpRequest()
|
||||||
|
|
||||||
def test_without_proxy(self):
|
def test_without_proxy(self):
|
||||||
|
@ -57,7 +57,7 @@ class Server(base.APIResourceWrapper):
|
|||||||
'OS-EXT-AZ:availability_zone', 'OS-DCF:diskConfig']
|
'OS-EXT-AZ:availability_zone', 'OS-DCF:diskConfig']
|
||||||
|
|
||||||
def __init__(self, apiresource, request):
|
def __init__(self, apiresource, request):
|
||||||
super(Server, self).__init__(apiresource)
|
super().__init__(apiresource)
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
# TODO(gabriel): deprecate making a call to Glance as a fallback.
|
# TODO(gabriel): deprecate making a call to Glance as a fallback.
|
||||||
|
@ -109,7 +109,7 @@ class Image(base.APIResourceWrapper):
|
|||||||
def to_dict(self, show_ext_attrs=False):
|
def to_dict(self, show_ext_attrs=False):
|
||||||
if not isinstance(self._apiresource, abc.Iterable):
|
if not isinstance(self._apiresource, abc.Iterable):
|
||||||
return self._apiresource.to_dict()
|
return self._apiresource.to_dict()
|
||||||
image_dict = super(Image, self).to_dict()
|
image_dict = super().to_dict()
|
||||||
image_dict['is_public'] = self.is_public
|
image_dict['is_public'] = self.is_public
|
||||||
image_dict['properties'] = {
|
image_dict['properties'] = {
|
||||||
k: self._apiresource[k] for k in self._apiresource
|
k: self._apiresource[k] for k in self._apiresource
|
||||||
@ -372,14 +372,14 @@ def get_image_upload_mode():
|
|||||||
|
|
||||||
class ExternallyUploadedImage(Image):
|
class ExternallyUploadedImage(Image):
|
||||||
def __init__(self, apiresource, request):
|
def __init__(self, apiresource, request):
|
||||||
super(ExternallyUploadedImage, self).__init__(apiresource)
|
super().__init__(apiresource)
|
||||||
image_endpoint = base.url_for(request, 'image', 'publicURL')
|
image_endpoint = base.url_for(request, 'image', 'publicURL')
|
||||||
upload_template = "%s/v2/images/%s/file"
|
upload_template = "%s/v2/images/%s/file"
|
||||||
self._url = upload_template % (image_endpoint, self.id)
|
self._url = upload_template % (image_endpoint, self.id)
|
||||||
self._token_id = request.user.token.id
|
self._token_id = request.user.token.id
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
base_dict = super(ExternallyUploadedImage, self).to_dict()
|
base_dict = super().to_dict()
|
||||||
base_dict.update({
|
base_dict.update({
|
||||||
'upload_url': self._url,
|
'upload_url': self._url,
|
||||||
'token_id': self._token_id
|
'token_id': self._token_id
|
||||||
|
@ -74,7 +74,7 @@ class Service(base.APIDictWrapper):
|
|||||||
_attrs = ['id', 'type', 'name']
|
_attrs = ['id', 'type', 'name']
|
||||||
|
|
||||||
def __init__(self, service, region, *args, **kwargs):
|
def __init__(self, service, region, *args, **kwargs):
|
||||||
super(Service, self).__init__(service, *args, **kwargs)
|
super().__init__(service, *args, **kwargs)
|
||||||
self.public_url = base.get_url_for_service(service, region,
|
self.public_url = base.get_url_for_service(service, region,
|
||||||
'publicURL')
|
'publicURL')
|
||||||
self.url = base.get_url_for_service(service, region,
|
self.url = base.get_url_for_service(service, region,
|
||||||
|
@ -78,7 +78,7 @@ class NeutronAPIDictWrapper(base.APIDictWrapper):
|
|||||||
for key, value in apidict.items()
|
for key, value in apidict.items()
|
||||||
if ':' in key
|
if ':' in key
|
||||||
})
|
})
|
||||||
super(NeutronAPIDictWrapper, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
|
|
||||||
def set_id_as_name_if_empty(self, length=8):
|
def set_id_as_name_if_empty(self, length=8):
|
||||||
try:
|
try:
|
||||||
@ -112,7 +112,7 @@ class Subnet(NeutronAPIDictWrapper):
|
|||||||
|
|
||||||
def __init__(self, apidict):
|
def __init__(self, apidict):
|
||||||
apidict['ipver_str'] = get_ipver_str(apidict['ip_version'])
|
apidict['ipver_str'] = get_ipver_str(apidict['ip_version'])
|
||||||
super(Subnet, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
|
|
||||||
|
|
||||||
AUTO_ALLOCATE_ID = '__auto_allocate__'
|
AUTO_ALLOCATE_ID = '__auto_allocate__'
|
||||||
@ -142,7 +142,7 @@ class PreAutoAllocateNetwork(Network):
|
|||||||
'subnets': [auto_allocated_subnet],
|
'subnets': [auto_allocated_subnet],
|
||||||
'tenant_id': tenant_id,
|
'tenant_id': tenant_id,
|
||||||
}
|
}
|
||||||
super(PreAutoAllocateNetwork, self).__init__(auto_allocated_network)
|
super().__init__(auto_allocated_network)
|
||||||
|
|
||||||
|
|
||||||
class Trunk(NeutronAPIDictWrapper):
|
class Trunk(NeutronAPIDictWrapper):
|
||||||
@ -153,7 +153,7 @@ class Trunk(NeutronAPIDictWrapper):
|
|||||||
return len(self._apidict.get('sub_ports', []))
|
return len(self._apidict.get('sub_ports', []))
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
trunk_dict = super(Trunk, self).to_dict()
|
trunk_dict = super().to_dict()
|
||||||
trunk_dict['name_or_id'] = self.name_or_id
|
trunk_dict['name_or_id'] = self.name_or_id
|
||||||
trunk_dict['subport_count'] = self.subport_count
|
trunk_dict['subport_count'] = self.subport_count
|
||||||
return trunk_dict
|
return trunk_dict
|
||||||
@ -175,7 +175,7 @@ class Port(NeutronAPIDictWrapper):
|
|||||||
apidict = copy.deepcopy(apidict)
|
apidict = copy.deepcopy(apidict)
|
||||||
wrapped_pairs = [PortAllowedAddressPair(pair) for pair in pairs]
|
wrapped_pairs = [PortAllowedAddressPair(pair) for pair in pairs]
|
||||||
apidict['allowed_address_pairs'] = wrapped_pairs
|
apidict['allowed_address_pairs'] = wrapped_pairs
|
||||||
super(Port, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
|
|
||||||
|
|
||||||
class PortTrunkParent(Port):
|
class PortTrunkParent(Port):
|
||||||
@ -203,14 +203,14 @@ class PortTrunkSubport(Port):
|
|||||||
def __init__(self, apidict, trunk_subport_info):
|
def __init__(self, apidict, trunk_subport_info):
|
||||||
for field in ['trunk_id', 'segmentation_type', 'segmentation_id']:
|
for field in ['trunk_id', 'segmentation_type', 'segmentation_id']:
|
||||||
apidict[field] = trunk_subport_info[field]
|
apidict[field] = trunk_subport_info[field]
|
||||||
super(PortTrunkSubport, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
|
|
||||||
|
|
||||||
class PortAllowedAddressPair(NeutronAPIDictWrapper):
|
class PortAllowedAddressPair(NeutronAPIDictWrapper):
|
||||||
"""Wrapper for neutron port allowed address pairs."""
|
"""Wrapper for neutron port allowed address pairs."""
|
||||||
|
|
||||||
def __init__(self, addr_pair):
|
def __init__(self, addr_pair):
|
||||||
super(PortAllowedAddressPair, self).__init__(addr_pair)
|
super().__init__(addr_pair)
|
||||||
# Horizon references id property for table operations
|
# Horizon references id property for table operations
|
||||||
self.id = addr_pair['ip_address']
|
self.id = addr_pair['ip_address']
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ class RouterStaticRoute(NeutronAPIDictWrapper):
|
|||||||
"""Wrapper for neutron routes extra route."""
|
"""Wrapper for neutron routes extra route."""
|
||||||
|
|
||||||
def __init__(self, route):
|
def __init__(self, route):
|
||||||
super(RouterStaticRoute, self).__init__(route)
|
super().__init__(route)
|
||||||
# Horizon references id property for table operations
|
# Horizon references id property for table operations
|
||||||
self.id = route['nexthop'] + ":" + route['destination']
|
self.id = route['nexthop'] + ":" + route['destination']
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ class SecurityGroup(NeutronAPIDictWrapper):
|
|||||||
sg['security_group_rules'] = []
|
sg['security_group_rules'] = []
|
||||||
sg['rules'] = [SecurityGroupRule(rule, sg_dict)
|
sg['rules'] = [SecurityGroupRule(rule, sg_dict)
|
||||||
for rule in sg['security_group_rules']]
|
for rule in sg['security_group_rules']]
|
||||||
super(SecurityGroup, self).__init__(sg)
|
super().__init__(sg)
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {k: self._apidict[k] for k in self._apidict if k != 'rules'}
|
return {k: self._apidict[k] for k in self._apidict if k != 'rules'}
|
||||||
@ -283,7 +283,7 @@ class SecurityGroupRule(NeutronAPIDictWrapper):
|
|||||||
rule['ip_range'] = {'cidr': cidr} if cidr else {}
|
rule['ip_range'] = {'cidr': cidr} if cidr else {}
|
||||||
group = self._get_secgroup_name(sgr['remote_group_id'], sg_dict)
|
group = self._get_secgroup_name(sgr['remote_group_id'], sg_dict)
|
||||||
rule['group'] = {'name': group} if group else {}
|
rule['group'] = {'name': group} if group else {}
|
||||||
super(SecurityGroupRule, self).__init__(rule)
|
super().__init__(rule)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if 'name' in self.group:
|
if 'name' in self.group:
|
||||||
@ -497,7 +497,7 @@ class FloatingIp(base.APIDictWrapper):
|
|||||||
fip['ip'] = fip['floating_ip_address']
|
fip['ip'] = fip['floating_ip_address']
|
||||||
fip['fixed_ip'] = fip['fixed_ip_address']
|
fip['fixed_ip'] = fip['fixed_ip_address']
|
||||||
fip['pool'] = fip['floating_network_id']
|
fip['pool'] = fip['floating_network_id']
|
||||||
super(FloatingIp, self).__init__(fip)
|
super().__init__(fip)
|
||||||
|
|
||||||
|
|
||||||
class FloatingIpPool(base.APIDictWrapper):
|
class FloatingIpPool(base.APIDictWrapper):
|
||||||
@ -522,7 +522,7 @@ class FloatingIpTarget(base.APIDictWrapper):
|
|||||||
'id': '%s_%s' % (port.id, ip_address),
|
'id': '%s_%s' % (port.id, ip_address),
|
||||||
'port_id': port.id,
|
'port_id': port.id,
|
||||||
'instance_id': port.device_id}
|
'instance_id': port.device_id}
|
||||||
super(FloatingIpTarget, self).__init__(target)
|
super().__init__(target)
|
||||||
|
|
||||||
|
|
||||||
class FloatingIpManager(object):
|
class FloatingIpManager(object):
|
||||||
|
@ -21,7 +21,7 @@ class NaNJSONEncoder(json.JSONEncoder):
|
|||||||
def __init__(self, nan_str='NaN', inf_str='1e+999', **kwargs):
|
def __init__(self, nan_str='NaN', inf_str='1e+999', **kwargs):
|
||||||
self.nan_str = nan_str
|
self.nan_str = nan_str
|
||||||
self.inf_str = inf_str
|
self.inf_str = inf_str
|
||||||
super(NaNJSONEncoder, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def iterencode(self, o, _one_shot=False):
|
def iterencode(self, o, _one_shot=False):
|
||||||
"""JSON encoder with NaN and float inf support.
|
"""JSON encoder with NaN and float inf support.
|
||||||
|
@ -29,7 +29,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
class AjaxError(Exception):
|
class AjaxError(Exception):
|
||||||
def __init__(self, http_status, msg):
|
def __init__(self, http_status, msg):
|
||||||
self.http_status = http_status
|
self.http_status = http_status
|
||||||
super(AjaxError, self).__init__(msg)
|
super().__init__(msg)
|
||||||
|
|
||||||
|
|
||||||
http_errors = exceptions.UNAUTHORIZED + exceptions.NOT_FOUND + \
|
http_errors = exceptions.UNAUTHORIZED + exceptions.NOT_FOUND + \
|
||||||
@ -53,8 +53,8 @@ class CreatedResponse(_RestResponse):
|
|||||||
else:
|
else:
|
||||||
content = ''
|
content = ''
|
||||||
content_type = None
|
content_type = None
|
||||||
super(CreatedResponse, self).__init__(status=201, content=content,
|
super().__init__(status=201, content=content,
|
||||||
content_type=content_type)
|
content_type=content_type)
|
||||||
self['Location'] = location
|
self['Location'] = location
|
||||||
|
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class JSONResponse(_RestResponse):
|
|||||||
content = jsonutils.dumps(data, sort_keys=settings.DEBUG,
|
content = jsonutils.dumps(data, sort_keys=settings.DEBUG,
|
||||||
cls=json_encoder)
|
cls=json_encoder)
|
||||||
|
|
||||||
super(JSONResponse, self).__init__(
|
super().__init__(
|
||||||
status=status,
|
status=status,
|
||||||
content=content,
|
content=content,
|
||||||
content_type='application/json',
|
content_type='application/json',
|
||||||
|
@ -56,7 +56,7 @@ class Container(base.APIDictWrapper):
|
|||||||
|
|
||||||
class StorageObject(base.APIDictWrapper):
|
class StorageObject(base.APIDictWrapper):
|
||||||
def __init__(self, apidict, container_name, orig_name=None, data=None):
|
def __init__(self, apidict, container_name, orig_name=None, data=None):
|
||||||
super(StorageObject, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
self.container_name = container_name
|
self.container_name = container_name
|
||||||
self.orig_name = orig_name
|
self.orig_name = orig_name
|
||||||
self.data = data
|
self.data = data
|
||||||
@ -68,7 +68,7 @@ class StorageObject(base.APIDictWrapper):
|
|||||||
|
|
||||||
class PseudoFolder(base.APIDictWrapper):
|
class PseudoFolder(base.APIDictWrapper):
|
||||||
def __init__(self, apidict, container_name):
|
def __init__(self, apidict, container_name):
|
||||||
super(PseudoFolder, self).__init__(apidict)
|
super().__init__(apidict)
|
||||||
self.container_name = container_name
|
self.container_name = container_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -26,7 +26,7 @@ class Developer(horizon.Dashboard):
|
|||||||
def allowed(self, context):
|
def allowed(self, context):
|
||||||
if not settings.DEBUG:
|
if not settings.DEBUG:
|
||||||
return False
|
return False
|
||||||
return super(Developer, self).allowed(context)
|
return super().allowed(context)
|
||||||
|
|
||||||
|
|
||||||
horizon.register(Developer)
|
horizon.register(Developer)
|
||||||
|
@ -42,7 +42,7 @@ class ProfilerClientMiddleware(object):
|
|||||||
def __init__(self, get_response):
|
def __init__(self, get_response):
|
||||||
if not PROFILER_ENABLED:
|
if not PROFILER_ENABLED:
|
||||||
raise exceptions.MiddlewareNotUsed()
|
raise exceptions.MiddlewareNotUsed()
|
||||||
super(ProfilerClientMiddleware, self).__init__()
|
super().__init__()
|
||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
|
@ -27,7 +27,7 @@ class IndexView(views.HorizonTemplateView):
|
|||||||
page_title = _("OpenStack Profiler")
|
page_title = _("OpenStack Profiler")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(IndexView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class UpdateAggregateForm(forms.SelfHandlingForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(UpdateAggregateForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
old_availability_zone = self.initial['availability_zone']
|
old_availability_zone = self.initial['availability_zone']
|
||||||
if not old_availability_zone:
|
if not old_availability_zone:
|
||||||
self.fields['availability_zone'].required = False
|
self.fields['availability_zone'].required = False
|
||||||
|
@ -40,4 +40,4 @@ class Aggregates(horizon.Panel):
|
|||||||
"likely due to a problem communicating with the Nova "
|
"likely due to a problem communicating with the Nova "
|
||||||
"endpoint. Host Aggregates panel will not be displayed.")
|
"endpoint. Host Aggregates panel will not be displayed.")
|
||||||
return False
|
return False
|
||||||
return super(Aggregates, self).allowed(context)
|
return super().allowed(context)
|
||||||
|
@ -75,7 +75,7 @@ class UpdateMetadataAction(tables.LinkAction):
|
|||||||
|
|
||||||
def __init__(self, attrs=None, **kwargs):
|
def __init__(self, attrs=None, **kwargs):
|
||||||
kwargs['preempt'] = True
|
kwargs['preempt'] = True
|
||||||
super(UpdateMetadataAction, self).__init__(attrs, **kwargs)
|
super().__init__(attrs, **kwargs)
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
aggregate_id = self.table.get_object_id(datum)
|
aggregate_id = self.table.get_object_id(datum)
|
||||||
|
@ -81,7 +81,7 @@ class UpdateView(forms.ModalFormView):
|
|||||||
'availability_zone': aggregate.availability_zone}
|
'availability_zone': aggregate.availability_zone}
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['id'] = self.kwargs['id']
|
context['id'] = self.kwargs['id']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -107,6 +107,6 @@ class ManageHostsView(workflows.WorkflowView):
|
|||||||
return {'id': self.kwargs["id"]}
|
return {'id': self.kwargs["id"]}
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ManageHostsView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['id'] = self.kwargs['id']
|
context['id'] = self.kwargs['id']
|
||||||
return context
|
return context
|
||||||
|
@ -36,7 +36,7 @@ class SetAggregateInfoAction(workflows.Action):
|
|||||||
slug = "set_aggregate_info"
|
slug = "set_aggregate_info"
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(SetAggregateInfoAction, self).clean()
|
cleaned_data = super().clean()
|
||||||
name = cleaned_data.get('name', '')
|
name = cleaned_data.get('name', '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -64,9 +64,7 @@ class SetAggregateInfoStep(workflows.Step):
|
|||||||
|
|
||||||
class AddHostsToAggregateAction(workflows.MembershipAction):
|
class AddHostsToAggregateAction(workflows.MembershipAction):
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(AddHostsToAggregateAction, self).__init__(request,
|
super().__init__(request, *args, **kwargs)
|
||||||
*args,
|
|
||||||
**kwargs)
|
|
||||||
err_msg = _('Unable to get the available hosts')
|
err_msg = _('Unable to get the available hosts')
|
||||||
|
|
||||||
default_role_field_name = self.get_default_role_field_name()
|
default_role_field_name = self.get_default_role_field_name()
|
||||||
@ -95,9 +93,7 @@ class AddHostsToAggregateAction(workflows.MembershipAction):
|
|||||||
|
|
||||||
class ManageAggregateHostsAction(workflows.MembershipAction):
|
class ManageAggregateHostsAction(workflows.MembershipAction):
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(ManageAggregateHostsAction, self).__init__(request,
|
super().__init__(request, *args, **kwargs)
|
||||||
*args,
|
|
||||||
**kwargs)
|
|
||||||
err_msg = _('Unable to get the available hosts')
|
err_msg = _('Unable to get the available hosts')
|
||||||
|
|
||||||
default_role_field_name = self.get_default_role_field_name()
|
default_role_field_name = self.get_default_role_field_name()
|
||||||
|
@ -33,6 +33,6 @@ class UpdateDefaultQuotasView(workflows.WorkflowView):
|
|||||||
workflow_class = project_workflows.UpdateDefaultQuotas
|
workflow_class = project_workflows.UpdateDefaultQuotas
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(UpdateDefaultQuotasView, self).get_initial()
|
initial = super().get_initial()
|
||||||
initial['disabled_quotas'] = quotas.get_disabled_quotas(self.request)
|
initial['disabled_quotas'] = quotas.get_disabled_quotas(self.request)
|
||||||
return initial
|
return initial
|
||||||
|
@ -48,8 +48,7 @@ class UpdateDefaultComputeQuotasAction(workflows.Action):
|
|||||||
label=_("Length of Injected File Path"))
|
label=_("Length of Injected File Path"))
|
||||||
|
|
||||||
def __init__(self, request, context, *args, **kwargs):
|
def __init__(self, request, context, *args, **kwargs):
|
||||||
super(UpdateDefaultComputeQuotasAction, self).__init__(
|
super().__init__(request, context, *args, **kwargs)
|
||||||
request, context, *args, **kwargs)
|
|
||||||
disabled_quotas = context['disabled_quotas']
|
disabled_quotas = context['disabled_quotas']
|
||||||
for field in disabled_quotas:
|
for field in disabled_quotas:
|
||||||
if field in self.fields:
|
if field in self.fields:
|
||||||
@ -104,8 +103,7 @@ class UpdateDefaultVolumeQuotasAction(workflows.Action):
|
|||||||
snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
|
snapshots = forms.IntegerField(min_value=-1, label=_("Volume Snapshots"))
|
||||||
|
|
||||||
def __init__(self, request, context, *args, **kwargs):
|
def __init__(self, request, context, *args, **kwargs):
|
||||||
super(UpdateDefaultVolumeQuotasAction, self).__init__(
|
super().__init__(request, context, *args, **kwargs)
|
||||||
request, context, *args, **kwargs)
|
|
||||||
disabled_quotas = context['disabled_quotas']
|
disabled_quotas = context['disabled_quotas']
|
||||||
for field in disabled_quotas:
|
for field in disabled_quotas:
|
||||||
if field in self.fields:
|
if field in self.fields:
|
||||||
|
@ -69,7 +69,7 @@ class UpdateMetadata(tables.LinkAction):
|
|||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
kwargs['preempt'] = True
|
kwargs['preempt'] = True
|
||||||
super(UpdateMetadata, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
obj_id = self.table.get_object_id(datum)
|
obj_id = self.table.get_object_id(datum)
|
||||||
|
@ -76,7 +76,7 @@ class CreateFlavorInfoAction(workflows.Action):
|
|||||||
return name
|
return name
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(CreateFlavorInfoAction, self).clean()
|
cleaned_data = super().clean()
|
||||||
name = cleaned_data.get('name')
|
name = cleaned_data.get('name')
|
||||||
flavor_id = cleaned_data.get('flavor_id')
|
flavor_id = cleaned_data.get('flavor_id')
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class CreateFlavorInfo(workflows.Step):
|
|||||||
|
|
||||||
class FlavorAccessAction(workflows.MembershipAction):
|
class FlavorAccessAction(workflows.MembershipAction):
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(FlavorAccessAction, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
err_msg = _('Unable to retrieve flavor access list. '
|
err_msg = _('Unable to retrieve flavor access list. '
|
||||||
'Please try again later.')
|
'Please try again later.')
|
||||||
context = args[0]
|
context = args[0]
|
||||||
|
@ -39,7 +39,7 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
|
|||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AdminFloatingIpAllocate, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
floating_pool_list = kwargs.get('initial', {}).get('pool_list', [])
|
floating_pool_list = kwargs.get('initial', {}).get('pool_list', [])
|
||||||
self.fields['pool'].choices = floating_pool_list
|
self.fields['pool'].choices = floating_pool_list
|
||||||
tenant_list = kwargs.get('initial', {}).get('tenant_list', [])
|
tenant_list = kwargs.get('initial', {}).get('tenant_list', [])
|
||||||
|
@ -129,7 +129,7 @@ class DetailView(views.HorizonTemplateView):
|
|||||||
exceptions.handle(self.request, msg, redirect=url)
|
exceptions.handle(self.request, msg, redirect=url)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
floating_ip_id = self.kwargs['floating_ip_id']
|
floating_ip_id = self.kwargs['floating_ip_id']
|
||||||
floating_ip = self._get_corresponding_data("floating IP",
|
floating_ip = self._get_corresponding_data("floating IP",
|
||||||
|
@ -27,7 +27,7 @@ from openstack_dashboard.dashboards.admin.group_types.specs \
|
|||||||
|
|
||||||
class GroupTypeSpecMixin(object):
|
class GroupTypeSpecMixin(object):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GroupTypeSpecMixin, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
try:
|
try:
|
||||||
context['group_type'] = api.cinder.group_type_get(
|
context['group_type'] = api.cinder.group_type_get(
|
||||||
self.request, self.kwargs['type_id'])
|
self.request, self.kwargs['type_id'])
|
||||||
@ -74,7 +74,7 @@ class CreateView(GroupTypeSpecMixin, forms.ModalFormView):
|
|||||||
return reverse(self.success_url)
|
return reverse(self.success_url)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CreateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
args = (self.kwargs['type_id'],)
|
args = (self.kwargs['type_id'],)
|
||||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||||
return context
|
return context
|
||||||
@ -111,14 +111,14 @@ class EditView(GroupTypeSpecMixin, forms.ModalFormView):
|
|||||||
'value': group_specs.get(key, '')}
|
'value': group_specs.get(key, '')}
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EditView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
args = (self.kwargs['type_id'], self.kwargs['key'],)
|
args = (self.kwargs['type_id'], self.kwargs['key'],)
|
||||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||||
context['modal_header'] = self.modal_header % self.kwargs['key']
|
context['modal_header'] = self.modal_header % self.kwargs['key']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def form_invalid(self, form):
|
def form_invalid(self, form):
|
||||||
context = super(EditView, self).get_context_data()
|
context = super().get_context_data()
|
||||||
context = self._populate_context(context)
|
context = self._populate_context(context)
|
||||||
context['form'] = form
|
context['form'] = form
|
||||||
context['modal_header'] = self.modal_header % self.kwargs['key']
|
context['modal_header'] = self.modal_header % self.kwargs['key']
|
||||||
|
@ -77,7 +77,7 @@ class EditGroupTypeView(forms.ModalFormView):
|
|||||||
return group_type
|
return group_type
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EditGroupTypeView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['group_type'] = self.get_data()
|
context['group_type'] = self.get_data()
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
@ -35,7 +35,7 @@ class EvacuateHostForm(forms.SelfHandlingForm):
|
|||||||
initial=False, required=False)
|
initial=False, required=False)
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(EvacuateHostForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
initial = kwargs.get('initial', {})
|
initial = kwargs.get('initial', {})
|
||||||
self.fields['target_host'].choices = \
|
self.fields['target_host'].choices = \
|
||||||
self.populate_host_choices(request, initial)
|
self.populate_host_choices(request, initial)
|
||||||
|
@ -30,7 +30,7 @@ class EvacuateHost(tables.LinkAction):
|
|||||||
policy_rules = (("compute", "os_compute_api:os-evacuate"),)
|
policy_rules = (("compute", "os_compute_api:os-evacuate"),)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(EvacuateHost, self).__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.name = kwargs.get('name', self.name)
|
self.name = kwargs.get('name', self.name)
|
||||||
|
|
||||||
def allowed(self, request, instance):
|
def allowed(self, request, instance):
|
||||||
|
@ -31,7 +31,7 @@ class EvacuateHostView(forms.ModalFormView):
|
|||||||
submit_label = page_title
|
submit_label = page_title
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(EvacuateHostView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["compute_host"] = self.kwargs['compute_host']
|
context["compute_host"] = self.kwargs['compute_host']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class EvacuateHostView(forms.ModalFormView):
|
|||||||
exceptions.handle(self.request, msg, redirect=redirect)
|
exceptions.handle(self.request, msg, redirect=redirect)
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(EvacuateHostView, self).get_initial()
|
initial = super().get_initial()
|
||||||
hosts = self.get_active_compute_hosts_names()
|
hosts = self.get_active_compute_hosts_names()
|
||||||
current_host = self.kwargs['compute_host']
|
current_host = self.kwargs['compute_host']
|
||||||
initial.update({'current_host': current_host,
|
initial.update({'current_host': current_host,
|
||||||
@ -64,12 +64,12 @@ class DisableServiceView(forms.ModalFormView):
|
|||||||
submit_label = page_title
|
submit_label = page_title
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DisableServiceView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["compute_host"] = self.kwargs['compute_host']
|
context["compute_host"] = self.kwargs['compute_host']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(DisableServiceView, self).get_initial()
|
initial = super().get_initial()
|
||||||
initial.update({'host': self.kwargs['compute_host']})
|
initial.update({'host': self.kwargs['compute_host']})
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
@ -83,12 +83,12 @@ class MigrateHostView(forms.ModalFormView):
|
|||||||
submit_label = page_title
|
submit_label = page_title
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(MigrateHostView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["compute_host"] = self.kwargs['compute_host']
|
context["compute_host"] = self.kwargs['compute_host']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(MigrateHostView, self).get_initial()
|
initial = super().get_initial()
|
||||||
current_host = self.kwargs['compute_host']
|
current_host = self.kwargs['compute_host']
|
||||||
|
|
||||||
initial.update({
|
initial.update({
|
||||||
|
@ -31,7 +31,7 @@ class AdminIndexView(tabs.TabbedTableView):
|
|||||||
page_title = _("All Hypervisors")
|
page_title = _("All Hypervisors")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AdminIndexView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
try:
|
try:
|
||||||
context["stats"] = api.nova.hypervisor_stats(self.request)
|
context["stats"] = api.nova.hypervisor_stats(self.request)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -65,7 +65,7 @@ class AdminDetailView(tables.DataTableView):
|
|||||||
return instances
|
return instances
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AdminDetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
hypervisor_name = self.kwargs['hypervisor'].split('_', 1)[1]
|
hypervisor_name = self.kwargs['hypervisor'].split('_', 1)[1]
|
||||||
breadcrumb = [(hypervisor_name, None)]
|
breadcrumb = [(hypervisor_name, None)]
|
||||||
context['custom_breadcrumb'] = breadcrumb
|
context['custom_breadcrumb'] = breadcrumb
|
||||||
|
@ -49,7 +49,7 @@ class UpdateMetadata(tables.LinkAction):
|
|||||||
|
|
||||||
def __init__(self, attrs=None, **kwargs):
|
def __init__(self, attrs=None, **kwargs):
|
||||||
kwargs['preempt'] = True
|
kwargs['preempt'] = True
|
||||||
super(UpdateMetadata, self).__init__(attrs, **kwargs)
|
super().__init__(attrs, **kwargs)
|
||||||
|
|
||||||
def get_link_url(self, datum):
|
def get_link_url(self, datum):
|
||||||
image_id = self.table.get_object_id(datum)
|
image_id = self.table.get_object_id(datum)
|
||||||
|
@ -164,7 +164,7 @@ class UpdateView(views.UpdateView):
|
|||||||
class DetailView(views.DetailView):
|
class DetailView(views.DetailView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
table = project_tables.AdminImagesTable(self.request)
|
table = project_tables.AdminImagesTable(self.request)
|
||||||
context["url"] = reverse('horizon:admin:images:index')
|
context["url"] = reverse('horizon:admin:images:index')
|
||||||
context["actions"] = table.render_row_actions(context["image"])
|
context["actions"] = table.render_row_actions(context["image"])
|
||||||
|
@ -214,11 +214,9 @@ class NetworkAgentsTable(tables.DataTable):
|
|||||||
filters.timesince))
|
filters.timesince))
|
||||||
|
|
||||||
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
||||||
super(NetworkAgentsTable, self).__init__(
|
super().__init__(request, data=data,
|
||||||
request,
|
needs_form_wrapper=needs_form_wrapper,
|
||||||
data=data,
|
**kwargs)
|
||||||
needs_form_wrapper=needs_form_wrapper,
|
|
||||||
**kwargs)
|
|
||||||
|
|
||||||
availability_zone_supported = api.neutron.is_extension_supported(
|
availability_zone_supported = api.neutron.is_extension_supported(
|
||||||
request,
|
request,
|
||||||
|
@ -32,7 +32,7 @@ class IndexView(tabs.TabbedTableView):
|
|||||||
page_title = _("System Information")
|
page_title = _("System Information")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(IndexView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
try:
|
try:
|
||||||
context["version"] = version.version_info.version_string()
|
context["version"] = version.version_info.version_string()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -39,7 +39,7 @@ class LiveMigrateForm(forms.SelfHandlingForm):
|
|||||||
initial=False, required=False)
|
initial=False, required=False)
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(LiveMigrateForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
initial = kwargs.get('initial', {})
|
initial = kwargs.get('initial', {})
|
||||||
instance_id = initial.get('instance_id')
|
instance_id = initial.get('instance_id')
|
||||||
self.fields['instance_id'] = forms.CharField(widget=forms.HiddenInput,
|
self.fields['instance_id'] = forms.CharField(widget=forms.HiddenInput,
|
||||||
|
@ -94,7 +94,7 @@ class LiveMigrateInstance(policy.PolicyTargetMixin,
|
|||||||
|
|
||||||
class AdminUpdateRow(project_tables.UpdateRow):
|
class AdminUpdateRow(project_tables.UpdateRow):
|
||||||
def get_data(self, request, instance_id):
|
def get_data(self, request, instance_id):
|
||||||
instance = super(AdminUpdateRow, self).get_data(request, instance_id)
|
instance = super().get_data(request, instance_id)
|
||||||
try:
|
try:
|
||||||
tenant = api.keystone.tenant_get(request,
|
tenant = api.keystone.tenant_get(request,
|
||||||
instance.tenant_id,
|
instance.tenant_id,
|
||||||
|
@ -205,7 +205,7 @@ class LiveMigrateView(forms.ModalFormView):
|
|||||||
success_label = page_title
|
success_label = page_title
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(LiveMigrateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["instance_id"] = self.kwargs['instance_id']
|
context["instance_id"] = self.kwargs['instance_id']
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ class LiveMigrateView(forms.ModalFormView):
|
|||||||
exceptions.handle(self.request, msg, redirect=redirect)
|
exceptions.handle(self.request, msg, redirect=redirect)
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(LiveMigrateView, self).get_initial()
|
initial = super().get_initial()
|
||||||
_object = self.get_object()
|
_object = self.get_object()
|
||||||
if _object:
|
if _object:
|
||||||
current_host = getattr(_object, 'OS-EXT-SRV-ATTR:host', '')
|
current_host = getattr(_object, 'OS-EXT-SRV-ATTR:host', '')
|
||||||
|
@ -61,7 +61,7 @@ class CreateNamespaceForm(forms.SelfHandlingForm):
|
|||||||
protected = forms.BooleanField(label=_("Protected"), required=False)
|
protected = forms.BooleanField(label=_("Protected"), required=False)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
data = super(CreateNamespaceForm, self).clean()
|
data = super().clean()
|
||||||
|
|
||||||
# The key can be missing based on particular upload
|
# The key can be missing based on particular upload
|
||||||
# conditions. Code defensively for it here...
|
# conditions. Code defensively for it here...
|
||||||
|
@ -101,7 +101,7 @@ class UpdateView(forms.ModalFormView):
|
|||||||
submit_label = _("Save Changes")
|
submit_label = _("Save Changes")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
args = (self.kwargs['namespace_id'],)
|
args = (self.kwargs['namespace_id'],)
|
||||||
context["namespace_id"] = self.kwargs['namespace_id']
|
context["namespace_id"] = self.kwargs['namespace_id']
|
||||||
context["submit_url"] = reverse(self.submit_url, args=args)
|
context["submit_url"] = reverse(self.submit_url, args=args)
|
||||||
@ -132,7 +132,7 @@ class DetailView(tabs.TabView):
|
|||||||
page_title = "{{ namespace.namespace }}"
|
page_title = "{{ namespace.namespace }}"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["namespace"] = self.get_data()
|
context["namespace"] = self.get_data()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ class ManageResourceTypes(forms.ModalFormView):
|
|||||||
'resource_types': resource_types}
|
'resource_types': resource_types}
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ManageResourceTypes, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
selected_type_names = [selected_type['name'] for selected_type in
|
selected_type_names = [selected_type['name'] for selected_type in
|
||||||
context['form'].initial['resource_types']]
|
context['form'].initial['resource_types']]
|
||||||
|
@ -32,7 +32,7 @@ class AddDHCPAgent(forms.SelfHandlingForm):
|
|||||||
help_text=_("Choose an DHCP Agent to attach to."))
|
help_text=_("Choose an DHCP Agent to attach to."))
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(AddDHCPAgent, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
initial = kwargs.get('initial', {})
|
initial = kwargs.get('initial', {})
|
||||||
self.fields['agent'].choices = self._populate_agent_choices(request,
|
self.fields['agent'].choices = self._populate_agent_choices(request,
|
||||||
initial)
|
initial)
|
||||||
|
@ -40,7 +40,7 @@ class AddView(forms.ModalFormView):
|
|||||||
args=(self.kwargs['network_id'],))
|
args=(self.kwargs['network_id'],))
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AddView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['network_id'] = self.kwargs['network_id']
|
context['network_id'] = self.kwargs['network_id']
|
||||||
args = (self.kwargs['network_id'],)
|
args = (self.kwargs['network_id'],)
|
||||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||||
@ -48,7 +48,7 @@ class AddView(forms.ModalFormView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(AddView, self).get_initial()
|
initial = super().get_initial()
|
||||||
agents = self._get_agents()
|
agents = self._get_agents()
|
||||||
network_id = self.kwargs['network_id']
|
network_id = self.kwargs['network_id']
|
||||||
try:
|
try:
|
||||||
|
@ -153,7 +153,7 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
return cls(request, *args, **kwargs)
|
return cls(request, *args, **kwargs)
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(CreateNetwork, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
tenant_choices = [('', _("Select a project"))]
|
tenant_choices = [('', _("Select a project"))]
|
||||||
tenants, has_more = api.keystone.tenant_list(request)
|
tenants, has_more = api.keystone.tenant_list(request)
|
||||||
for tenant in tenants:
|
for tenant in tenants:
|
||||||
@ -293,7 +293,7 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
exceptions.handle(request, msg, redirect=redirect)
|
exceptions.handle(request, msg, redirect=redirect)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(CreateNetwork, self).clean()
|
cleaned_data = super().clean()
|
||||||
if api.neutron.is_extension_supported(self.request, 'provider'):
|
if api.neutron.is_extension_supported(self.request, 'provider'):
|
||||||
self._clean_physical_network(cleaned_data)
|
self._clean_physical_network(cleaned_data)
|
||||||
self._clean_segmentation_id(cleaned_data)
|
self._clean_segmentation_id(cleaned_data)
|
||||||
|
@ -40,7 +40,7 @@ class DetailView(project_views.DetailView):
|
|||||||
tab_group_class = ports_tabs.PortDetailTabs
|
tab_group_class = ports_tabs.PortDetailTabs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
port = context["port"]
|
port = context["port"]
|
||||||
network_url = "horizon:admin:networks:detail"
|
network_url = "horizon:admin:networks:detail"
|
||||||
subnet_url = "horizon:admin:networks:subnets:detail"
|
subnet_url = "horizon:admin:networks:subnets:detail"
|
||||||
@ -70,7 +70,7 @@ class UpdateView(project_views.UpdateView):
|
|||||||
failure_url = 'horizon:admin:networks:detail'
|
failure_url = 'horizon:admin:networks:detail'
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
initial = super(UpdateView, self).get_initial()
|
initial = super().get_initial()
|
||||||
port = self._get_object()
|
port = self._get_object()
|
||||||
if 'binding__host_id' in port:
|
if 'binding__host_id' in port:
|
||||||
initial['binding__host_id'] = port['binding__host_id']
|
initial['binding__host_id'] = port['binding__host_id']
|
||||||
|
@ -56,7 +56,7 @@ class CreatePort(project_workflow.CreatePort):
|
|||||||
args=(self.context['network_id'],))
|
args=(self.context['network_id'],))
|
||||||
|
|
||||||
def _construct_parameters(self, context):
|
def _construct_parameters(self, context):
|
||||||
params = super(CreatePort, self)._construct_parameters(context)
|
params = super()._construct_parameters(context)
|
||||||
params.update({'tenant_id': context['target_tenant_id'],
|
params.update({'tenant_id': context['target_tenant_id'],
|
||||||
'binding__host_id': context['binding__host_id']})
|
'binding__host_id': context['binding__host_id']})
|
||||||
return params
|
return params
|
||||||
@ -97,7 +97,7 @@ class UpdatePort(project_workflow.UpdatePort):
|
|||||||
args=(self.context['network_id'],))
|
args=(self.context['network_id'],))
|
||||||
|
|
||||||
def _construct_parameters(self, data):
|
def _construct_parameters(self, data):
|
||||||
params = super(UpdatePort, self)._construct_parameters(data)
|
params = super()._construct_parameters(data)
|
||||||
params.update({'device_id': data['device_id'],
|
params.update({'device_id': data['device_id'],
|
||||||
'device_owner': data['device_owner'],
|
'device_owner': data['device_owner'],
|
||||||
'binding__host_id': data['binding__host_id'],
|
'binding__host_id': data['binding__host_id'],
|
||||||
|
@ -120,10 +120,9 @@ class SubnetsTable(tables.DataTable):
|
|||||||
hidden_title = False
|
hidden_title = False
|
||||||
|
|
||||||
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
||||||
super(SubnetsTable, self).__init__(
|
super().__init__(request, data=data,
|
||||||
request, data=data,
|
needs_form_wrapper=needs_form_wrapper,
|
||||||
needs_form_wrapper=needs_form_wrapper,
|
**kwargs)
|
||||||
**kwargs)
|
|
||||||
if not api.neutron.is_extension_supported(request,
|
if not api.neutron.is_extension_supported(request,
|
||||||
'network-ip-availability'):
|
'network-ip-availability'):
|
||||||
del self.columns['subnet_used_ips']
|
del self.columns['subnet_used_ips']
|
||||||
@ -168,7 +167,7 @@ class SubnetsTab(project_tabs_subnets_tab):
|
|||||||
|
|
||||||
def get_subnets_data(self):
|
def get_subnets_data(self):
|
||||||
try:
|
try:
|
||||||
subnets = super(SubnetsTab, self).get_subnets_data()
|
subnets = super().get_subnets_data()
|
||||||
network_id = self.tab_group.kwargs['network_id']
|
network_id = self.tab_group.kwargs['network_id']
|
||||||
|
|
||||||
if api.neutron.is_extension_supported(self.request,
|
if api.neutron.is_extension_supported(self.request,
|
||||||
|
@ -32,7 +32,7 @@ class UpdateView(project_views.UpdateView):
|
|||||||
|
|
||||||
class DetailView(project_views.DetailView):
|
class DetailView(project_views.DetailView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
subnet = context['subnet']
|
subnet = context['subnet']
|
||||||
table = admin_tables.SubnetsTable(self.request,
|
table = admin_tables.SubnetsTable(self.request,
|
||||||
network_id=subnet.network_id)
|
network_id=subnet.network_id)
|
||||||
|
@ -119,10 +119,9 @@ class NetworksTable(tables.DataTable):
|
|||||||
row_actions = (EditNetwork, CreateSubnet, project_tables.DeleteNetwork)
|
row_actions = (EditNetwork, CreateSubnet, project_tables.DeleteNetwork)
|
||||||
|
|
||||||
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs):
|
||||||
super(NetworksTable, self).__init__(
|
super().__init__(request, data=data,
|
||||||
request, data=data,
|
needs_form_wrapper=needs_form_wrapper,
|
||||||
needs_form_wrapper=needs_form_wrapper,
|
**kwargs)
|
||||||
**kwargs)
|
|
||||||
try:
|
try:
|
||||||
if not api.neutron.is_extension_supported(
|
if not api.neutron.is_extension_supported(
|
||||||
request, "network_availability_zone"):
|
request, "network_availability_zone"):
|
||||||
|
@ -118,7 +118,7 @@ class IndexView(tables.DataTableView):
|
|||||||
return networks
|
return networks
|
||||||
|
|
||||||
def get_filters(self, filters=None, filters_map=None):
|
def get_filters(self, filters=None, filters_map=None):
|
||||||
filters = super(IndexView, self).get_filters(filters, filters_map)
|
filters = super().get_filters(filters, filters_map)
|
||||||
if 'project' in filters:
|
if 'project' in filters:
|
||||||
tenants = api.keystone.tenant_list(self.request)[0]
|
tenants = api.keystone.tenant_list(self.request)[0]
|
||||||
tenant_filter_ids = [t.id for t in tenants
|
tenant_filter_ids = [t.id for t in tenants
|
||||||
@ -179,7 +179,7 @@ class DetailView(tabs.TabbedTableView):
|
|||||||
return reverse_lazy('horizon:admin:networks:index')
|
return reverse_lazy('horizon:admin:networks:index')
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
network = self._get_data()
|
network = self._get_data()
|
||||||
context["network"] = network
|
context["network"] = network
|
||||||
table = networks_tables.NetworksTable(self.request)
|
table = networks_tables.NetworksTable(self.request)
|
||||||
|
@ -26,13 +26,11 @@ class CreateNetworkInfoAction(network_workflows.CreateNetworkInfoAction):
|
|||||||
self.create_network_form = context.get('create_network_form')
|
self.create_network_form = context.get('create_network_form')
|
||||||
self.base_fields = self.create_network_form.base_fields
|
self.base_fields = self.create_network_form.base_fields
|
||||||
|
|
||||||
super(CreateNetworkInfoAction, self).__init__(
|
super().__init__(request, context, *args, **kwargs)
|
||||||
request, context, *args, **kwargs)
|
|
||||||
self.fields = self.create_network_form.fields
|
self.fields = self.create_network_form.fields
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
self.create_network_form.cleaned_data = super(
|
self.create_network_form.cleaned_data = super().clean()
|
||||||
CreateNetworkInfoAction, self).clean()
|
|
||||||
self.create_network_form._changed_data = self.changed_data
|
self.create_network_form._changed_data = self.changed_data
|
||||||
self.create_network_form._errors = self.errors
|
self.create_network_form._errors = self.errors
|
||||||
return self.create_network_form.clean()
|
return self.create_network_form.clean()
|
||||||
@ -48,11 +46,10 @@ class CreateNetworkInfo(network_workflows.CreateNetworkInfo):
|
|||||||
|
|
||||||
def __init__(self, workflow):
|
def __init__(self, workflow):
|
||||||
self.contributes = tuple(workflow.create_network_form.fields.keys())
|
self.contributes = tuple(workflow.create_network_form.fields.keys())
|
||||||
super(CreateNetworkInfo, self).__init__(workflow)
|
super().__init__(workflow)
|
||||||
|
|
||||||
def prepare_action_context(self, request, context):
|
def prepare_action_context(self, request, context):
|
||||||
context = super(CreateNetworkInfo, self).prepare_action_context(
|
context = super().prepare_action_context(request, context)
|
||||||
request, context)
|
|
||||||
context['create_network_form'] = self.workflow.create_network_form
|
context['create_network_form'] = self.workflow.create_network_form
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -66,11 +63,8 @@ class CreateNetwork(network_workflows.CreateNetwork):
|
|||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
self.create_network_form = networks_forms.CreateNetwork(
|
self.create_network_form = networks_forms.CreateNetwork(
|
||||||
request, *args, **kwargs)
|
request, *args, **kwargs)
|
||||||
super(CreateNetwork, self).__init__(
|
super().__init__(request=request, context_seed=context_seed,
|
||||||
request=request,
|
entry_point=entry_point, *args, **kwargs)
|
||||||
context_seed=context_seed,
|
|
||||||
entry_point=entry_point,
|
|
||||||
*args, **kwargs)
|
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse("horizon:admin:networks:index")
|
return reverse("horizon:admin:networks:index")
|
||||||
|
@ -50,12 +50,12 @@ class GlobalOverview(usage.UsageView):
|
|||||||
csv_response_class = GlobalUsageCsvRenderer
|
csv_response_class = GlobalUsageCsvRenderer
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(GlobalOverview, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['monitoring'] = settings.EXTERNAL_MONITORING
|
context['monitoring'] = settings.EXTERNAL_MONITORING
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_data(self):
|
def get_data(self):
|
||||||
data = super(GlobalOverview, self).get_data()
|
data = super().get_data()
|
||||||
# Pre-fill project names
|
# Pre-fill project names
|
||||||
try:
|
try:
|
||||||
projects, has_more = api.keystone.tenant_list(self.request)
|
projects, has_more = api.keystone.tenant_list(self.request)
|
||||||
|
@ -79,7 +79,7 @@ class CreatePolicyForm(forms.SelfHandlingForm):
|
|||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(CreatePolicyForm, self).clean()
|
cleaned_data = super().clean()
|
||||||
action_object_type = cleaned_data.get("action_object_type")
|
action_object_type = cleaned_data.get("action_object_type")
|
||||||
error_msg = _("This field is required.")
|
error_msg = _("This field is required.")
|
||||||
if action_object_type in ["shared_network", "external_network"]:
|
if action_object_type in ["shared_network", "external_network"]:
|
||||||
@ -91,7 +91,7 @@ class CreatePolicyForm(forms.SelfHandlingForm):
|
|||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(CreatePolicyForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
tenant_choices = [('', _("Select a project"))]
|
tenant_choices = [('', _("Select a project"))]
|
||||||
tenants, has_more = api.keystone.tenant_list(request)
|
tenants, has_more = api.keystone.tenant_list(request)
|
||||||
tenant_choices.append(("*", "*"))
|
tenant_choices.append(("*", "*"))
|
||||||
@ -161,7 +161,7 @@ class UpdatePolicyForm(forms.SelfHandlingForm):
|
|||||||
failure_url = 'horizon:admin:rbac_policies:index'
|
failure_url = 'horizon:admin:rbac_policies:index'
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(UpdatePolicyForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
tenant_choices = [('', _("Select a project"))]
|
tenant_choices = [('', _("Select a project"))]
|
||||||
tenant_choices.append(("*", "*"))
|
tenant_choices.append(("*", "*"))
|
||||||
tenants, has_more = api.keystone.tenant_list(request)
|
tenants, has_more = api.keystone.tenant_list(request)
|
||||||
|
@ -44,7 +44,7 @@ class OverviewTab(tabs.Tab):
|
|||||||
return rbac_policy
|
return rbac_policy
|
||||||
|
|
||||||
def get_context_data(self, request, **kwargs):
|
def get_context_data(self, request, **kwargs):
|
||||||
context = super(OverviewTab, self).get_context_data(request, **kwargs)
|
context = super().get_context_data(request, **kwargs)
|
||||||
rbac_policy = self._get_data()
|
rbac_policy = self._get_data()
|
||||||
|
|
||||||
context["rbac_policy"] = rbac_policy
|
context["rbac_policy"] = rbac_policy
|
||||||
|
@ -116,7 +116,7 @@ class UpdateView(forms.ModalFormView):
|
|||||||
page_title = _("Update RBAC Policy")
|
page_title = _("Update RBAC Policy")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(UpdateView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
args = (self.kwargs['rbac_policy_id'],)
|
args = (self.kwargs['rbac_policy_id'],)
|
||||||
context["rbac_policy_id"] = self.kwargs['rbac_policy_id']
|
context["rbac_policy_id"] = self.kwargs['rbac_policy_id']
|
||||||
context["submit_url"] = reverse(self.submit_url, args=args)
|
context["submit_url"] = reverse(self.submit_url, args=args)
|
||||||
|
@ -27,7 +27,7 @@ class CreateForm(r_forms.CreateForm):
|
|||||||
failure_url = 'horizon:admin:routers:index'
|
failure_url = 'horizon:admin:routers:index'
|
||||||
|
|
||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
super(CreateForm, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
tenant_choices = [('', _("Select a project"))]
|
tenant_choices = [('', _("Select a project"))]
|
||||||
tenants, __ = api.keystone.tenant_list(request)
|
tenants, __ = api.keystone.tenant_list(request)
|
||||||
for tenant in tenants:
|
for tenant in tenants:
|
||||||
|
@ -55,7 +55,7 @@ class RouterMixin(r_test.RouterMixin):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def _check_get_detail(self, router, extraroute=True):
|
def _check_get_detail(self, router, extraroute=True):
|
||||||
super(RouterMixin, self)._check_get_detail(router, extraroute)
|
super()._check_get_detail(router, extraroute)
|
||||||
self.mock_is_extension_supported.assert_any_call(
|
self.mock_is_extension_supported.assert_any_call(
|
||||||
test.IsHttpRequest(), 'l3_agent_scheduler')
|
test.IsHttpRequest(), 'l3_agent_scheduler')
|
||||||
if self.support_l3_agent:
|
if self.support_l3_agent:
|
||||||
@ -191,7 +191,7 @@ class RouterTests(RouterMixin, r_test.RouterTestCase, test.BaseAdminViewTests):
|
|||||||
|
|
||||||
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
||||||
def test_router_detail(self):
|
def test_router_detail(self):
|
||||||
super(RouterTests, self).test_router_detail()
|
super().test_router_detail()
|
||||||
|
|
||||||
@test.create_mocks({api.neutron: ('router_list',
|
@test.create_mocks({api.neutron: ('router_list',
|
||||||
'network_list',
|
'network_list',
|
||||||
@ -358,8 +358,8 @@ class RouterRouteTests(RouterMixin,
|
|||||||
|
|
||||||
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
||||||
def test_extension_hides_without_routes(self):
|
def test_extension_hides_without_routes(self):
|
||||||
super(RouterRouteTests, self).test_extension_hides_without_routes()
|
super().test_extension_hides_without_routes()
|
||||||
|
|
||||||
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
@test.create_mocks({api.neutron: ('list_l3_agent_hosting_router',)})
|
||||||
def test_routerroute_detail(self):
|
def test_routerroute_detail(self):
|
||||||
super(RouterRouteTests, self).test_routerroute_detail()
|
super().test_routerroute_detail()
|
||||||
|
@ -84,7 +84,7 @@ class IndexView(r_views.IndexView, n_views.IndexView):
|
|||||||
return routers
|
return routers
|
||||||
|
|
||||||
def get_filters(self, filters=None, filters_map=None):
|
def get_filters(self, filters=None, filters_map=None):
|
||||||
filters = super(IndexView, self).get_filters(filters, filters_map)
|
filters = super().get_filters(filters, filters_map)
|
||||||
if 'project' in filters:
|
if 'project' in filters:
|
||||||
tenants = api.keystone.tenant_list(self.request)[0]
|
tenants = api.keystone.tenant_list(self.request)[0]
|
||||||
tenants_filter_ids = [t.id for t in tenants
|
tenants_filter_ids = [t.id for t in tenants
|
||||||
@ -100,7 +100,7 @@ class DetailView(r_views.DetailView):
|
|||||||
network_url = 'horizon:admin:networks:detail'
|
network_url = 'horizon:admin:networks:detail'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
table = rtbl.RoutersTable(self.request)
|
table = rtbl.RoutersTable(self.request)
|
||||||
context["url"] = self.failure_url
|
context["url"] = self.failure_url
|
||||||
router = context["router"]
|
router = context["router"]
|
||||||
|
@ -53,7 +53,7 @@ class UpdateStatus(forms.SelfHandlingForm):
|
|||||||
current_status = kwargs['initial']['status']
|
current_status = kwargs['initial']['status']
|
||||||
kwargs['initial'].pop('status')
|
kwargs['initial'].pop('status')
|
||||||
|
|
||||||
super(UpdateStatus, self).__init__(request, *args, **kwargs)
|
super().__init__(request, *args, **kwargs)
|
||||||
|
|
||||||
self.fields['status'].choices = populate_status_choices(
|
self.fields['status'].choices = populate_status_choices(
|
||||||
current_status, STATUS_CHOICES)
|
current_status, STATUS_CHOICES)
|
||||||
|
@ -38,7 +38,7 @@ class UpdateRow(snapshots_tables.UpdateRow):
|
|||||||
ajax = True
|
ajax = True
|
||||||
|
|
||||||
def get_data(self, request, snapshot_id):
|
def get_data(self, request, snapshot_id):
|
||||||
snapshot = super(UpdateRow, self).get_data(request, snapshot_id)
|
snapshot = super().get_data(request, snapshot_id)
|
||||||
snapshot.host_name = getattr(snapshot._volume,
|
snapshot.host_name = getattr(snapshot._volume,
|
||||||
'os-vol-host-attr:host')
|
'os-vol-host-attr:host')
|
||||||
tenant_id = getattr(snapshot._volume,
|
tenant_id = getattr(snapshot._volume,
|
||||||
|
@ -119,7 +119,7 @@ class UpdateStatusView(forms.ModalFormView):
|
|||||||
return self._object
|
return self._object
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(UpdateStatusView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['snapshot_id'] = self.kwargs["snapshot_id"]
|
context['snapshot_id'] = self.kwargs["snapshot_id"]
|
||||||
args = (self.kwargs['snapshot_id'],)
|
args = (self.kwargs['snapshot_id'],)
|
||||||
context['submit_url'] = reverse(self.submit_url, args=args)
|
context['submit_url'] = reverse(self.submit_url, args=args)
|
||||||
@ -136,7 +136,7 @@ class DetailView(views.DetailView):
|
|||||||
volume_url = 'horizon:admin:volumes:detail'
|
volume_url = 'horizon:admin:volumes:detail'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
snapshot = self.get_data()
|
snapshot = self.get_data()
|
||||||
snapshot.volume_url = reverse(self.volume_url,
|
snapshot.volume_url = reverse(self.volume_url,
|
||||||
args=(snapshot.volume_id,))
|
args=(snapshot.volume_id,))
|
||||||
|
@ -33,7 +33,7 @@ class Trunks(horizon.Panel):
|
|||||||
request = context['request']
|
request = context['request']
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
super(Trunks, self).allowed(context) and
|
super().allowed(context) and
|
||||||
request.user.has_perms(self.permissions) and
|
request.user.has_perms(self.permissions) and
|
||||||
neutron.is_extension_supported(request,
|
neutron.is_extension_supported(request,
|
||||||
extension_alias='trunk')
|
extension_alias='trunk')
|
||||||
|
@ -75,7 +75,7 @@ class DetailView(project_views.DetailView):
|
|||||||
tab_group_class = admin_tabs.DetailTabs
|
tab_group_class = admin_tabs.DetailTabs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
table = admin_tables.GroupSnapshotsTable(self.request)
|
table = admin_tables.GroupSnapshotsTable(self.request)
|
||||||
context["actions"] = table.render_row_actions(context["vg_snapshot"])
|
context["actions"] = table.render_row_actions(context["vg_snapshot"])
|
||||||
return context
|
return context
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user