Adjustments for initial public launch of OpenCloud
diff --git a/planetstack/core/models/__init__.py b/planetstack/core/models/__init__.py
index b453a14..6926d90 100644
--- a/planetstack/core/models/__init__.py
+++ b/planetstack/core/models/__init__.py
@@ -6,8 +6,8 @@
 from .service import ServiceAttribute
 from .tag import Tag
 from .role import Role
-from .deployment import Deployment
-from .site import Site
+#from .deployment import Deployment
+from .site import Site,Deployment, DeploymentRole, DeploymentPrivilege, SiteDeployments
 from .user import User
 from .serviceclass import ServiceClass
 from .slice import Slice
@@ -19,8 +19,8 @@
 from .slice import SlicePrivilege
 from .site import SiteRole
 from .site import SitePrivilege
-from .deployment import DeploymentRole
-from .deployment import DeploymentPrivilege
+#from .deployment import DeploymentRole
+#from .deployment import DeploymentPrivilege
 from .planetstack import PlanetStackRole
 from .planetstack import PlanetStackPrivilege
 from .slicetag import SliceTag
diff --git a/planetstack/core/models/deployment.py b/planetstack/core/models/deployment.py
index 9a4cbe1..1e5e6dc 100644
--- a/planetstack/core/models/deployment.py
+++ b/planetstack/core/models/deployment.py
@@ -5,8 +5,14 @@
 
 # Create your models here.
 
+class ManyToManyField_NoSyncdb(models.ManyToManyField):
+    def __init__(self, *args, **kwargs):
+        super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs)
+        self.creates_table = False
+
 class Deployment(PlCoreBase):
     name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment")
+#    sites = ManyToManyField_NoSyncdb('Site', through=Site.deployments.through, blank=True)
 
     def __unicode__(self):  return u'%s' % (self.name)
 
@@ -15,7 +21,6 @@
 
     ROLE_CHOICES = (('admin','Admin'),)
     role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-    krole_id = models.CharField(max_length=80, verbose_name="Keystone role id", null=True, blank=True)
 
     def __unicode__(self):  return u'%s' % (self.role)
 
diff --git a/planetstack/core/models/network.py b/planetstack/core/models/network.py
index 63a4191..72e7a5f 100644
--- a/planetstack/core/models/network.py
+++ b/planetstack/core/models/network.py
@@ -1,7 +1,7 @@
 import os
 import socket
 from django.db import models
-from core.models import PlCoreBase, Site, Slice, Sliver, Deployment
+from core.models import PlCoreBase, Site, Slice, Sliver
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 
@@ -26,8 +26,6 @@
 class Network(PlCoreBase):
     name = models.CharField(max_length=32)
     template = models.ForeignKey(NetworkTemplate)
-    deployment = models.ForeignKey(Deployment, related_name="networks", help_text="Deployment this Network belongs to")
-    site = models.ForeignKey(Site, blank=True, null=True, default=None, related_name="networks", help_text="Is this an infrastructure Network at a single Site?")
     subnet = models.CharField(max_length=32, blank=True)
     ports = models.CharField(max_length=1024, blank=True, null=True)
     labels = models.CharField(max_length=1024, blank=True, null=True)
diff --git a/planetstack/core/models/node.py b/planetstack/core/models/node.py
index 0781609..c3c2eab 100644
--- a/planetstack/core/models/node.py
+++ b/planetstack/core/models/node.py
@@ -1,8 +1,7 @@
 import os
 from django.db import models
 from core.models import PlCoreBase
-from core.models import Site
-from core.models import Deployment
+from core.models import Site,Deployment
 from core.models import Tag
 from django.contrib.contenttypes import generic
 
diff --git a/planetstack/core/models/service.py b/planetstack/core/models/service.py
index ffa3531..289c7ff 100644
--- a/planetstack/core/models/service.py
+++ b/planetstack/core/models/service.py
@@ -6,6 +6,7 @@
     enabled = models.BooleanField(default=True)
     name = models.CharField(max_length=30, help_text="Service Name")
     versionNumber = models.CharField(max_length=30, help_text="Version of Service Definition")
+    published = models.BooleanField(default=True)
 
     def __unicode__(self): return u'%s' % (self.name)
 
diff --git a/planetstack/core/models/site.py b/planetstack/core/models/site.py
index 56f9bd0..caf5afb 100644
--- a/planetstack/core/models/site.py
+++ b/planetstack/core/models/site.py
@@ -1,13 +1,15 @@
 import os
 from django.db import models
 from core.models import PlCoreBase
