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
This commit is contained in:
Tatiana Mazur 2013-08-23 17:26:48 +04:00
parent 71ddcb0025
commit b4fc9b4bc9
25 changed files with 89 additions and 122 deletions

View File

@ -28,7 +28,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from keystoneclient.exceptions import ClientException # 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 exceptions
from horizon import messages from horizon import messages
@ -154,7 +154,8 @@ def keystoneclient(request, admin=False):
# Take care of client connection caching/fetching a new client. # Take care of client connection caching/fetching a new client.
# Admin vs. non-admin clients are cached separately for token matching. # 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 if hasattr(request, cache_attr) and (not user.token.id
or getattr(request, cache_attr).auth_token == user.token.id): or getattr(request, cache_attr).auth_token == user.token.id):
LOG.debug("Using cached client for token: %s" % user.token.id) LOG.debug("Using cached client for token: %s" % user.token.id)

View File

@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
import horizon 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 from openstack_dashboard.dashboards.admin import dashboard
@ -27,5 +27,5 @@ class Domains(horizon.Panel):
slug = 'domains' slug = 'domains'
if IDENTITY_VERSIONS.active >= 3: if keystone.VERSIONS.active >= 3:
dashboard.Admin.register(Domains) dashboard.Admin.register(Domains)

View File

@ -19,7 +19,7 @@ import logging
from django.conf import settings # noqa from django.conf import settings # noqa
from django.utils.translation import ugettext_lazy as _ # 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 messages
from horizon import tables from horizon import tables
@ -66,7 +66,7 @@ class DeleteDomainsAction(tables.DeleteAction):
msg = _('Domain "%s" must be disabled before it can be deleted.') \ msg = _('Domain "%s" must be disabled before it can be deleted.') \
% domain.name % domain.name
messages.error(request, msg) messages.error(request, msg)
raise ClientException(409, msg) raise exceptions.ClientException(409, msg)
else: else:
LOG.info('Deleting domain "%s".' % obj_id) LOG.info('Deleting domain "%s".' % obj_id)
api.keystone.domain_delete(request, obj_id) api.keystone.domain_delete(request, obj_id)

View File

@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
import horizon 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 from openstack_dashboard.dashboards.admin import dashboard
@ -27,5 +27,5 @@ class Groups(horizon.Panel):
slug = 'groups' slug = 'groups'
if IDENTITY_VERSIONS.active >= 3: if keystone.VERSIONS.active >= 3:
dashboard.Admin.register(Groups) dashboard.Admin.register(Groups)

View File

