cleanup controller links in admin.py
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index f4a78a3..296098f 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -769,14 +769,6 @@
(None, {'fields': fieldList, 'classes':['suit-tab suit-tab-general']}),
#('Deployment Networks', {'fields': ['deployments'], 'classes':['suit-tab suit-tab-deployments']}),
]
- suit_form_tabs =(('general', 'Site Details'),
- ('users','Users'),
- ('siteprivileges','Privileges'),
- ('deployments','Deployments'),
- ('slices','Slices'),
- #('nodes','Nodes'),
- ('tags','Tags'),
- )
readonly_fields = ['backend_status_text', 'accountLink']
user_readonly_fields = ['name', 'deployments','site_url', 'enabled', 'is_public', 'login_base', 'accountLink']
@@ -785,8 +777,26 @@
list_display_links = ('backend_status_icon', 'name', )
filter_horizontal = ('deployments',)
inlines = [SliceInline,UserInline,TagInline, SitePrivilegeInline, SiteDeploymentInline]
+ admin_inlines = [ControllerSite]
search_fields = ['name']
+ @property
+ def suit_form_tabs(self):
+ tabs = [('general', 'Site Details'),
+ ('users','Users'),
+ ('siteprivileges','Privileges'),
+ ('deployments','Deployments'),
+ ('slices','Slices'),
+ #('nodes','Nodes'),
+ ('tags','Tags'),
+ ]
+
+ request=getattr(_thread_locals, "request", None)
+ if request and request.user.is_admin:
+ tabs.append( ('admin-only', 'Admin-Only') )
+
+ return tabs
+
def queryset(self, request):
return Site.select_by_user(request.user)
@@ -892,7 +902,7 @@
verbose_name_plural = "Controller Slices"
suit_classes = 'suit-tab suit-tab-admin-only'
fields = ['backend_status_icon', 'controller', 'tenant_id']
- readonly_fields = ('backend_status_icon', )
+ readonly_fields = ('backend_status_icon', 'controller' )
class SliceAdmin(PlanetStackBaseAdmin):
form = SliceForm
@@ -1191,6 +1201,14 @@
suit_classes = 'suit-tab suit-tab-dashboards'
fields = ['user', 'dashboardView', 'order']
+class ControllerUserInline(PlStackTabularInline):
+ model = ControllerUser
+ extra = 0
+ suit_classes = 'suit-tab suit-tab-admin-only'
+ fields = ['controller', 'user', 'kuser_id']
+ readonly_fields=['controller']
+
+
class UserAdmin(PermissionCheckingAdminMixin, UserAdmin):
# Note: Make sure PermissionCheckingAdminMixin is listed before
# admin.ModelAdmin in the class declaration.
@@ -1208,7 +1226,7 @@
list_display = ('email', 'firstname', 'lastname', 'site', 'last_login')
list_filter = ('site',)
inlines = [SlicePrivilegeInline,SitePrivilegeInline,UserDashboardViewInline]
-
+ admin_inlines = [ControllerUserInline]
fieldListLoginDetails = ['backend_status_text', 'email','site','password','is_active','is_readonly','is_admin','public_key']
fieldListContactInfo = ['firstname','lastname','phone','timezone']
@@ -1236,12 +1254,17 @@
if getattr(_thread_locals, "obj", None) is None:
return []
else:
- return (('general','Login Details'),
+ tabs = [('general','Login Details'),
('contact','Contact Information'),
('sliceprivileges','Slice Privileges'),
('siteprivileges','Site Privileges'),
- ('controllerprivileges','Controller Privileges'),
- ('dashboards','Dashboard Views'))
+ ('dashboards','Dashboard Views')]
+
+ request=getattr(_thread_locals, "request", None)
+ if request and request.user.is_admin:
+ tabs.append( ('admin-only', 'Admin-Only') )
+
+ return tabs
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'site':
diff --git a/planetstack/core/dashboard/views/view_common.py b/planetstack/core/dashboard/views/view_common.py
index bccd7d2..9d979e6 100644
--- a/planetstack/core/dashboard/views/view_common.py
+++ b/planetstack/core/dashboard/views/view_common.py
@@ -73,7 +73,7 @@
for sliver in slice.slivers.all():
#sites_used['deploymentSites'] = sliver.node.deployment.name
# sites_used[sliver.image.name] = sliver.image.name
- sites_used[sliver.node.site_deployment.site.name] = 1 #sliver.numberCores
+ sites_used[sliver.node.site_deployment.site] = 1 #sliver.numberCores
sliceid = Slice.objects.get(id=entry.slice.id).id
try:
sliverList = Sliver.objects.filter(slice=entry.slice.id)
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 881468a..4b42815 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -282,9 +282,9 @@
objects = ControllerLinkManager()
deleted_objects = ControllerLinkDeletionManager()
- site = models.ForeignKey(Site,related_name='sitedeployment')
- deployment = models.ForeignKey(Deployment,related_name='sitedeployment')
- controller = models.ForeignKey(Controller, null=True, blank=True, related_name='sitedeployment')
+ site = models.ForeignKey(Site,related_name='sitedeployments')
+ deployment = models.ForeignKey(Deployment,related_name='sitedeployments')
+ controller = models.ForeignKey(Controller, null=True, blank=True, related_name='sitedeployments')
availability_zone = models.CharField(max_length=200, null=True, blank=True, help_text="OpenStack availability zone")
def __unicode__(self): return u'%s %s' % (self.deployment, self.site)