add nodes tab to site admin
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index ea86f4b..e187f68 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -770,6 +770,12 @@
('serviceattrs','Additional Attributes'),
)
+class SiteNodeInline(PlStackTabularInline):
+ model = Node
+ fields = ['name', 'site_deployment']
+ extra = 0
+ suit_classes = 'suit-tab suit-tab-nodes'
+
class SiteAdmin(PlanetStackBaseAdmin):
fieldList = ['backend_status_text', 'name', 'site_url', 'enabled', 'is_public', 'login_base', 'accountLink','location']
fieldsets = [
@@ -783,7 +789,7 @@
list_display = ('backend_status_icon', 'name', 'login_base','site_url', 'enabled')
list_display_links = ('backend_status_icon', 'name', )
filter_horizontal = ('deployments',)
- inlines = [SliceInline,UserInline,TagInline, SitePrivilegeInline, SiteDeploymentInline]
+ inlines = [SliceInline,UserInline,TagInline, SitePrivilegeInline, SiteDeploymentInline, SiteNodeInline]
admin_inlines = [ControllerSiteInline]
search_fields = ['name']
@@ -794,7 +800,7 @@
('siteprivileges','Privileges'),
('deployments','Deployments'),
('slices','Slices'),
- #('nodes','Nodes'),
+ ('nodes','Nodes'),
]
request=getattr(_thread_locals, "request", None)
diff --git a/planetstack/core/models/node.py b/planetstack/core/models/node.py
index 0884ec1..94f93a5 100644
--- a/planetstack/core/models/node.py
+++ b/planetstack/core/models/node.py
@@ -1,7 +1,7 @@
import os
from django.db import models
from core.models import PlCoreBase
-from core.models import SiteDeployment
+from core.models import Site, SiteDeployment
from core.models import Tag
from django.contrib.contenttypes import generic
@@ -10,7 +10,13 @@
class Node(PlCoreBase):
name = models.CharField(max_length=200, unique=True, help_text="Name of the Node")
site_deployment = models.ForeignKey(SiteDeployment, related_name='nodes')
+ site = models.ForeignKey(Site, null=True, blank=True, related_name='nodes')
tags = generic.GenericRelation(Tag)
def __unicode__(self): return u'%s' % (self.name)
+ def save(self, *args, **kwds):
+ if self.site is None and self.site_deployment is not None:
+ self.site = self.site_deployment.site
+
+ super(Node, self).save(*args, **kwds)