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
8 class Site(PlCoreBase):
10 tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
11 name = models.CharField(max_length=200, help_text="Name for this Site")
12 site_url = models.URLField(null=True, blank=True, max_length=512, help_text="Site's Home URL Page")
13 enabled = models.BooleanField(default=True, help_text="Status for this Site")
14 longitude = models.FloatField(null=True, blank=True)
15 latitude = models.FloatField(null=True, blank=True)
16 login_base = models.CharField(max_length=50, unique=True, help_text="Prefix for Slices associated with this Site")
17 is_public = models.BooleanField(default=True, help_text="Indicates the visibility of this site to other members")
18 abbreviated_name = models.CharField(max_length=80)
20 deployments = models.ManyToManyField(Deployment, blank=True, related_name='sites')
21 tags = generic.GenericRelation(Tag)
23 def __unicode__(self): return u'%s' % (self.name)
25 class SitePrivilege(PlCoreBase):
27 user = models.ForeignKey('User', related_name='site_privileges')
28 site = models.ForeignKey('Site', related_name='site_privileges')
29 role = models.ForeignKey('Role')
31 def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role)
33 def save(self, *args, **kwds):
34 super(SitePrivilege, self).save(*args, **kwds)
36 def delete(self, *args, **kwds):
37 super(SitePrivilege, self).delete(*args, **kwds)