@ -22,49 +22,12 @@ from django.template.defaultfilters import title # noqa
from django.utils.translation import ugettext_lazy as _ # noqa from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables from horizon import tables
from horizon.utils.filters import parse_isotime # noqa from horizon.utils import filters
from horizon.utils.filters import replace_underscores # noqa
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.instances \ from openstack_dashboard.dashboards.project.instances \
import tables as project_tables 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__) LOG = logging.getLogger(__name__)
@ -141,7 +104,7 @@ class AdminInstancesTable(tables.DataTable):
classes=('nowrap-col',), classes=('nowrap-col',),
attrs={'data-type': 'size'}) attrs={'data-type': 'size'})
status = tables.Column("status", status = tables.Column("status",
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Status"), verbose_name=_("Status"),
status=True, status=True,
status_choices=STATUS_CHOICES, status_choices=STATUS_CHOICES,
@ -149,16 +112,16 @@ class AdminInstancesTable(tables.DataTable):
project_tables.STATUS_DISPLAY_CHOICES) project_tables.STATUS_DISPLAY_CHOICES)
task = tables.Column("OS-EXT-STS:task_state", task = tables.Column("OS-EXT-STS:task_state",
verbose_name=_("Task"), verbose_name=_("Task"),
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
status=True, status=True,
status_choices=TASK_STATUS_CHOICES, status_choices=TASK_STATUS_CHOICES,
display_choices=project_tables.TASK_DISPLAY_CHOICES) display_choices=project_tables.TASK_DISPLAY_CHOICES)
state = tables.Column(project_tables.get_power_state, state = tables.Column(project_tables.get_power_state,
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Power State")) verbose_name=_("Power State"))
created = tables.Column("created", created = tables.Column("created",
verbose_name=_("Uptime"), verbose_name=_("Uptime"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
class Meta: class Meta:
name = "instances" name = "instances"

View File

@ -26,7 +26,7 @@ from django.utils import timezone
from mox import IsA # noqa 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 import api
from openstack_dashboard.test import helpers as test from openstack_dashboard.test import helpers as test
@ -69,7 +69,7 @@ class UsageViewTests(test.BaseAdminViewTests):
'<td class="sortable normal_column">%.2f</td>' % '<td class="sortable normal_column">%.2f</td>' %
(usage_obj.vcpus, (usage_obj.vcpus,
usage_obj.disk_gb_hours, usage_obj.disk_gb_hours,
mbformat(usage_obj.memory_mb), sizeformat.mbformat(usage_obj.memory_mb),
usage_obj.vcpu_hours, usage_obj.vcpu_hours,
usage_obj.total_local_gb_usage)) usage_obj.total_local_gb_usage))

View File

@ -18,7 +18,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
import horizon 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 from openstack_dashboard.dashboards.admin import dashboard
@ -26,5 +26,5 @@ class Roles(horizon.Panel):
name = _("Roles") name = _("Roles")
slug = 'roles' slug = 'roles'
if IDENTITY_VERSIONS.active >= 3: if keystone.VERSIONS.active >= 3:
dashboard.Admin.register(Roles) dashboard.Admin.register(Roles)

View File

@ -32,8 +32,7 @@ from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
from horizon.utils import fields from horizon.utils import fields
from horizon.utils.validators import validate_ip_protocol # noqa from horizon.utils import validators as utils_validators
from horizon.utils.validators import validate_port_range # noqa
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.utils import filters from openstack_dashboard.utils import filters
@ -96,7 +95,7 @@ class AddRule(forms.SelfHandlingForm):
label=_('IP Protocol'), required=False, label=_('IP Protocol'), required=False,
help_text=_("Enter an integer value between 0 and 255 " help_text=_("Enter an integer value between 0 and 255 "
"(or -1 which means wildcard)."), "(or -1 which means wildcard)."),
validators=[validate_ip_protocol], validators=[utils_validators.validate_ip_protocol],
widget=forms.TextInput(attrs={ widget=forms.TextInput(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'rule_menu', 'data-switch-on': 'rule_menu',
@ -121,7 +120,8 @@ class AddRule(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'range', 'data-switch-on': 'range',
'data-range-port': _('Port')}), 'data-range-port': _('Port')}),
validators=[validate_port_range]) validators=[
utils_validators.validate_port_range])
from_port = forms.IntegerField(label=_("From Port"), from_port = forms.IntegerField(label=_("From Port"),
required=False, required=False,
@ -131,7 +131,8 @@ class AddRule(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'range', 'data-switch-on': 'range',
'data-range-range': _('From Port')}), 'data-range-range': _('From Port')}),
validators=[validate_port_range]) validators=[
utils_validators.validate_port_range])
to_port = forms.IntegerField(label=_("To Port"), to_port = forms.IntegerField(label=_("To Port"),
required=False, required=False,
@ -141,7 +142,8 @@ class AddRule(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'range', 'data-switch-on': 'range',
'data-range-range': _('To Port')}), 'data-range-range': _('To Port')}),
validators=[validate_port_range]) validators=[
utils_validators.validate_port_range])
icmp_type = forms.IntegerField(label=_("Type"), icmp_type = forms.IntegerField(label=_("Type"),
required=False, required=False,
@ -151,7 +153,8 @@ class AddRule(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'rule_menu', 'data-switch-on': 'rule_menu',
'data-rule_menu-icmp': _('Type')}), 'data-rule_menu-icmp': _('Type')}),
validators=[validate_port_range]) validators=[
utils_validators.validate_port_range])
icmp_code = forms.IntegerField(label=_("Code"), icmp_code = forms.IntegerField(label=_("Code"),
required=False, required=False,
@ -161,7 +164,8 @@ class AddRule(forms.SelfHandlingForm):
'class': 'switched', 'class': 'switched',
'data-switch-on': 'rule_menu', 'data-switch-on': 'rule_menu',
'data-rule_menu-icmp': _('Code')}), 'data-rule_menu-icmp': _('Code')}),
validators=[validate_port_range]) validators=[
utils_validators.validate_port_range])
remote = forms.ChoiceField(label=_('Remote'), remote = forms.ChoiceField(label=_('Remote'),
choices=[('cidr', _('CIDR')), choices=[('cidr', _('CIDR')),

View File

@ -31,9 +31,6 @@ from openstack_dashboard.test import helpers as test
from openstack_dashboard.dashboards.project.access_and_security.\ from openstack_dashboard.dashboards.project.access_and_security.\
security_groups import tables 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') INDEX_URL = reverse('horizon:project:access_and_security:index')

View File

@ -26,13 +26,12 @@ from django.utils.http import urlencode # noqa
from django.utils.translation import string_concat # noqa from django.utils.translation import string_concat # noqa
from django.utils.translation import ugettext_lazy as _ # 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 exceptions
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from horizon.templatetags import sizeformat from horizon.templatetags import sizeformat
from horizon.utils.filters import parse_isotime # noqa from horizon.utils import filters
from horizon.utils.filters import replace_underscores # noqa
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard.dashboards.project.access_and_security.floating_ips \ from openstack_dashboard.dashboards.project.access_and_security.floating_ips \
@ -403,7 +402,7 @@ class SimpleDisassociateIP(tables.Action):
classes = ("btn-danger", "btn-disassociate",) classes = ("btn-danger", "btn-disassociate",)
def allowed(self, request, instance): def allowed(self, request, instance):
if not HORIZON_CONFIG["simple_ip_management"]: if not conf.HORIZON_CONFIG["simple_ip_management"]:
return False return False
return not is_deleting(instance) return not is_deleting(instance)
@ -557,23 +556,23 @@ class InstancesTable(tables.DataTable):
attrs={'data-type': 'size'}) attrs={'data-type': 'size'})
keypair = tables.Column(get_keyname, verbose_name=_("Keypair")) keypair = tables.Column(get_keyname, verbose_name=_("Keypair"))
status = tables.Column("status", status = tables.Column("status",
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Status"), verbose_name=_("Status"),
status=True, status=True,
status_choices=STATUS_CHOICES, status_choices=STATUS_CHOICES,
display_choices=STATUS_DISPLAY_CHOICES) display_choices=STATUS_DISPLAY_CHOICES)
task = tables.Column("OS-EXT-STS:task_state", task = tables.Column("OS-EXT-STS:task_state",
verbose_name=_("Task"), verbose_name=_("Task"),
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
status=True, status=True,
status_choices=TASK_STATUS_CHOICES, status_choices=TASK_STATUS_CHOICES,
display_choices=TASK_DISPLAY_CHOICES) display_choices=TASK_DISPLAY_CHOICES)
state = tables.Column(get_power_state, state = tables.Column(get_power_state,
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Power State")) verbose_name=_("Power State"))
created = tables.Column("created", created = tables.Column("created",
verbose_name=_("Uptime"), verbose_name=_("Uptime"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
class Meta: class Meta:
name = "instances" name = "instances"

View File

@ -21,7 +21,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon.utils import fields from horizon.utils import fields
from horizon.utils.validators import validate_port_range # noqa from horizon.utils import validators
from horizon import workflows from horizon import workflows
from openstack_dashboard import api from openstack_dashboard import api
@ -129,7 +129,7 @@ class AddVipAction(workflows.Action):
protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1, protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1,
help_text=_("Enter an integer value " help_text=_("Enter an integer value "
"between 1 and 65535."), "between 1 and 65535."),
validators=[validate_port_range]) validators=[validators.validate_port_range])
protocol = forms.ChoiceField(label=_("Protocol")) protocol = forms.ChoiceField(label=_("Protocol"))
session_persistence = forms.ChoiceField( session_persistence = forms.ChoiceField(
required=False, initial={}, label=_("Session Persistence")) required=False, initial={}, label=_("Session Persistence"))
@ -265,7 +265,7 @@ class AddMemberAction(workflows.Action):
protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1, protocol_port = forms.IntegerField(label=_("Protocol Port"), min_value=1,
help_text=_("Enter an integer value " help_text=_("Enter an integer value "
"between 1 and 65535."), "between 1 and 65535."),
validators=[validate_port_range]) validators=[validators.validate_port_range])
admin_state_up = forms.BooleanField(label=_("Admin State"), admin_state_up = forms.BooleanField(label=_("Admin State"),
initial=True, required=False) initial=True, required=False)

View File

@ -20,7 +20,7 @@ import urlparse
from django.core.urlresolvers import reverse # noqa from django.core.urlresolvers import reverse # noqa
from django.template.defaultfilters import register # 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__) LOG = logging.getLogger(__name__)
@ -50,7 +50,7 @@ resource_urls = {
'link': 'horizon:project:networks:subnets:detail'}, 'link': 'horizon:project:networks:subnets:detail'},
"OS::Swift::Container": { "OS::Swift::Container": {
'link': 'horizon:project:containers:index', 'link': 'horizon:project:containers:index',
'format_pattern': '%s' + FOLDER_DELIMITER}, 'format_pattern': '%s' + swift.FOLDER_DELIMITER},
} }

View File

@ -1,14 +1,15 @@
from django.template.defaultfilters import title # noqa from django.template.defaultfilters import title # noqa
from django.template.loader import render_to_string # 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): 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: if stack.stack_status_reason:
stack.stack_status_reason = title( stack.stack_status_reason = title(
replace_underscores(stack.stack_status_reason) filters.replace_underscores(stack.stack_status_reason)
) )
context = {} context = {}
context['stack'] = stack context['stack'] = stack
@ -19,11 +20,11 @@ def stack_info(stack, stack_image):
def resource_info(resource): def resource_info(resource):
resource.resource_status_desc = title( resource.resource_status_desc = title(
replace_underscores(resource.resource_status) filters.replace_underscores(resource.resource_status)
) )
if resource.resource_status_reason: if resource.resource_status_reason:
resource.resource_status_reason = title( resource.resource_status_reason = title(
replace_underscores(resource.resource_status_reason) filters.replace_underscores(resource.resource_status_reason)
) )
context = {} context = {}
context['resource'] = resource context['resource'] = resource

View File

@ -21,8 +21,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import messages from horizon import messages
from horizon import tables from horizon import tables
from horizon.utils.filters import parse_isotime # noqa from horizon.utils import filters
from horizon.utils.filters import replace_underscores # noqa
from heatclient import exc from heatclient import exc
@ -77,12 +76,12 @@ class StacksTable(tables.DataTable):
link="horizon:project:stacks:detail",) link="horizon:project:stacks:detail",)
created = tables.Column("creation_time", created = tables.Column("creation_time",
verbose_name=_("Created"), verbose_name=_("Created"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
updated = tables.Column("updated_time", updated = tables.Column("updated_time",
verbose_name=_("Updated"), verbose_name=_("Updated"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
status = tables.Column("stack_status", status = tables.Column("stack_status",
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Status"), verbose_name=_("Status"),
status=True, status=True,
status_choices=STATUS_CHOICES) status_choices=STATUS_CHOICES)
@ -109,9 +108,9 @@ class EventsTable(tables.DataTable):
link=mappings.resource_to_url) link=mappings.resource_to_url)
timestamp = tables.Column('event_time', timestamp = tables.Column('event_time',
verbose_name=_("Time Since Event"), verbose_name=_("Time Since Event"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
status = tables.Column("resource_status", status = tables.Column("resource_status",
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Status"),) verbose_name=_("Status"),)
statusreason = tables.Column("resource_status_reason", statusreason = tables.Column("resource_status_reason",
@ -155,9 +154,9 @@ class ResourcesTable(tables.DataTable):
verbose_name=_("Stack Resource Type"),) verbose_name=_("Stack Resource Type"),)
updated_time = tables.Column('updated_time', updated_time = tables.Column('updated_time',
verbose_name=_("Date Updated"), verbose_name=_("Date Updated"),
filters=(parse_isotime, timesince)) filters=(filters.parse_isotime, timesince))
status = tables.Column("resource_status", status = tables.Column("resource_status",
filters=(title, replace_underscores), filters=(title, filters.replace_underscores),
verbose_name=_("Status"), verbose_name=_("Status"),
status=True, status=True,
status_choices=STATUS_CHOICES) status_choices=STATUS_CHOICES)

View File

@ -16,8 +16,8 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import exceptions from horizon import exceptions
from horizon import forms from horizon import forms
from horizon import messages from horizon import messages
from horizon.utils.fields import SelectWidget # noqa from horizon.utils import fields
from horizon.utils.functions import bytes_to_gigabytes # noqa from horizon.utils import functions
from horizon.utils.memoized import memoized # noqa from horizon.utils.memoized import memoized # noqa
from openstack_dashboard import api from openstack_dashboard import api
@ -38,7 +38,7 @@ class CreateForm(forms.SelfHandlingForm):
volume_source_type = forms.ChoiceField(label=_("Volume Source"), volume_source_type = forms.ChoiceField(label=_("Volume Source"),
required=False) required=False)
snapshot_source = forms.ChoiceField(label=_("Use snapshot as a source"), snapshot_source = forms.ChoiceField(label=_("Use snapshot as a source"),
widget=SelectWidget( widget=fields.SelectWidget(
attrs={'class': 'snapshot-selector'}, attrs={'class': 'snapshot-selector'},
data_attrs=('size', 'display_name'), data_attrs=('size', 'display_name'),
transform=lambda x: transform=lambda x:
@ -46,7 +46,7 @@ class CreateForm(forms.SelfHandlingForm):
x.size))), x.size))),
required=False) required=False)
image_source = forms.ChoiceField(label=_("Use image as a source"), image_source = forms.ChoiceField(label=_("Use image as a source"),
widget=SelectWidget( widget=fields.SelectWidget(
attrs={'class': 'image-selector'}, attrs={'class': 'image-selector'},
data_attrs=('size', 'name'), data_attrs=('size', 'name'),
transform=lambda x: transform=lambda x:
@ -109,7 +109,8 @@ class CreateForm(forms.SelfHandlingForm):
request.GET["image_id"]) request.GET["image_id"])
image.bytes = image.size image.bytes = image.size
self.fields['name'].initial = image.name 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['image_source'].choices = ((image.id, image),)
self.fields['size'].help_text = _('Volume size must be equal ' self.fields['size'].help_text = _('Volume size must be equal '
'to or greater than the image size (%s)' 'to or greater than the image size (%s)'
@ -143,7 +144,7 @@ class CreateForm(forms.SelfHandlingForm):
choices = [('', _("Choose an image"))] choices = [('', _("Choose an image"))]
for image in images: for image in images:
image.bytes = image.size image.bytes = image.size
image.size = bytes_to_gigabytes(image.bytes) image.size = functions.bytes_to_gigabytes(image.bytes)
choices.append((image.id, image)) choices.append((image.id, image))
self.fields['image_source'].choices = choices self.fields['image_source'].choices = choices
else: else:
@ -189,7 +190,7 @@ class CreateForm(forms.SelfHandlingForm):
image = self.get_image(request, image = self.get_image(request,
data["image_source"]) data["image_source"])
image_id = image.id image_id = image.id
image_size = bytes_to_gigabytes(image.size) image_size = functions.bytes_to_gigabytes(image.size)
if (data['size'] < image_size): if (data['size'] < image_size):
error_message = _('The volume size cannot be less than ' error_message = _('The volume size cannot be less than '
'the image size (%s)' % 'the image size (%s)' %

View File

@ -17,8 +17,8 @@
from django.conf.urls.defaults import patterns # noqa from django.conf.urls.defaults import patterns # noqa
from django.conf.urls.defaults import url # 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('', urlpatterns = patterns('',
url(r'^$', PasswordView.as_view(), name='index')) url(r'^$', views.PasswordView.as_view(), name='index'))

View File

@ -17,10 +17,12 @@
from horizon import forms from horizon import forms
from django.core.urlresolvers import reverse_lazy # noqa 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): class PasswordView(forms.ModalFormView):
form_class = PasswordForm form_class = pass_forms.PasswordForm
template_name = 'settings/password/change.html' template_name = 'settings/password/change.html'
success_url = reverse_lazy('logout') success_url = reverse_lazy('logout')

View File

@ -17,8 +17,8 @@
from django.conf.urls.defaults import patterns # noqa from django.conf.urls.defaults import patterns # noqa
from django.conf.urls.defaults import url # 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('', urlpatterns = patterns('',
url(r'^$', UserSettingsView.as_view(), name='index')) url(r'^$', views.UserSettingsView.as_view(), name='index'))

View File

@ -17,11 +17,11 @@
from django.conf import settings # noqa from django.conf import settings # noqa
from horizon import forms 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): class UserSettingsView(forms.ModalFormView):
form_class = UserSettingsForm form_class = user_forms.UserSettingsForm
template_name = 'settings/user/settings.html' template_name = 'settings/user/settings.html'
def get_initial(self): def get_initial(self):

View File

@ -49,7 +49,7 @@ from horizon.test import helpers as horizon_helpers
from openstack_dashboard import api from openstack_dashboard import api
from openstack_dashboard import context_processors 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. # Makes output of failing mox tests much easier to read.
@ -115,7 +115,7 @@ class TestCase(horizon_helpers.TestCase):
* Several handy additional assertion methods. * Several handy additional assertion methods.
""" """
def setUp(self): def setUp(self):
load_test_data(self) test_utils.load_test_data(self)
self.mox = mox.Mox() self.mox = mox.Mox()
self.factory = RequestFactoryWithMessages() self.factory = RequestFactoryWithMessages()
self.context = {'authorized_tenants': self.tenants.list()} self.context = {'authorized_tenants': self.tenants.list()}
@ -344,7 +344,7 @@ class SeleniumTestCase(horizon_helpers.SeleniumTestCase):
def setUp(self): def setUp(self):
super(SeleniumTestCase, self).setUp() super(SeleniumTestCase, self).setUp()
load_test_data(self) test_utils.load_test_data(self)
self.mox = mox.Mox() self.mox = mox.Mox()
self._real_get_user = utils.get_user self._real_get_user = utils.get_user

View File

@ -3,7 +3,7 @@ import os
from django.utils.translation import ugettext_lazy as _ # noqa from django.utils.translation import ugettext_lazy as _ # noqa
from horizon.test.settings import * # 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 from openstack_dashboard import exceptions
@ -11,8 +11,8 @@ from openstack_dashboard import exceptions
TEST_DIR = os.path.dirname(os.path.abspath(__file__)) TEST_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, "..")) ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
SECRET_KEY = generate_or_read_from_file(os.path.join(TEST_DIR, SECRET_KEY = secret_key.generate_or_read_from_file(
'.secret_key_store')) os.path.join(TEST_DIR, '.secret_key_store'))
ROOT_URLCONF = 'openstack_dashboard.urls' ROOT_URLCONF = 'openstack_dashboard.urls'
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
os.path.join(TEST_DIR, 'templates'), os.path.join(TEST_DIR, 'templates'),

View File

@ -19,7 +19,7 @@ from neutronclient.common import exceptions as neutron_exceptions
from novaclient import exceptions as nova_exceptions from novaclient import exceptions as nova_exceptions
from swiftclient import client as swift_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): def create_stubbed_exception(cls, status_code=500):
@ -43,7 +43,7 @@ def create_stubbed_exception(cls, status_code=500):
def data(TEST): def data(TEST):
TEST.exceptions = TestDataContainer() TEST.exceptions = utils.TestDataContainer()
unauth = keystone_exceptions.Unauthorized unauth = keystone_exceptions.Unauthorized
TEST.exceptions.keystone_unauthorized = create_stubbed_exception(unauth) TEST.exceptions.keystone_unauthorized = create_stubbed_exception(unauth)

View File

@ -4,7 +4,7 @@ from django.template.defaultfilters import timesince # noqa
from django.utils.translation import ugettext_lazy as _ # noqa from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables from horizon import tables
from horizon.templatetags.sizeformat import mbformat # noqa from horizon.templatetags import sizeformat
class CSVSummary(tables.LinkAction): class CSVSummary(tables.LinkAction):
@ -21,7 +21,7 @@ class BaseUsageTable(tables.DataTable):
disk = tables.Column('local_gb', verbose_name=_("Disk")) disk = tables.Column('local_gb', verbose_name=_("Disk"))
memory = tables.Column('memory_mb', memory = tables.Column('memory_mb',
verbose_name=_("RAM"), verbose_name=_("RAM"),
filters=(mbformat,), filters=(sizeformat.mbformat,),
attrs={"data-type": "size"}) attrs={"data-type": "size"})
hours = tables.Column('vcpu_hours', verbose_name=_("VCPU Hours"), hours = tables.Column('vcpu_hours', verbose_name=_("VCPU Hours"),
filters=(lambda v: floatformat(v, 2),)) filters=(lambda v: floatformat(v, 2),))

View File

@ -1,7 +1,7 @@
import logging import logging
from horizon import tables from horizon import tables
from openstack_dashboard.usage.base import BaseUsage # noqa from openstack_dashboard.usage import base
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -13,7 +13,7 @@ class UsageView(tables.DataTableView):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(UsageView, self).__init__(*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 " raise AttributeError("You must specify a usage_class attribute "
"which is a subclass of BaseUsage.") "which is a subclass of BaseUsage.")

View File

@ -19,7 +19,7 @@ from django.views.decorators import vary
import horizon import horizon
from openstack_auth.views import Login # noqa from openstack_auth import views
def get_user_home(user): def get_user_home(user):
@ -32,7 +32,7 @@ def get_user_home(user):
def splash(request): def splash(request):
if request.user.is_authenticated(): if request.user.is_authenticated():
return shortcuts.redirect(get_user_home(request.user)) return shortcuts.redirect(get_user_home(request.user))
form = Login(request) form = views.Login(request)
request.session.clear() request.session.clear()
request.session.set_test_cookie() request.session.set_test_cookie()
return shortcuts.render(request, 'splash.html', {'form': form}) return shortcuts.render(request, 'splash.html', {'form': form})