solve the admin tab issue in a more generic way
diff --git a/xos/core/admin.py b/xos/core/admin.py
index 70df867..b32a281 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -17,6 +17,7 @@
from django.core.urlresolvers import reverse, resolve, NoReverseMatch
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import conditional_escape, format_html
+from django.utils.text import capfirst
from django.forms.utils import flatatt, to_current_timezone
from cgi import escape as html_escape
@@ -192,6 +193,30 @@
else:
return True
+class ServiceAppAdmin (SingletonAdmin):
+ # This is for services to render an 'administration page'. It builds up
+ # a list of all registered admins for the service, and passes them in the
+ # 'registered_admins' member of the template context.
+
+ def change_view(self, request, object_id, extra_context=None):
+ extra_context = extra_context or {}
+
+ admins=[]
+ for model, model_admin in admin.site._registry.items():
+ if model == self.model:
+ continue
+ if model._meta.app_label == self.model._meta.app_label:
+ info = {"app": model._meta.app_label,
+ "model": model._meta.model_name,
+ "name": capfirst(model._meta.verbose_name_plural),
+ "url": reverse('admin:%s_%s_changelist' % (model._meta.app_label, model._meta.model_name), current_app=model._meta.app_label) }
+ admins.append(info)
+
+ extra_context["registered_admins"] = admins
+
+ return super(ServiceAppAdmin, self).change_view(request=request, object_id=object_id,
+ extra_context=extra_context)
+
class XOSTabularInline(admin.TabularInline):
def __init__(self, *args, **kwargs):
super(XOSTabularInline, self).__init__(*args, **kwargs)
diff --git a/xos/hpc/admin.py b/xos/hpc/admin.py
index e1176f1..b247deb 100644
--- a/xos/hpc/admin.py
+++ b/xos/hpc/admin.py
@@ -10,9 +10,9 @@
from django.utils import timezone
from django.contrib.contenttypes import generic
from suit.widgets import LinkedSelect
-from core.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin, XOSTabularInline
-class HpcServiceAdmin(SingletonAdmin):
+class HpcServiceAdmin(ServiceAppAdmin):
model = HpcService
verbose_name = "HPC Service"
verbose_name_plural = "HPC Service"
diff --git a/xos/hpc/templates/hpcadmin.html b/xos/hpc/templates/hpcadmin.html
index 3b17906..5c05020 100644
--- a/xos/hpc/templates/hpcadmin.html
+++ b/xos/hpc/templates/hpcadmin.html
@@ -1,3 +1,12 @@
+<div class = "left-nav">
+<ul>
+{% for admin in registered_admins %}
+ <li><a href="{{ admin.url }}">{{ admin.name }}</a></li>
+{% endfor %}
+</ul>
+</div>
+
+<!--
<ul>
<li><a href="/admin/hpc/originserver/">Origin Servers</a></li>
<li><a href="/admin/hpc/contentprovider/">Content Providers</a></li>
@@ -6,3 +15,4 @@
<li><a href="/admin/hpc/sitemap/">Site Maps</a></li>
<li><a href="/admin/hpc/accessmap/">Access Maps</a></li>
</ul>
+-->
diff --git a/xos/requestrouter/admin.py b/xos/requestrouter/admin.py
index 3722acc..d470b29 100644
--- a/xos/requestrouter/admin.py
+++ b/xos/requestrouter/admin.py
@@ -10,9 +10,9 @@
from django.utils import timezone
from django.contrib.contenttypes import generic
from suit.widgets import LinkedSelect
-from core.admin import SingletonAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin
+from core.admin import ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline, ReadOnlyAwareAdmin
-class RequestRouterServiceAdmin(SingletonAdmin):
+class RequestRouterServiceAdmin(ServiceAppAdmin):
model = RequestRouterService
verbose_name = "Request Router Service"
verbose_name_plural = "Request Router Service"
diff --git a/xos/requestrouter/templates/rradmin.html b/xos/requestrouter/templates/rradmin.html
index fc50dd4..142d87a 100644
--- a/xos/requestrouter/templates/rradmin.html
+++ b/xos/requestrouter/templates/rradmin.html
@@ -1,3 +1,13 @@
+<div class = "left-nav">
+<ul>
+{% for admin in registered_admins %}
+ <li><a href="{{ admin.url }}">{{ admin.name }}</a></li>
+{% endfor %}
+</ul>
+</div>
+
+<!--
<ul>
<li><a href="/admin/requestrouter/servicemap/">Service Maps</a></li>
</ul>
+-->
diff --git a/xos/syndicate_storage/admin.py b/xos/syndicate_storage/admin.py
index 74732d7..fcc06f1 100644
--- a/xos/syndicate_storage/admin.py
+++ b/xos/syndicate_storage/admin.py
@@ -10,11 +10,11 @@
from django.utils import timezone
from django.contrib.contenttypes import generic
from suit.widgets import LinkedSelect
-from core.admin import ReadOnlyAwareAdmin,SingletonAdmin,SliceInline,ServiceAttrAsTabInline,XOSBaseAdmin, XOSTabularInline
+from core.admin import ReadOnlyAwareAdmin,ServiceAppAdmin,SliceInline,ServiceAttrAsTabInline,XOSBaseAdmin, XOSTabularInline
from suit.widgets import LinkedSelect
from django.core.exceptions import ValidationError, ObjectDoesNotExist
-class SyndicateServiceAdmin(SingletonAdmin,ReadOnlyAwareAdmin):
+class SyndicateServiceAdmin(ServiceAppAdmin):
model = SyndicateService
verbose_name = "Syndicate Storage"
verbose_name_plural = "Syndicate Storage"
diff --git a/xos/syndicate_storage/templates/syndicateadmin.html b/xos/syndicate_storage/templates/syndicateadmin.html
index 1e4e859..0c46206 100644
--- a/xos/syndicate_storage/templates/syndicateadmin.html
+++ b/xos/syndicate_storage/templates/syndicateadmin.html
@@ -1,3 +1,13 @@
+<div class = "left-nav">
+<ul>
+{% for admin in registered_admins %}
+ <li><a href="{{ admin.url }}">{{ admin.name }}</a></li>
+{% endfor %}
+</ul>
+</div>
+
+<!--
<ul>
<li><a href="/admin/syndicate_storage/volume/">Volumes</a></li>
</ul>
+-->