2 from django.db import models
3 from core.models import PlCoreBase
4 from core.models import Deployment
5 from core.models import Tag
6 from django.contrib.contenttypes import generic
7 from geoposition.fields import GeopositionField
9 class Site(PlCoreBase):
11 tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
12 name = models.CharField(max_length=200, help_text="Name for this Site")
13 site_url = models.URLField(null=True, blank=True, max_length=512, help_text="Site's Home URL Page")
14 enabled = models.BooleanField(default=True, help_text="Status for this Site")
15 location = GeopositionField()
16 longitude = models.FloatField(null=True, blank=True)
17 latitude = models.FloatField(null=True, blank=True)
18 login_base = models.CharField(max_length=50, unique=True, help_text="Prefix for Slices associated with this Site")
19 is_public = models.BooleanField(default=True, help_text="Indicates the visibility of this site to other members")
20 abbreviated_name = models.CharField(max_length=80)
22 deployments = models.ManyToManyField(Deployment, blank=True, related_name='sites')
23 tags = generic.GenericRelation(Tag)
25 def __unicode__(self): return u'%s' % (self.name)
27 class SiteRole(PlCoreBase):
29 ROLE_CHOICES = (('admin','Admin'),('pi','PI'),('tech','Tech'),('billing','Billing'), ('user', 'User'))
30 role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
31 krole_id = models.CharField(max_length=80, verbose_name="Keystone role id", null=True, blank=True)
33 def __unicode__(self): return u'%s' % (self.role)
35 class SitePrivilege(PlCoreBase):
37 user = models.ForeignKey('User', related_name='site_privileges')
38 site = models.ForeignKey('Site', related_name='site_privileges')
39 role = models.ForeignKey('SiteRole')
41 def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role)
43 def save(self, *args, **kwds):
44 super(SitePrivilege, self).save(*args, **kwds)
46 def delete(self, *args, **kwds):
47 super(SitePrivilege, self).delete(*args, **kwds)