Created
January 22, 2015 19:43
-
-
Save eugene-goldberg/4021a1a117ceaa313f47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
views.py: | |
class UpdateView(forms.ModalFormView): | |
form_class = project_forms.UpdateWorkload | |
template_name = 'update_workload.html' | |
context_object_name = 'workload' | |
success_url = reverse_lazy('index') | |
def get_context_data(self, **kwargs): | |
context = super(UpdateView, self).get_context_data(**kwargs) | |
context["instance_id"] = self.kwargs['instance_id'] | |
return context | |
@memoized.memoized_method | |
def _get_object(self, *args, **kwargs): | |
workload_id = self.kwargs['id'] | |
try: | |
print workload_id | |
except Exception: | |
redirect = self.success_url | |
msg = _('Unable to retrieve Workload.') | |
exceptions.handle(self.request, msg, redirect=redirect) | |
urls.py: | |
WORKLOADS = r'(?P<instance_id>[^/]+)/%s$' | |
urlpatterns = patterns('', | |
url(r'^create/$', views.CreateView.as_view(), name='create'), | |
url(WORKLOADS % 'update', views.UpdateView.as_view(), name='update'), | |
url(r'^$', views.IndexView.as_view(), name='index'), | |
) | |
tables.py: | |
class UpdateWorkload(tables.LinkAction): | |
name = "update" | |
verbose_name = _("Edit Workload") | |
url = "horizon:mydashboard:workloads_panel:update" | |
classes = ("ajax-modal",) | |
icon = "pencil" | |
def get_link_url(self, datum): | |
instance_id = self.table.get_object_id(datum) | |
return urlresolvers.reverse(self.url, args=[instance_id]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment