From b4fc9b4bc96cbfbf61243cd0427a0f00635e6ad5 Mon Sep 17 00:00:00 2001 From: Tatiana Mazur Date: Fri, 23 Aug 2013 17:26:48 +0400 Subject: [PATCH] Small "H302 check" cleanup This patch set removes some commented out stuff that has been unintentially left in "H302 check" patch set. It also replaces a couple more method imports with module imports. Fixes bug 1215892 Change-Id: I35fd880154a4ea6d6d8d3b3615103c271aa4a005 --- openstack_dashboard/api/keystone.py | 5 +- .../dashboards/admin/domains/panel.py | 4 +- .../dashboards/admin/domains/tables.py | 4 +- .../dashboards/admin/groups/panel.py | 4 +- .../dashboards/admin/instances/tables.py | 49 +++---------------- .../dashboards/admin/overview/tests.py | 4 +- .../dashboards/admin/roles/panel.py | 4 +- .../security_groups/forms.py | 20 +++++--- .../security_groups/tests.py | 3 -- .../dashboards/project/instances/tables.py | 15 +++--- .../project/loadbalancers/workflows.py | 6 +-- .../dashboards/project/stacks/mappings.py | 4 +- .../dashboards/project/stacks/sro.py | 11 +++-- .../dashboards/project/stacks/tables.py | 17 +++---- .../dashboards/project/volumes/forms.py | 15 +++--- .../dashboards/settings/password/urls.py | 4 +- .../dashboards/settings/password/views.py | 6 ++- .../dashboards/settings/user/urls.py | 4 +- .../dashboards/settings/user/views.py | 4 +- openstack_dashboard/test/helpers.py | 6 +-- openstack_dashboard/test/settings.py | 6 +-- .../test/test_data/exceptions.py | 4 +- openstack_dashboard/usage/tables.py | 4 +- openstack_dashboard/usage/views.py | 4 +- openstack_dashboard/views.py | 4 +- 25 files changed, 89 insertions(+), 122 deletions(-) diff --git a/openstack_dashboard/api/keystone.py b/openstack_dashboard/api/keystone.py index 6104baa417..3bc2a4c030 100644 --- a/openstack_dashboard/api/keystone.py +++ b/openstack_dashboard/api/keystone.py @@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa from keystoneclient.exceptions import ClientException # noqa -from openstack_auth.backend import KEYSTONE_CLIENT_ATTR # noqa +from openstack_auth import backend from horizon import exceptions from horizon import messages @@ -154,7 +154,8 @@ def keystoneclient(request, admin=False): # Take care of client connection caching/fetching a new client. # Admin vs. non-admin clients are cached separately for token matching. - cache_attr = "_keystoneclient_admin" if admin else KEYSTONE_CLIENT_ATTR + cache_attr = "_keystoneclient_admin" if admin \ + else backend.KEYSTONE_CLIENT_ATTR if hasattr(request, cache_attr) and (not user.token.id or getattr(request, cache_attr).auth_token == user.token.id): LOG.debug("Using cached client for token: %s" % user.token.id) diff --git a/openstack_dashboard/dashboards/admin/domains/panel.py b/openstack_dashboard/dashboards/admin/domains/panel.py index 6ee3984de5..4f5deb6a3e 100644 --- a/openstack_dashboard/dashboards/admin/domains/panel.py +++ b/openstack_dashboard/dashboards/admin/domains/panel.py @@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa import horizon -from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS # noqa +from openstack_dashboard.api import keystone from openstack_dashboard.dashboards.admin import dashboard @@ -27,5 +27,5 @@ class Domains(horizon.Panel): slug = 'domains' -if IDENTITY_VERSIONS.active >= 3: +if keystone.VERSIONS.active >= 3: dashboard.Admin.register(Domains) diff --git a/openstack_dashboard/dashboards/admin/domains/tables.py b/openstack_dashboard/dashboards/admin/domains/tables.py index d880bcf11d..71c1b36266 100644 --- a/openstack_dashboard/dashboards/admin/domains/tables.py +++ b/openstack_dashboard/dashboards/admin/domains/tables.py @@ -19,7 +19,7 @@ import logging from django.conf import settings # noqa from django.utils.translation import ugettext_lazy as _ # noqa -from keystoneclient.exceptions import ClientException # noqa +from keystoneclient import exceptions from horizon import messages from horizon import tables @@ -66,7 +66,7 @@ class DeleteDomainsAction(tables.DeleteAction): msg = _('Domain "%s" must be disabled before it can be deleted.') \ % domain.name messages.error(request, msg) - raise ClientException(409, msg) + raise exceptions.ClientException(409, msg) else: LOG.info('Deleting domain "%s".' % obj_id) api.keystone.domain_delete(request, obj_id) diff --git a/openstack_dashboard/dashboards/admin/groups/panel.py b/openstack_dashboard/dashboards/admin/groups/panel.py index 0f1ce6e296..2a5bb92b2d 100644 --- a/openstack_dashboard/dashboards/admin/groups/panel.py +++ b/openstack_dashboard/dashboards/admin/groups/panel.py @@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa import horizon -from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS # noqa +from openstack_dashboard.api import keystone from openstack_dashboard.dashboards.admin import dashboard @@ -27,5 +27,5 @@ class Groups(horizon.Panel): slug = 'groups' -if IDENTITY_VERSIONS.active >= 3: +if keystone.VERSIONS.active >= 3: dashboard.Admin.register(Groups) diff --git a/openstack_dashboard/dashboards/admin/instances/tables.py b/openstack_dashboard/dashboards/admin/instances/tables.py index ced016a1b8..9738a6e39c 100644 --- a/openstack_dashboard/dashboards/admin/instances/tables.py +++ b/openstack_dashboard/dashboards/admin/instances/tables.py @@ -22,49 +22,12 @@ from django.template.defaultfilters import title # noqa from django.utils.translation import ugettext_lazy as _ # noqa from horizon import tables -from horizon.utils.filters import parse_isotime # noqa -from horizon.utils.filters import replace_underscores # noqa +from horizon.utils import filters from openstack_dashboard import api from openstack_dashboard.dashboards.project.instances \ import tables as project_tables -# ACTIVE_STATES -#from openstack_dashboard.dashboards.project.instances.tables import \ -# ConfirmResize -#from openstack_dashboard.dashboards.project.instances.tables import \ -# ConsoleLink -#from openstack_dashboard.dashboards.project.instances.tables import \ -# CreateSnapshot -#from openstack_dashboard.dashboards.project.instances.tables import \ -# EditInstance -#from openstack_dashboard.dashboards.project.instances.tables import \ -# get_ips -#from openstack_dashboard.dashboards.project.instances.tables import \ -# get_power_state -#from openstack_dashboard.dashboards.project.instances.tables import \ -# get_size -#from openstack_dashboard.dashboards.project.instances.tables import \ -# is_deleting -#from openstack_dashboard.dashboards.project.instances.tables import \ -# LogLink -#from openstack_dashboard.dashboards.project.instances.tables import \ -# RebootInstance -#from openstack_dashboard.dashboards.project.instances.tables import \ -# RevertResize -#from openstack_dashboard.dashboards.project.instances.tables import \ -# SoftRebootInstance -#from openstack_dashboard.dashboards.project.instances.tables import \ -# STATUS_DISPLAY_CHOICES -#from openstack_dashboard.dashboards.project.instances.tables import \ -# TASK_DISPLAY_CHOICES -#from openstack_dashboard.dashboards.project.instances.tables import \ -# TerminateInstance -#from openstack_dashboard.dashboards.project.instances.tables import \ -# TogglePause -#from openstack_dashboard.dashboards.project.instances.tables import \ -# ToggleSuspend -#from openstack_dashboard.dashboards.project.instances.tables import \ -# UpdateRow + LOG = logging.getLogger(__name__) @@ -141,7 +104,7 @@ class AdminInstancesTable(tables.DataTable): classes=('nowrap-col',), attrs={'data-type': 'size'}) status = tables.Column("status", - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES, @@ -149,16 +112,16 @@ class AdminInstancesTable(tables.DataTable): project_tables.STATUS_DISPLAY_CHOICES) task = tables.Column("OS-EXT-STS:task_state", verbose_name=_("Task"), - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), status=True, status_choices=TASK_STATUS_CHOICES, display_choices=project_tables.TASK_DISPLAY_CHOICES) state = tables.Column(project_tables.get_power_state, - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Power State")) created = tables.Column("created", verbose_name=_("Uptime"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) class Meta: name = "instances" diff --git a/openstack_dashboard/dashboards/admin/overview/tests.py b/openstack_dashboard/dashboards/admin/overview/tests.py index e227509096..b5af5a7b23 100644 --- a/openstack_dashboard/dashboards/admin/overview/tests.py +++ b/openstack_dashboard/dashboards/admin/overview/tests.py @@ -26,7 +26,7 @@ from django.utils import timezone from mox import IsA # noqa -from horizon.templatetags.sizeformat import mbformat # noqa +from horizon.templatetags import sizeformat from openstack_dashboard import api from openstack_dashboard.test import helpers as test @@ -69,7 +69,7 @@ class UsageViewTests(test.BaseAdminViewTests): '%.2f' % (usage_obj.vcpus, usage_obj.disk_gb_hours, - mbformat(usage_obj.memory_mb), + sizeformat.mbformat(usage_obj.memory_mb), usage_obj.vcpu_hours, usage_obj.total_local_gb_usage)) diff --git a/openstack_dashboard/dashboards/admin/roles/panel.py b/openstack_dashboard/dashboards/admin/roles/panel.py index c752a9b19b..75063dbeb7 100644 --- a/openstack_dashboard/dashboards/admin/roles/panel.py +++ b/openstack_dashboard/dashboards/admin/roles/panel.py @@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa import horizon -from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS # noqa +from openstack_dashboard.api import keystone from openstack_dashboard.dashboards.admin import dashboard @@ -26,5 +26,5 @@ class Roles(horizon.Panel): name = _("Roles") slug = 'roles' -if IDENTITY_VERSIONS.active >= 3: +if keystone.VERSIONS.active >= 3: dashboard.Admin.register(Roles) diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py index 1bdaba7d27..b3c7c4da06 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/forms.py @@ -32,8 +32,7 @@ from horizon import exceptions from horizon import forms from horizon import messages from horizon.utils import fields -from horizon.utils.validators import validate_ip_protocol # noqa -from horizon.utils.validators import validate_port_range # noqa +from horizon.utils import validators as utils_validators from openstack_dashboard import api from openstack_dashboard.utils import filters @@ -96,7 +95,7 @@ class AddRule(forms.SelfHandlingForm): label=_('IP Protocol'), required=False, help_text=_("Enter an integer value between 0 and 255 " "(or -1 which means wildcard)."), - validators=[validate_ip_protocol], + validators=[utils_validators.validate_ip_protocol], widget=forms.TextInput(attrs={ 'class': 'switched', 'data-switch-on': 'rule_menu', @@ -121,7 +120,8 @@ class AddRule(forms.SelfHandlingForm): 'class': 'switched', 'data-switch-on': 'range', 'data-range-port': _('Port')}), - validators=[validate_port_range]) + validators=[ + utils_validators.validate_port_range]) from_port = forms.IntegerField(label=_("From Port"), required=False, @@ -131,7 +131,8 @@ class AddRule(forms.SelfHandlingForm): 'class': 'switched', 'data-switch-on': 'range', 'data-range-range': _('From Port')}), - validators=[validate_port_range]) + validators=[ + utils_validators.validate_port_range]) to_port = forms.IntegerField(label=_("To Port"), required=False, @@ -141,7 +142,8 @@ class AddRule(forms.SelfHandlingForm): 'class': 'switched', 'data-switch-on': 'range', 'data-range-range': _('To Port')}), - validators=[validate_port_range]) + validators=[ + utils_validators.validate_port_range]) icmp_type = forms.IntegerField(label=_("Type"), required=False, @@ -151,7 +153,8 @@ class AddRule(forms.SelfHandlingForm): 'class': 'switched', 'data-switch-on': 'rule_menu', 'data-rule_menu-icmp': _('Type')}), - validators=[validate_port_range]) + validators=[ + utils_validators.validate_port_range]) icmp_code = forms.IntegerField(label=_("Code"), required=False, @@ -161,7 +164,8 @@ class AddRule(forms.SelfHandlingForm): 'class': 'switched', 'data-switch-on': 'rule_menu', 'data-rule_menu-icmp': _('Code')}), - validators=[validate_port_range]) + validators=[ + utils_validators.validate_port_range]) remote = forms.ChoiceField(label=_('Remote'), choices=[('cidr', _('CIDR')), diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py index d57178e353..1b14d9a6e4 100644 --- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py +++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py @@ -31,9 +31,6 @@ from openstack_dashboard.test import helpers as test from openstack_dashboard.dashboards.project.access_and_security.\ security_groups import tables -# import RulesTable -#from openstack_dashboard.dashboards.project.access_and_security.\ -# security_groups.tables import SecurityGroupsTable INDEX_URL = reverse('horizon:project:access_and_security:index') diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index c1757ef6f0..ff03515025 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -26,13 +26,12 @@ from django.utils.http import urlencode # noqa from django.utils.translation import string_concat # noqa from django.utils.translation import ugettext_lazy as _ # noqa -from horizon.conf import HORIZON_CONFIG # noqa +from horizon import conf from horizon import exceptions from horizon import messages from horizon import tables from horizon.templatetags import sizeformat -from horizon.utils.filters import parse_isotime # noqa -from horizon.utils.filters import replace_underscores # noqa +from horizon.utils import filters from openstack_dashboard import api from openstack_dashboard.dashboards.project.access_and_security.floating_ips \ @@ -403,7 +402,7 @@ class SimpleDisassociateIP(tables.Action): classes = ("btn-danger", "btn-disassociate",) def allowed(self, request, instance): - if not HORIZON_CONFIG["simple_ip_management"]: + if not conf.HORIZON_CONFIG["simple_ip_management"]: return False return not is_deleting(instance) @@ -557,23 +556,23 @@ class InstancesTable(tables.DataTable): attrs={'data-type': 'size'}) keypair = tables.Column(get_keyname, verbose_name=_("Keypair")) status = tables.Column("status", - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES, display_choices=STATUS_DISPLAY_CHOICES) task = tables.Column("OS-EXT-STS:task_state", verbose_name=_("Task"), - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), status=True, status_choices=TASK_STATUS_CHOICES, display_choices=TASK_DISPLAY_CHOICES) state = tables.Column(get_power_state, - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Power State")) created = tables.Column("created", verbose_name=_("Uptime"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) class Meta: name = "instances" diff --git a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py index 159bc9f025..49062beaaa 100644 --- a/openstack_dashboard/dashboards/project/loadbalancers/workflows.py +++ b/openstack_dashboard/dashboards/project/loadbalancers/workflows.py @@ -21,7 +21,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa from horizon import exceptions from horizon import forms from horizon.utils import fields -from horizon.utils.validators import validate_port_range # noqa +from horizon.utils import validators from horizon import workflows from openstack_dashboard import api @@ -129,7 +129,7 @@ class AddVipAction(workflows.Action): protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1, help_text=_("Enter an integer value " "between 1 and 65535."), - validators=[validate_port_range]) + validators=[validators.validate_port_range]) protocol = forms.ChoiceField(label=_("Protocol")) session_persistence = forms.ChoiceField( required=False, initial={}, label=_("Session Persistence")) @@ -265,7 +265,7 @@ class AddMemberAction(workflows.Action): protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1, help_text=_("Enter an integer value " "between 1 and 65535."), - validators=[validate_port_range]) + validators=[validators.validate_port_range]) admin_state_up = forms.BooleanField(label=_("Admin State"), initial=True, required=False) diff --git a/openstack_dashboard/dashboards/project/stacks/mappings.py b/openstack_dashboard/dashboards/project/stacks/mappings.py index 490cc1f3db..0353291248 100644 --- a/openstack_dashboard/dashboards/project/stacks/mappings.py +++ b/openstack_dashboard/dashboards/project/stacks/mappings.py @@ -20,7 +20,7 @@ import urlparse from django.core.urlresolvers import reverse # noqa from django.template.defaultfilters import register # noqa -from openstack_dashboard.api.swift import FOLDER_DELIMITER # noqa +from openstack_dashboard.api import swift LOG = logging.getLogger(__name__) @@ -50,7 +50,7 @@ resource_urls = { 'link': 'horizon:project:networks:subnets:detail'}, "OS::Swift::Container": { 'link': 'horizon:project:containers:index', - 'format_pattern': '%s' + FOLDER_DELIMITER}, + 'format_pattern': '%s' + swift.FOLDER_DELIMITER}, } diff --git a/openstack_dashboard/dashboards/project/stacks/sro.py b/openstack_dashboard/dashboards/project/stacks/sro.py index 0399ceca9f..ac8a5f6eca 100644 --- a/openstack_dashboard/dashboards/project/stacks/sro.py +++ b/openstack_dashboard/dashboards/project/stacks/sro.py @@ -1,14 +1,15 @@ from django.template.defaultfilters import title # noqa from django.template.loader import render_to_string # noqa -from horizon.utils.filters import replace_underscores # noqa +from horizon.utils import filters def stack_info(stack, stack_image): - stack.stack_status_desc = title(replace_underscores(stack.stack_status)) + stack.stack_status_desc = title( + filters.replace_underscores(stack.stack_status)) if stack.stack_status_reason: stack.stack_status_reason = title( - replace_underscores(stack.stack_status_reason) + filters.replace_underscores(stack.stack_status_reason) ) context = {} context['stack'] = stack @@ -19,11 +20,11 @@ def stack_info(stack, stack_image): def resource_info(resource): resource.resource_status_desc = title( - replace_underscores(resource.resource_status) + filters.replace_underscores(resource.resource_status) ) if resource.resource_status_reason: resource.resource_status_reason = title( - replace_underscores(resource.resource_status_reason) + filters.replace_underscores(resource.resource_status_reason) ) context = {} context['resource'] = resource diff --git a/openstack_dashboard/dashboards/project/stacks/tables.py b/openstack_dashboard/dashboards/project/stacks/tables.py index bb199221f2..8e0afa1bf9 100644 --- a/openstack_dashboard/dashboards/project/stacks/tables.py +++ b/openstack_dashboard/dashboards/project/stacks/tables.py @@ -21,8 +21,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa from horizon import messages from horizon import tables -from horizon.utils.filters import parse_isotime # noqa -from horizon.utils.filters import replace_underscores # noqa +from horizon.utils import filters from heatclient import exc @@ -77,12 +76,12 @@ class StacksTable(tables.DataTable): link="horizon:project:stacks:detail",) created = tables.Column("creation_time", verbose_name=_("Created"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) updated = tables.Column("updated_time", verbose_name=_("Updated"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) status = tables.Column("stack_status", - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES) @@ -109,9 +108,9 @@ class EventsTable(tables.DataTable): link=mappings.resource_to_url) timestamp = tables.Column('event_time', verbose_name=_("Time Since Event"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) status = tables.Column("resource_status", - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Status"),) statusreason = tables.Column("resource_status_reason", @@ -155,9 +154,9 @@ class ResourcesTable(tables.DataTable): verbose_name=_("Stack Resource Type"),) updated_time = tables.Column('updated_time', verbose_name=_("Date Updated"), - filters=(parse_isotime, timesince)) + filters=(filters.parse_isotime, timesince)) status = tables.Column("resource_status", - filters=(title, replace_underscores), + filters=(title, filters.replace_underscores), verbose_name=_("Status"), status=True, status_choices=STATUS_CHOICES) diff --git a/openstack_dashboard/dashboards/project/volumes/forms.py b/openstack_dashboard/dashboards/project/volumes/forms.py index 6fd480c1ee..b5341fc0ba 100644 --- a/openstack_dashboard/dashboards/project/volumes/forms.py +++ b/openstack_dashboard/dashboards/project/volumes/forms.py @@ -16,8 +16,8 @@ from django.utils.translation import ugettext_lazy as _ # noqa from horizon import exceptions from horizon import forms from horizon import messages -from horizon.utils.fields import SelectWidget # noqa -from horizon.utils.functions import bytes_to_gigabytes # noqa +from horizon.utils import fields +from horizon.utils import functions from horizon.utils.memoized import memoized # noqa from openstack_dashboard import api @@ -38,7 +38,7 @@ class CreateForm(forms.SelfHandlingForm): volume_source_type = forms.ChoiceField(label=_("Volume Source"), required=False) snapshot_source = forms.ChoiceField(label=_("Use snapshot as a source"), - widget=SelectWidget( + widget=fields.SelectWidget( attrs={'class': 'snapshot-selector'}, data_attrs=('size', 'display_name'), transform=lambda x: @@ -46,7 +46,7 @@ class CreateForm(forms.SelfHandlingForm): x.size))), required=False) image_source = forms.ChoiceField(label=_("Use image as a source"), - widget=SelectWidget( + widget=fields.SelectWidget( attrs={'class': 'image-selector'}, data_attrs=('size', 'name'), transform=lambda x: @@ -109,7 +109,8 @@ class CreateForm(forms.SelfHandlingForm): request.GET["image_id"]) image.bytes = image.size self.fields['name'].initial = image.name - self.fields['size'].initial = bytes_to_gigabytes(image.size) + self.fields['size'].initial = functions.bytes_to_gigabytes( + image.size) self.fields['image_source'].choices = ((image.id, image),) self.fields['size'].help_text = _('Volume size must be equal ' 'to or greater than the image size (%s)' @@ -143,7 +144,7 @@ class CreateForm(forms.SelfHandlingForm): choices = [('', _("Choose an image"))] for image in images: image.bytes = image.size - image.size = bytes_to_gigabytes(image.bytes) + image.size = functions.bytes_to_gigabytes(image.bytes) choices.append((image.id, image)) self.fields['image_source'].choices = choices else: @@ -189,7 +190,7 @@ class CreateForm(forms.SelfHandlingForm): image = self.get_image(request, data["image_source"]) image_id = image.id - image_size = bytes_to_gigabytes(image.size) + image_size = functions.bytes_to_gigabytes(image.size) if (data['size'] < image_size): error_message = _('The volume size cannot be less than ' 'the image size (%s)' % diff --git a/openstack_dashboard/dashboards/settings/password/urls.py b/openstack_dashboard/dashboards/settings/password/urls.py index 5001a2df16..1cc32f48b4 100644 --- a/openstack_dashboard/dashboards/settings/password/urls.py +++ b/openstack_dashboard/dashboards/settings/password/urls.py @@ -17,8 +17,8 @@ from django.conf.urls.defaults import patterns # noqa from django.conf.urls.defaults import url # noqa -from openstack_dashboard.dashboards.settings.password.views import PasswordView # noqa +from openstack_dashboard.dashboards.settings.password import views urlpatterns = patterns('', - url(r'^$', PasswordView.as_view(), name='index')) + url(r'^$', views.PasswordView.as_view(), name='index')) diff --git a/openstack_dashboard/dashboards/settings/password/views.py b/openstack_dashboard/dashboards/settings/password/views.py index 5017617f5a..d26873f55c 100644 --- a/openstack_dashboard/dashboards/settings/password/views.py +++ b/openstack_dashboard/dashboards/settings/password/views.py @@ -17,10 +17,12 @@ from horizon import forms from django.core.urlresolvers import reverse_lazy # noqa -from openstack_dashboard.dashboards.settings.password.forms import PasswordForm # noqa + +from openstack_dashboard.dashboards.settings.password \ + import forms as pass_forms class PasswordView(forms.ModalFormView): - form_class = PasswordForm + form_class = pass_forms.PasswordForm template_name = 'settings/password/change.html' success_url = reverse_lazy('logout') diff --git a/openstack_dashboard/dashboards/settings/user/urls.py b/openstack_dashboard/dashboards/settings/user/urls.py index 98cdf8b13a..ec87f24412 100644 --- a/openstack_dashboard/dashboards/settings/user/urls.py +++ b/openstack_dashboard/dashboards/settings/user/urls.py @@ -17,8 +17,8 @@ from django.conf.urls.defaults import patterns # noqa from django.conf.urls.defaults import url # noqa -from openstack_dashboard.dashboards.settings.user.views import UserSettingsView # noqa +from openstack_dashboard.dashboards.settings.user import views urlpatterns = patterns('', - url(r'^$', UserSettingsView.as_view(), name='index')) + url(r'^$', views.UserSettingsView.as_view(), name='index')) diff --git a/openstack_dashboard/dashboards/settings/user/views.py b/openstack_dashboard/dashboards/settings/user/views.py index a58b0dd76f..a310253375 100644 --- a/openstack_dashboard/dashboards/settings/user/views.py +++ b/openstack_dashboard/dashboards/settings/user/views.py @@ -17,11 +17,11 @@ from django.conf import settings # noqa from horizon import forms -from openstack_dashboard.dashboards.settings.user.forms import UserSettingsForm # noqa +from openstack_dashboard.dashboards.settings.user import forms as user_forms class UserSettingsView(forms.ModalFormView): - form_class = UserSettingsForm + form_class = user_forms.UserSettingsForm template_name = 'settings/user/settings.html' def get_initial(self): diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index dbd80664b1..02bf96a308 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -49,7 +49,7 @@ from horizon.test import helpers as horizon_helpers from openstack_dashboard import api from openstack_dashboard import context_processors -from openstack_dashboard.test.test_data.utils import load_test_data # noqa +from openstack_dashboard.test.test_data import utils as test_utils # Makes output of failing mox tests much easier to read. @@ -115,7 +115,7 @@ class TestCase(horizon_helpers.TestCase): * Several handy additional assertion methods. """ def setUp(self): - load_test_data(self) + test_utils.load_test_data(self) self.mox = mox.Mox() self.factory = RequestFactoryWithMessages() self.context = {'authorized_tenants': self.tenants.list()} @@ -344,7 +344,7 @@ class SeleniumTestCase(horizon_helpers.SeleniumTestCase): def setUp(self): super(SeleniumTestCase, self).setUp() - load_test_data(self) + test_utils.load_test_data(self) self.mox = mox.Mox() self._real_get_user = utils.get_user diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py index 3944e765ff..d7ed2bce64 100644 --- a/openstack_dashboard/test/settings.py +++ b/openstack_dashboard/test/settings.py @@ -3,7 +3,7 @@ import os from django.utils.translation import ugettext_lazy as _ # noqa from horizon.test.settings import * # noqa -from horizon.utils.secret_key import generate_or_read_from_file # noqa +from horizon.utils import secret_key from openstack_dashboard import exceptions @@ -11,8 +11,8 @@ from openstack_dashboard import exceptions TEST_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, "..")) -SECRET_KEY = generate_or_read_from_file(os.path.join(TEST_DIR, - '.secret_key_store')) +SECRET_KEY = secret_key.generate_or_read_from_file( + os.path.join(TEST_DIR, '.secret_key_store')) ROOT_URLCONF = 'openstack_dashboard.urls' TEMPLATE_DIRS = ( os.path.join(TEST_DIR, 'templates'), diff --git a/openstack_dashboard/test/test_data/exceptions.py b/openstack_dashboard/test/test_data/exceptions.py index ffa0165d7a..5200c2c98e 100644 --- a/openstack_dashboard/test/test_data/exceptions.py +++ b/openstack_dashboard/test/test_data/exceptions.py @@ -19,7 +19,7 @@ from neutronclient.common import exceptions as neutron_exceptions from novaclient import exceptions as nova_exceptions from swiftclient import client as swift_exceptions -from openstack_dashboard.test.test_data.utils import TestDataContainer # noqa +from openstack_dashboard.test.test_data import utils def create_stubbed_exception(cls, status_code=500): @@ -43,7 +43,7 @@ def create_stubbed_exception(cls, status_code=500): def data(TEST): - TEST.exceptions = TestDataContainer() + TEST.exceptions = utils.TestDataContainer() unauth = keystone_exceptions.Unauthorized TEST.exceptions.keystone_unauthorized = create_stubbed_exception(unauth) diff --git a/openstack_dashboard/usage/tables.py b/openstack_dashboard/usage/tables.py index f205c5136f..baab5a6c1c 100644 --- a/openstack_dashboard/usage/tables.py +++ b/openstack_dashboard/usage/tables.py @@ -4,7 +4,7 @@ from django.template.defaultfilters import timesince # noqa from django.utils.translation import ugettext_lazy as _ # noqa from horizon import tables -from horizon.templatetags.sizeformat import mbformat # noqa +from horizon.templatetags import sizeformat class CSVSummary(tables.LinkAction): @@ -21,7 +21,7 @@ class BaseUsageTable(tables.DataTable): disk = tables.Column('local_gb', verbose_name=_("Disk")) memory = tables.Column('memory_mb', verbose_name=_("RAM"), - filters=(mbformat,), + filters=(sizeformat.mbformat,), attrs={"data-type": "size"}) hours = tables.Column('vcpu_hours', verbose_name=_("VCPU Hours"), filters=(lambda v: floatformat(v, 2),)) diff --git a/openstack_dashboard/usage/views.py b/openstack_dashboard/usage/views.py index 630fb34566..72a895700b 100644 --- a/openstack_dashboard/usage/views.py +++ b/openstack_dashboard/usage/views.py @@ -1,7 +1,7 @@ import logging from horizon import tables -from openstack_dashboard.usage.base import BaseUsage # noqa +from openstack_dashboard.usage import base LOG = logging.getLogger(__name__) @@ -13,7 +13,7 @@ class UsageView(tables.DataTableView): def __init__(self, *args, **kwargs): super(UsageView, self).__init__(*args, **kwargs) - if not issubclass(self.usage_class, BaseUsage): + if not issubclass(self.usage_class, base.BaseUsage): raise AttributeError("You must specify a usage_class attribute " "which is a subclass of BaseUsage.") diff --git a/openstack_dashboard/views.py b/openstack_dashboard/views.py index 176f3e9186..f595df859d 100644 --- a/openstack_dashboard/views.py +++ b/openstack_dashboard/views.py @@ -19,7 +19,7 @@ from django.views.decorators import vary import horizon -from openstack_auth.views import Login # noqa +from openstack_auth import views def get_user_home(user): @@ -32,7 +32,7 @@ def get_user_home(user): def splash(request): if request.user.is_authenticated(): return shortcuts.redirect(get_user_home(request.user)) - form = Login(request) + form = views.Login(request) request.session.clear() request.session.set_test_cookie() return shortcuts.render(request, 'splash.html', {'form': form})