-from core.models import Deployment
+#from core.models import Deployment
 from core.models import Tag
 from django.contrib.contenttypes import generic
 from geoposition.fields import GeopositionField
 
 class Site(PlCoreBase):
-
+    """
+        A logical grouping of Nodes that are co-located at the same geographic location, which also typically corresponds to the Nodes' location in the physical network.
+    """
     tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
     name = models.CharField(max_length=200, help_text="Name for this Site")
     site_url = models.URLField(null=True, blank=True, max_length=512, help_text="Site's Home URL Page")
@@ -19,16 +21,16 @@
     is_public = models.BooleanField(default=True, help_text="Indicates the visibility of this site to other members")
     abbreviated_name = models.CharField(max_length=80)
 
-    deployments = models.ManyToManyField(Deployment, blank=True, related_name='sites')
+    deployments = models.ManyToManyField('Deployment', blank=True)
+    #deployments = models.ManyToManyField('Deployment', through='SiteDeployments', blank=True)
     tags = generic.GenericRelation(Tag)
 
     def __unicode__(self):  return u'%s' % (self.name)
 
 class SiteRole(PlCoreBase):
 
-    ROLE_CHOICES = (('admin','Admin'),('pi','PI'),('tech','Tech'),('billing','Billing'), ('user', 'User'))
+    ROLE_CHOICES = (('admin','Admin'),('pi','PI'),('tech','Tech'),('billing','Billing'))
     role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-    krole_id = models.CharField(max_length=80, verbose_name="Keystone role id", null=True, blank=True)
 
     def __unicode__(self):  return u'%s' % (self.role)
 
@@ -46,4 +48,33 @@
     def delete(self, *args, **kwds):
         super(SitePrivilege, self).delete(*args, **kwds)
 
+class Deployment(PlCoreBase):
+    name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment")
+    #sites = models.ManyToManyField('Site', through='SiteDeployments', blank=True)
+
+    def __unicode__(self):  return u'%s' % (self.name)
+
+
+class DeploymentRole(PlCoreBase):
+
+    ROLE_CHOICES = (('admin','Admin'),)
+    role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
+
+    def __unicode__(self):  return u'%s' % (self.role)
+
+class DeploymentPrivilege(PlCoreBase):
+
+    user = models.ForeignKey('User', related_name='deployment_privileges')
+    deployment = models.ForeignKey('Deployment', related_name='deployment_privileges')
+    role = models.ForeignKey('DeploymentRole')
+
+    def __unicode__(self):  return u'%s %s %s' % (self.deployment, self.user, self.role)
+
+class SiteDeployments(PlCoreBase):
+    site = models.ForeignKey(Site)
+    deployment = models.ForeignKey(Deployment)
+
+    class Meta:
+        db_table = 'site_deployments'
+        #auto_created = Site
 
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index 3d18b24..1fa342a 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -43,10 +43,9 @@
         super(Slice, self).save(*args, **kwds)
 
 class SliceRole(PlCoreBase):
-    ROLE_CHOICES = (('admin','Admin'),('default','Default'), ('user', 'User'), ('pi', 'PI'))
+    ROLE_CHOICES = (('admin','Admin'),('default','Default'))
 
     role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-    krole_id = models.CharField(max_length=80, verbose_name="Keystone role id", null=True, blank=True)
 
     def __unicode__(self):  return u'%s' % (self.role)
 
diff --git a/planetstack/core/models/user.py b/planetstack/core/models/user.py
index 32f2078..a3b82d8 100644
--- a/planetstack/core/models/user.py
+++ b/planetstack/core/models/user.py
@@ -6,7 +6,6 @@
 from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
 from timezones.fields import TimeZoneField
 
-
 # Create your models here.
 class UserManager(BaseUserManager):
     def create_user(self, email, firstname, lastname, password=None):
@@ -70,6 +69,7 @@
     is_active = models.BooleanField(default=True)
     is_admin = models.BooleanField(default=True)
     is_staff = models.BooleanField(default=True)
+    is_readonly = models.BooleanField(default=False)
 
     created = models.DateTimeField(auto_now_add=True)
     updated = models.DateTimeField(auto_now=True)
@@ -82,6 +82,9 @@
     USERNAME_FIELD = 'email'
     REQUIRED_FIELDS = ['firstname', 'lastname']
 
+    def isReadOnlyUser(self):
+        return self.is_readonly
+
     def get_full_name(self):
         # The user is identified by their email address
         return self.email