Small code cleanup

This contains mostly small cosmetic changes to make the diff against the
upstream master nicer after the rebase.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
This commit is contained in:
Tomas Sedovic 2013-08-01 15:03:02 +02:00
parent 544cef78a6
commit 3907712767
6 changed files with 19 additions and 38 deletions

3
README
View File

@ -1,3 +0,0 @@
This is a repo for sharing UI elements for the new OpenStack-M work.
This file is largely a test. Feel free to delete it.

View File

@ -38,4 +38,3 @@ assert DynamicChoiceField
# FIXME: TableStep hack adding NumberInput
from horizon.forms.fields import NumberInput

View File

@ -71,10 +71,7 @@ class DynamicTypedChoiceField(DynamicChoiceField, fields.TypedChoiceField):
pass
"""FIXME: TableStep"""
#should be in django 1.5.1 forms.widgets
# FIXME: TableStep
# Should be in django 1.5.1 forms.widgets
class NumberInput(widgets.TextInput):
input_type = 'number'
"""FIXME: TableStep end"""

View File

@ -199,11 +199,10 @@ class Column(html.HTMLElement):
link=None, allowed_data_types=[], hidden=False, attrs=None,
status=False, status_choices=None, display_choices=None,
empty_value=None, filters=None, classes=None, summation=None,
auto=None, truncate=None, link_classes=None, form_widget=None,
form_widget_attributes=None):
"""FIXME: TableStep"""
# form_widget=None, form_widget_attributes=None added in parameters
"""FIXME: TableStep end"""
auto=None, truncate=None, link_classes=None,
# FIXME: Added for TableStep:
form_widget=None, form_widget_attributes=None
):
self.classes = list(classes or getattr(self, "classes", []))
super(Column, self).__init__()
@ -233,10 +232,8 @@ class Column(html.HTMLElement):
self.filters = filters or []
self.truncate = truncate
self.link_classes = link_classes or []
"""FIXME: TableStep"""
self.form_widget = form_widget
self.form_widget_attributes = form_widget_attributes or {}
"""FIXME: TableStep end"""
self.form_widget = form_widget # FIXME: TableStep
self.form_widget_attributes = form_widget_attributes or {} # TableStep
if status_choices:
self.status_choices = status_choices
@ -462,18 +459,18 @@ class Row(html.HTMLElement):
for column in table.columns.values():
if column.auto == "multi_select":
"""FIXME: TableStep code modified"""
# FIXME: TableStep code modified
# multi_select fields in the table must be checked after
# a server action
# TODO remove this ugly code and create proper TableFormWidget
# TODO: remove this ugly code and create proper TableFormWidget
multi_select_values = []
if getattr(table, 'request', False) and \
getattr(table.request, 'POST', False):
if (getattr(table, 'request', False) and
getattr(table.request, 'POST', False)):
multi_select_values = table.request.POST.getlist(
self.table._meta.multi_select_name)
multi_select_values +=\
getattr(table, 'active_multi_select_values', [])
multi_select_values += getattr(table,
'active_multi_select_values', [])
if unicode(table.get_object_id(datum)) in multi_select_values:
multi_select_value = lambda value: True
@ -484,11 +481,10 @@ class Row(html.HTMLElement):
# Convert value to string to avoid accidental type conversion
data = widget.render(self.table._meta.multi_select_name,
unicode(table.get_object_id(datum)))
"""FIXME: TableStep code modified end"""
# FIXME: end of added TableStep code
table._data_cache[column][table.get_object_id(datum)] = data
elif column.auto == "form_widget":
"""FIXME: TableStep whole condition added"""
elif column.auto == "form_widget": # FIXME: Added for TableStep:
widget = column.form_widget
widget_name = "%s__%s__%s" % \
(self.table._meta.multi_select_name,
@ -499,7 +495,6 @@ class Row(html.HTMLElement):
column.get_data(datum),
column.form_widget_attributes)
table._data_cache[column][table.get_object_id(datum)] = data
"""FIXME: TableStep whole condition added end"""
elif column.auto == "actions":
data = table.render_row_actions(datum)
table._data_cache[column][table.get_object_id(datum)] = data
@ -507,7 +502,6 @@ class Row(html.HTMLElement):
data = column.get_data(datum)
cell = Cell(datum, data, column, self)
cells.append((column.name or column.auto, cell))
self.cells = SortedDict(cells)
if self.ajax:
@ -821,11 +815,10 @@ class DataTableOptions(object):
self.actions_column = getattr(options,
'actions_column',
len(self.row_actions) > 0)
"""FIXME: TableStep"""
# FIXME: TableStep
self.multi_select_name = getattr(options,
'multi_select_name',
'object_ids')
"""FIXME: TableStep end"""
self.multi_select = getattr(options,
'multi_select',
len(self.table_actions) > 0)

View File

@ -422,10 +422,9 @@ class Step(object):
extra_context = {"form": self.action,
"step": self}
"""FIXME: TableStep"""
# FIXME: TableStep:
if issubclass(self.__class__, TableStep):
extra_context.update(self.get_context_data(self.workflow.request))
"""FIXME: TableStep end"""
context = template.RequestContext(self.workflow.request, extra_context)
return step_template.render(context)
@ -442,9 +441,7 @@ class Step(object):
"""
self.action.add_error(message)
"""FIXME: TableStep"""
# FIXME: TableStep
class TableStep(Step):
"""
A :class:`~horizon.workflows.Step` class which knows how to deal with
@ -521,7 +518,6 @@ class TableStep(Step):
def has_more_data(self, table):
return False
"""FIXME: TableStep end"""
class WorkflowMetaclass(type):

View File

@ -39,7 +39,6 @@ from openstack_dashboard.api import glance
from openstack_dashboard.api import heat
from openstack_dashboard.api import keystone
from openstack_dashboard.api import lbaas
from openstack_dashboard.api import management
from openstack_dashboard.api import network
from openstack_dashboard.api import neutron
from openstack_dashboard.api import nova