filteredlist url working
diff --git a/xos/hpc/admin.py b/xos/hpc/admin.py
index 003af86..7d50fe9 100644
--- a/xos/hpc/admin.py
+++ b/xos/hpc/admin.py
@@ -11,8 +11,9 @@
 from django.contrib.contenttypes import generic
 from suit.widgets import LinkedSelect
 from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline
+from functools import update_wrapper
 
-class HpcServiceAdmin(ServiceAppAdmin):
+class HpcServiceAdmin(ReadOnlyAwareAdmin):
     model = HpcService
     verbose_name = "HPC Service"
     verbose_name_plural = "HPC Service"
@@ -22,6 +23,8 @@
     readonly_fields = ('backend_status_text', )
     inlines = [SliceInline,ServiceAttrAsTabInline]
 
+    extracontext_registered_admins = True
+
     user_readonly_fields = ["name", "enabled", "versionNumber", "description"]
 
     suit_form_tabs =(('general', 'HPC Service Details'),
@@ -49,6 +52,39 @@
        else:
            return "/admin/hpc/hpcservice/"
 
+   """
+      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
+      custom filtering in self.filtered_changelist_view.
+
+      Note: also need to deal with the breadcrumb and the add view.
+   """
+
+   def get_urls(self):
+       from django.conf.urls import patterns, url
+

+       def wrap(view):

+            def wrapper(*args, **kwargs):

+                return self.admin_site.admin_view(view)(*args, **kwargs)

+            return update_wrapper(wrapper, view)
+
+       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)
+       ]
+       return my_urls + urls
+
+   def filtered_changelist_view(self, request, hpcServiceId, extra_context=None):
+       request.hpcService = HpcService.objects.get(id=hpcServiceId)
+       return self.changelist_view(request, 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")):
+           qs = self.model.filter_by_hpcService(qs, request.hpcService)
+       return qs
+
 class CDNPrefixInline(XOSTabularInline):
     model = CDNPrefix
     extra = 0
diff --git a/xos/hpc/models.py b/xos/hpc/models.py
index 0d88fdb..e915fbc 100644
--- a/xos/hpc/models.py
+++ b/xos/hpc/models.py
@@ -30,10 +30,10 @@
     def __unicode__(self):  return u'%s' % (self.name)
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(hpcService=hpcService)
+        return qs.filter(hpcService=hpcService)
 
 class ContentProvider(PlCoreBase):
     class Meta:
@@ -59,10 +59,10 @@
         return self.CP_TO_ACCOUNT.get(self.name, self.name)
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(serviceProvider__hpcService=hpcService)
+        return qs.filter(serviceProvider__hpcService=hpcService)
 
 
 class OriginServer(PlCoreBase):
@@ -83,10 +83,10 @@
     def __unicode__(self):  return u'%s' % (self.url)
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(contentProvider__serviceProvider__hpcService=hpcService)
+        return qs.filter(contentProvider__serviceProvider__hpcService=hpcService)
 
 class CDNPrefix(PlCoreBase):
     class Meta:
@@ -103,10 +103,10 @@
     def __unicode__(self):  return u'%s' % (self.prefix)
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(contentProvider__serviceProvider__hpcService=hpcService)
+        return qs.filter(contentProvider__serviceProvider__hpcService=hpcService)
 
 class AccessMap(PlCoreBase):
     class Meta:
@@ -146,10 +146,10 @@
         super(SiteMap, self).save(*args, **kwds)
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(Q(hpcService=hpcService) |
+        return qs.filter(Q(hpcService=hpcService) |
                                   Q(serviceProvider__hpcService=hpcService) |
                                   Q(contentProvider__serviceProvider__hpcService=hpcService) |
                                   Q(cdnPrefix__contentProvider__serviceProvider__hpcService=hpcService))
@@ -170,9 +170,9 @@
     def __unicode__(self): return self.resource_name
 
     @classmethod
-    def select_by_hpcService(cls, hpcService):
+    def filter_by_hpcService(cls, qs, hpcService):
         # This should be overridden by descendant classes that want to perform
         # filtering of visible objects by user.
-        return cls.objects.filter(hpcService=hpcService)
+        return qs.filter(hpcService=hpcService)