Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
Siobhan Tully | 30fd429 | 2013-05-10 08:59:56 -0400 | [diff] [blame] | 3 | from core.models import PlCoreBase |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 4 | from django.contrib.contenttypes import generic |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 5 | |
| 6 | # Create your models here. |
| 7 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 8 | class ManyToManyField_NoSyncdb(models.ManyToManyField): |
| 9 | def __init__(self, *args, **kwargs): |
| 10 | super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs) |
| 11 | self.creates_table = False |
| 12 | |
Siobhan Tully | bf1153a | 2013-05-27 20:53:48 -0400 | [diff] [blame] | 13 | class Deployment(PlCoreBase): |
| 14 | name = models.CharField(max_length=200, unique=True, help_text="Name of the Deployment") |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 15 | # sites = ManyToManyField_NoSyncdb('Site', through=Site.deployments.through, blank=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 16 | |
| 17 | def __unicode__(self): return u'%s' % (self.name) |
| 18 | |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 19 | |
| 20 | class DeploymentRole(PlCoreBase): |
| 21 | |
| 22 | ROLE_CHOICES = (('admin','Admin'),) |
| 23 | role = models.CharField(choices=ROLE_CHOICES, unique=True, max_length=30) |
| 24 | |
| 25 | def __unicode__(self): return u'%s' % (self.role) |
| 26 | |
| 27 | class DeploymentPrivilege(PlCoreBase): |
| 28 | |
| 29 | user = models.ForeignKey('User', related_name='deployment_privileges') |
| 30 | deployment = models.ForeignKey('Deployment', related_name='deployment_privileges') |
| 31 | role = models.ForeignKey('DeploymentRole') |
| 32 | |
| 33 | def __unicode__(self): return u'%s %s %s' % (self.deployment, self.user, self.role) |
| 34 | |