Adjusting admin GUI/inlines, fixed slice modification when no openstack environment is setup
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index c9bba2c..741271c 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -59,6 +59,14 @@
model = Node
extra = 0
+class SitePrivilegeInline(admin.TabularInline):
+ model = SitePrivilege
+ extra = 0
+
+class SliceMembershipInline(admin.TabularInline):
+ model = SliceMembership
+ extra = 0
+
class PlainTextWidget(forms.HiddenInput):
input_type = 'hidden'
@@ -124,7 +132,7 @@
class DeploymentNetworkAdmin(PlanetStackBaseAdmin):
form = DeploymentNetworkAdminForm
- inlines = [NodeInline,]
+ inlines = [NodeInline,SliverInline]
def get_formsets(self, request, obj=None):
for inline in self.get_inline_instances(request, obj):
@@ -146,7 +154,7 @@
]
list_display = ('name', 'login_base','site_url', 'enabled')
filter_horizontal = ('deployments',)
- inlines = [NodeInline, UserInline]
+ inlines = [NodeInline, UserInline, SitePrivilegeInline]
search_fields = ['name']
def queryset(self, request):
@@ -416,15 +424,16 @@
# that reference specific fields on auth.User.
list_display = ('email', 'site', 'firstname', 'lastname', 'is_admin', 'last_login')
list_filter = ('site',)
+ inlines = [SitePrivilegeInline, SliceMembershipInline]
fieldsets = (
- (None, {'fields': ('email', 'password')}),
- ('Personal info', {'fields': ('firstname','lastname','phone', 'is_admin', 'site', 'key')}),
+ (None, {'fields': ('email', 'password', 'site')}),
+ ('Personal info', {'fields': ('firstname','lastname','phone', 'key')}),
#('Important dates', {'fields': ('last_login',)}),
)
add_fieldsets = (
(None, {
'classes': ('wide',),
- 'fields': ('email', 'firstname', 'lastname', 'phone', 'site', 'is_admin', 'key','password1', 'password2')}
+ 'fields': ('email', 'firstname', 'lastname', 'phone', 'site', 'key','password1', 'password2')}
),
)
search_fields = ('email',)
@@ -445,14 +454,14 @@
admin.site.unregister(Group)
admin.site.register(Site, SiteAdmin)
-#admin.site.register(SitePrivilege, SitePrivilegeAdmin)
+admin.site.register(SitePrivilege, SitePrivilegeAdmin)
admin.site.register(Slice, SliceAdmin)
-#admin.site.register(SliceMembership, SliceMembershipAdmin)
-#admin.site.register(Subnet, SubnetAdmin)
+admin.site.register(SliceMembership, SliceMembershipAdmin)
+#admin.site.register(Subnet)
admin.site.register(Image, ImageAdmin)
-#admin.site.register(Node, NodeAdmin)
+admin.site.register(Node, NodeAdmin)
admin.site.register(Sliver, SliverAdmin)
admin.site.register(Key, KeyAdmin)
-#admin.site.register(Role, RoleAdmin)
+admin.site.register(Role, RoleAdmin)
admin.site.register(DeploymentNetwork, DeploymentNetworkAdmin)
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index a4eb3a4..2fd9fd3 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -49,11 +49,13 @@
def save(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.driver.add_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
+ if self.os_manager.driver:
+ self.os_manager.driver.add_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
super(SliceMembership, self).save(*args, **kwds)
def delete(self, *args, **kwds):
if not hasattr(self, 'os_manager'):
setattr(self, 'os_manager', OpenStackManager())
- self.os_manager.driver.delete_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
+ if self.os_manager.driver:
+ self.os_manager.driver.delete_user_role(self.user.kuser_id, self.slice.tenant_id, self.role.role_type)
super(SliceMembership, self).delete(*args, **kwds)