
from django.utils.translation import ugettext_lazy as _

from horizon import tables


class ResourceTypesTable(tables.DataTable):
    class ResourceColumn(tables.Column):
        def get_raw_data(self, datum):
            attr_list = ['implementation', 'component', 'resource']
            info_list = datum.resource_type.split('::')
            info_list[0] = info_list[0].replace("OS", "OpenStack")
            if info_list[0] == "AWS":
                info_list[0] = _("AWS compatible")
            info_dict = dict(zip(attr_list, info_list))
            return info_dict[self.transform]

    name = tables.Column("resource_type",
                         verbose_name=_("Type"),
                         link="horizon:project:stacks.resource_types:details",)
    implementation = ResourceColumn("implementation",
                                    verbose_name=_("Implementation"),)
    component = ResourceColumn("component",
                               verbose_name=_("Component"),)
    resource = ResourceColumn("resource",
                              verbose_name=_("Resource"),)

    def get_object_id(self, resource):
        return resource.resource_type

    class Meta(object):
        name = "resource_types"
        verbose_name = _("Resource Types")
        table_actions = (tables.FilterAction,)
        multi_select = False


from django.utils.translation import ugettext_lazy as _

from horizon import tables


class ResourceTypesTable(tables.DataTable):
    name = tables.Column("resource_type",
                         verbose_name=_("Type"),
                         link="horizon:project:stacks.resource_types:details",)

    def get_object_id(self, resource):
        return resource.resource_type

    class Meta(object):
        name = "resource_types"
        verbose_name = _("Resource Types")
        table_actions = (tables.FilterAction,)
        multi_select = False

Remove Orchestration Resource Types names restriction
Remove Orchestration Resource Types names restriction

The additional columns "Implementation", "Component" and "Resource"
are representative for a limited resource type group only. Resource
type name can have less or more than three words and Heat even allows
to specify a URL as a resource type. Horizon should not use these
columns at all: "Type" column and filter will do just the same trick.

Change-Id: I38a671490b90122e2d75e6aa11d3de0fa12817c9
Closes-Bug: #1614000

  
  from django.utils.translation import ugettext_lazy as _
  
  from horizon import tables
  
  
  class ResourceTypesTable(tables.DataTable):
-     class ResourceColumn(tables.Column):
-         def get_raw_data(self, datum):
-             attr_list = ['implementation', 'component', 'resource']
-             info_list = datum.resource_type.split('::')
-             info_list[0] = info_list[0].replace("OS", "OpenStack")
-             if info_list[0] == "AWS":
-                 info_list[0] = _("AWS compatible")
-             info_dict = dict(zip(attr_list, info_list))
-             return info_dict[self.transform]
- 
      name = tables.Column("resource_type",
                           verbose_name=_("Type"),
                           link="horizon:project:stacks.resource_types:details",)
-     implementation = ResourceColumn("implementation",
-                                     verbose_name=_("Implementation"),)
-     component = ResourceColumn("component",
-                                verbose_name=_("Component"),)
-     resource = ResourceColumn("resource",
-                               verbose_name=_("Resource"),)
  
      def get_object_id(self, resource):
          return resource.resource_type
  
      class Meta(object):
          name = "resource_types"
          verbose_name = _("Resource Types")
          table_actions = (tables.FilterAction,)
          multi_select = False
  
Remove Orchestration Resource Types names restriction
## Code Before:

from django.utils.translation import ugettext_lazy as _

from horizon import tables


class ResourceTypesTable(tables.DataTable):
    class ResourceColumn(tables.Column):
        def get_raw_data(self, datum):
            attr_list = ['implementation', 'component', 'resource']
            info_list = datum.resource_type.split('::')
            info_list[0] = info_list[0].replace("OS", "OpenStack")
            if info_list[0] == "AWS":
                info_list[0] = _("AWS compatible")
            info_dict = dict(zip(attr_list, info_list))
            return info_dict[self.transform]

    name = tables.Column("resource_type",
                         verbose_name=_("Type"),
                         link="horizon:project:stacks.resource_types:details",)
    implementation = ResourceColumn("implementation",
                                    verbose_name=_("Implementation"),)
    component = ResourceColumn("component",
                               verbose_name=_("Component"),)
    resource = ResourceColumn("resource",
                              verbose_name=_("Resource"),)

    def get_object_id(self, resource):
        return resource.resource_type

    class Meta(object):
        name = "resource_types"
        verbose_name = _("Resource Types")
        table_actions = (tables.FilterAction,)
        multi_select = False

## Instruction:
Remove Orchestration Resource Types names restriction
## Code After:

from django.utils.translation import ugettext_lazy as _

from horizon import tables


class ResourceTypesTable(tables.DataTable):
    name = tables.Column("resource_type",
                         verbose_name=_("Type"),
                         link="horizon:project:stacks.resource_types:details",)

    def get_object_id(self, resource):
        return resource.resource_type

    class Meta(object):
        name = "resource_types"
        verbose_name = _("Resource Types")
        table_actions = (tables.FilterAction,)
        multi_select = False
