blob: 5c84d1b920d2fc2b136c31ca3366efa4a2b82637 [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 Tully4bc09f22013-04-10 21:15:21 -04007
8class Site(PlCoreBase):
9
Tony Mack85d18832013-05-09 17:02:31 -040010 tenant_id = models.CharField(null=True, blank=True, max_length=200, help_text="Keystone tenant id")
Siobhan Tully4bc09f22013-04-10 21:15:21 -040011 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)
19
Siobhan Tullybf1153a2013-05-27 20:53:48 -040020 deployments = models.ManyToManyField(Deployment, blank=True, related_name='sites')
Siobhan Tullyde5450d2013-06-21 11:35:33 -040021 tags = generic.GenericRelation(Tag)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040022
23 def __unicode__(self): return u'%s' % (self.name)
24
25class SitePrivilege(PlCoreBase):
26
Siobhan Tully30fd4292013-05-10 08:59:56 -040027 user = models.ForeignKey('User', related_name='site_privileges')
Siobhan Tully4bc09f22013-04-10 21:15:21 -040028 site = models.ForeignKey('Site', related_name='site_privileges')
29 role = models.ForeignKey('Role')
30
31 def __unicode__(self): return u'%s %s %s' % (self.site, self.user, self.role)
32
Tony Mack00d361f2013-04-28 10:28:42 -040033 def save(self, *args, **kwds):
Tony Mack00d361f2013-04-28 10:28:42 -040034 super(SitePrivilege, self).save(*args, **kwds)
35
36 def delete(self, *args, **kwds):
Tony Mack00d361f2013-04-28 10:28:42 -040037 super(SitePrivilege, self).delete(*args, **kwds)
38
Siobhan Tully4bc09f22013-04-10 21:15:21 -040039