blob: 56f9bd0c3c614e600f97c5b1f6870224c58e5872 [file] [log] [blame]
import os
from django.db import models
from core.models import PlCoreBase
from core.models import Deployment
from core.models import Tag
from django.contrib.contenttypes import generic
from geoposition.fields import GeopositionField
class Site(PlCoreBase):
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")
enabled = models.BooleanField(default=True, help_text="Status for this Site")
location = GeopositionField()
longitude = models.FloatField(null=True, blank=True)
latitude = models.FloatField(null=True, blank=True)
login_base = models.CharField(max_length=50, unique=True, help_text="Prefix for Slices associated with this Site")
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')
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 = 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)
class SitePrivilege(PlCoreBase):
user = models.ForeignKey('User', related_name='site_privileges')
site = models.ForeignKey('Site', related_name='site_privileges')
role = models.ForeignKey('SiteRole')
def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role)
def save(self, *args, **kwds):
super(SitePrivilege, self).save(*args, **kwds)
def delete(self, *args, **kwds):
super(SitePrivilege, self).delete(*args, **kwds)