
from horizon import tables as horizon_tables

from tuskar_ui import api
from tuskar_ui.infrastructure.history import tables


class IndexView(horizon_tables.DataTableView):
    table_class = tables.HistoryTable
    template_name = "infrastructure/history/index.html"

    def get_data(self):
        plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
        if plan:
            stack = api.heat.Stack.get_by_plan(self.request, plan)
            if stack:
                return stack.events


from horizon import tables as horizon_tables

from tuskar_ui import api
from tuskar_ui.infrastructure.history import tables


class IndexView(horizon_tables.DataTableView):
    table_class = tables.HistoryTable
    template_name = "infrastructure/history/index.html"

    def get_data(self):
        plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
        if plan:
            stack = api.heat.Stack.get_by_plan(self.request, plan)
            if stack:
                return stack.events
        return []

Fix error in History table if stack does not exist
Fix error in History table if stack does not exist

Change-Id: Ic47761ddff23207a30eae0b7b523a996c545b3ba

  
  from horizon import tables as horizon_tables
  
  from tuskar_ui import api
  from tuskar_ui.infrastructure.history import tables
  
  
  class IndexView(horizon_tables.DataTableView):
      table_class = tables.HistoryTable
      template_name = "infrastructure/history/index.html"
  
      def get_data(self):
          plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
          if plan:
              stack = api.heat.Stack.get_by_plan(self.request, plan)
              if stack:
                  return stack.events
+         return []
  
Fix error in History table if stack does not exist
## Code Before:

from horizon import tables as horizon_tables

from tuskar_ui import api
from tuskar_ui.infrastructure.history import tables


class IndexView(horizon_tables.DataTableView):
    table_class = tables.HistoryTable
    template_name = "infrastructure/history/index.html"

    def get_data(self):
        plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
        if plan:
            stack = api.heat.Stack.get_by_plan(self.request, plan)
            if stack:
                return stack.events

## Instruction:
Fix error in History table if stack does not exist
## Code After:

from horizon import tables as horizon_tables

from tuskar_ui import api
from tuskar_ui.infrastructure.history import tables


class IndexView(horizon_tables.DataTableView):
    table_class = tables.HistoryTable
    template_name = "infrastructure/history/index.html"

    def get_data(self):
        plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
        if plan:
            stack = api.heat.Stack.get_by_plan(self.request, plan)
            if stack:
                return stack.events
        return []
