blob: 56f9bd0c3c614e600f97c5b1f6870224c58e5872 [file] [log] [blame]
Siobhan Tully4bc09f22013-04-10 21:15:21 -04001import os
2from django.db import models
Siobhan Tully30fd4292013-05-10 08:59:56 -04003from core.models import PlCoreBase
Siobhan Tullybf1153a2013-05-27 20:53:48 -04004from core.models import Deployment
Siobhan Tullyde5450d2013-06-21 11:35:33 -04005from core.models import Tag
6from django.contrib.contenttypes import generic
Siobhan Tully567e3e62013-06-21 18:03:16 -04007from geoposition.fields import GeopositionField
Siobhan Tully4bc09f22013-04-10 21:15:21 -04008
9class Site(PlCoreBase):
10
Tony Mack85d18832013-05-09 17:02:31 -040011 tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
Siobhan Tully4bc09f22013-04-10 21:15:21 -040012 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")
Siobhan Tully567e3e62013-06-21 18:03:16 -040015 location = GeopositionField()
Siobhan Tully4bc09f22013-04-10 21:15:21 -040016 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)
21
Siobhan Tullybf1153a2013-05-27 20:53:48 -040022 deployments = models.ManyToManyField(Deployment, blank=True, related_name='sites')
Siobhan Tullyde5450d2013-06-21 11:35:33 -040023 tags = generic.GenericRelation(Tag)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040024
25 def __unicode__(self): return u'%s' % (self.name)
26
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040027class SiteRole(PlCoreBase):
28
Tony Mack39714152013-10-08 13:51:05 -040029 ROLE_CHOICES = (('admin','Admin'),('pi','PI'),('tech','Tech'),('billing','Billing'), ('user', 'User'))
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040030 role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30)
Tony Mack27c73902013-10-08 14:36:33 -040031 krole_id = models.CharField(max_length=80, verbose_name="Keystone role id", null=True, blank=True)
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040032
33 def __unicode__(self): return u'%s' % (self.role)
34
Siobhan Tully4bc09f22013-04-10 21:15:21 -040035class SitePrivilege(PlCoreBase):
36
Siobhan Tully30fd4292013-05-10 08:59:56 -040037 user = models.ForeignKey('User', related_name='site_privileges')
Siobhan Tully4bc09f22013-04-10 21:15:21 -040038 site = models.ForeignKey('Site', related_name='site_privileges')
Siobhan Tullybfd11dc2013-09-03 12:59:24 -040039 role = models.ForeignKey('SiteRole')
Siobhan Tully4bc09f22013-04-10 21:15:21 -040040
41 def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role)
42
Tony Mack00d361f2013-04-28 10:28:42 -040043 def save(self, *args, **kwds):
Tony Mack00d361f2013-04-28 10:28:42 -040044 super(SitePrivilege, self).save(*args, **kwds)
45
46 def delete(self, *args, **kwds):
Tony Mack00d361f2013-04-28 10:28:42 -040047 super(SitePrivilege, self).delete(*args, **kwds)
48
Siobhan Tully4bc09f22013-04-10 21:15:21 -040049