Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenStack Horizon - LinkAction is not passing data to the view

I'm having an issue in one of my data tables - when the table's LinkAction is clicked, it would not pass the data to the corresponding View. I need to have an experience identical to what you get when you choose to update an existing Network record. There, when you click on the "Edit" row action, the corresponding Form is populated with that Network data. In my case, I have a custom dashboard/panel/tab/table. So, when I click on the "Edit" link action within that table row, I do get my Form to show, but it is not passed any data from the row.. Here is my table and action (

class UpdateWorkload(tables.LinkAction): name = "update" verbose_name = _("Edit Workload") url = "update" classes = ("ajax-modal",) icon = "pencil"

class WorkloadsTable(tables.DataTable): name = tables.Column("name", verbose_name=_("Name")) description = tables.Column("description", verbose_name=_("Description")) image = tables.Column("image", verbose_name=_("Image")) flavor = tables.Column("flavor", verbose_name=_("Flavor"))

class Meta:
    name = "workloads_table"
    verbose_name = _("Workloads Table")
    table_actions = (CreateNewWorkload,
    row_actions = (UpdateWorkload, DeleteWorkload)

Here is my update view (

class UpdateView(forms.ModalFormView): form_class = project_forms.UpdateWorkload template_name = 'update_workload.html' context_object_name = 'workload' success_url = reverse_lazy('index')

And here is my form (

class UpdateWorkload(forms.SelfHandlingForm): name = forms.CharField(max_length="255", label=_("Workload Name")) description = forms.CharField(widget=forms.Textarea, label=_("Description"), required=False) image_choices = [] images = forms.ChoiceField(label=_("Images"), choices=image_choices) flavor_choices = [] flavors = forms.ChoiceField(label=_("Flavors"), choices=flavor_choices)

def handle(self, request, data):
        # here we will need to call update on and pass the id
        workload = 0
        msg = _('Workload was successfully updated.')
        messages.success(request, msg)
        # return workload
    except Exception:
        msg = _('Failed to update Workload %s')
        redirect = reverse(self.failure_url)
        exceptions.handle(request, msg, redirect=redirect)

What can I do to make this table and view pass the row data to the form?