add filtered_change_view with altered changelist breadcrumb
diff --git a/xos/hpc/admin.py b/xos/hpc/admin.py
index 7d50fe9..4555ece 100644
--- a/xos/hpc/admin.py
+++ b/xos/hpc/admin.py
@@ -52,6 +52,12 @@
else:
return "/admin/hpc/hpcservice/"
+ def add_extra_context(self, request, extra_context):
+ super(HPCAdmin, self).add_extra_context(request, extra_context)
+
+ if getattr(request,"hpcService",None) is not None:
+ extra_context["custom_changelist_breadcrumb_url"] = "/admin/hpc/%s/%s/filteredlist/" % (self.model._meta.model_name, str(request.hpcService.id))
+
"""
One approach to filtering the HPC Admin views by HPCService. Encode
the HPCService into the URL for the changelist view. Then we could do our
@@ -71,7 +77,8 @@
urls = super(HPCAdmin, self).get_urls()
info = self.model._meta.app_label, self.model._meta.model_name
my_urls = [
- url(r'^(.+)/filteredlist/$', wrap(self.filtered_changelist_view), name="%s_%s_filteredchangelist" % info)
+ url(r'^(.+)/filteredlist/$', wrap(self.filtered_changelist_view), name="%s_%s_filteredchangelist" % info),
+ url(r'^(.+)/(.+)/$', wrap(self.filtered_change_view), name='%s_%s_filteredchange' % info),
]
return my_urls + urls
@@ -79,6 +86,10 @@
request.hpcService = HpcService.objects.get(id=hpcServiceId)
return self.changelist_view(request, extra_context)
+ def filtered_change_view(self, request, hpcServiceId, object_id, extra_context=None):
+ request.hpcService = HpcService.objects.get(id=hpcServiceId)
+ return self.change_view(request, object_id, extra_context)
+
def get_queryset(self, request):
qs = self.model.objects.all()
if (getattr(request,"hpcService",None) is not None) and (hasattr(self.model, "filter_by_hpcService")):