Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 1 | from django.db import models |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 2 | from core.models import User, Service, SingletonModel, PlCoreBase |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 3 | import os |
| 4 | from django.db import models |
| 5 | from django.forms.models import model_to_dict |
| 6 | |
| 7 | |
| 8 | # Create your models here. |
| 9 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 10 | class HpcService(SingletonModel,Service): |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 11 | |
| 12 | class Meta: |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 13 | app_label = "hpc" |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 14 | verbose_name = "HPC Service" |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 15 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 16 | class ServiceProvider(PlCoreBase): |
| 17 | class Meta: |
| 18 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 19 | |
| 20 | service_provider_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 21 | name = models.CharField(max_length=254,help_text="Service Provider Name") |
| 22 | description = models.TextField(max_length=254,null=True, blank=True, help_text="Description of Service Provider") |
| 23 | enabled = models.BooleanField(default=True) |
| 24 | |
| 25 | def __unicode__(self): return u'%s' % (self.name) |
| 26 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 27 | class ContentProvider(PlCoreBase): |
| 28 | class Meta: |
| 29 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 30 | |
| 31 | content_provider_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 32 | name = models.CharField(max_length=254) |
| 33 | enabled = models.BooleanField(default=True) |
| 34 | description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider") |
| 35 | serviceProvider = models.ForeignKey(ServiceProvider) |
| 36 | |
| 37 | # Note user relationships are directed not requiring a role. |
| 38 | users = models.ManyToManyField(User) |
| 39 | |
| 40 | def __unicode__(self): return u'%s' % (self.name) |
| 41 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 42 | class OriginServer(PlCoreBase): |
| 43 | class Meta: |
| 44 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 45 | |
| 46 | origin_server_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 47 | url = models.URLField() |
| 48 | contentProvider = models.ForeignKey(ContentProvider) |
| 49 | |
| 50 | authenticated = models.BooleanField(default=False, help_text="Status for this Site") |
| 51 | enabled = models.BooleanField(default=True, help_text="Status for this Site") |
| 52 | PROTOCOL_CHOICES = (('http', 'HTTP'),('rtmp', 'RTMP'), ('rtp', 'RTP'),('shout', 'SHOUTcast')) |
| 53 | protocol = models.CharField(default="HTTP", max_length = 12, choices=PROTOCOL_CHOICES) |
| 54 | redirects = models.BooleanField(default=True, help_text="Indicates whether Origin Server redirects should be used for this Origin Server") |
| 55 | description = models.TextField(null=True, blank=True, max_length=255) |
| 56 | |
| 57 | def __unicode__(self): return u'%s' % (self.url) |
| 58 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 59 | class CDNPrefix(PlCoreBase): |
| 60 | class Meta: |
| 61 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 62 | |
| 63 | cdn_prefix_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 64 | prefix = models.CharField(max_length=200, help_text="Registered Prefix for Domain") |
| 65 | contentProvider = models.ForeignKey(ContentProvider) |
| 66 | description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider") |
| 67 | |
| 68 | defaultOriginServer = models.ForeignKey(OriginServer) |
| 69 | enabled = models.BooleanField(default=True) |
| 70 | |
| 71 | def __unicode__(self): return u'%s' % (self.prefix) |
| 72 | |
Scott Baker | 5349108 | 2014-03-13 23:15:19 -0700 | [diff] [blame] | 73 | class AccessMap(models.Model): |
| 74 | contentProvider = models.ForeignKey(ContentProvider) |
| 75 | name = models.CharField(max_length=64, help_text="Name of the Access Map") |
| 76 | description = models.TextField(null=True, blank=True,max_length=130) |
| 77 | map = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed") |
| 78 | |
| 79 | def __unicode__(self): return self.name |
| 80 | |
| 81 | class SiteMap(models.Model): |
| 82 | """ can be bound to a ContentProvider, ServiceProvider, or neither """ |
| 83 | contentProvider = models.ForeignKey(ContentProvider, blank=True, null=True) |
| 84 | serviceProvider = models.ForeignKey(ServiceProvider, blank=True, null=True) |
| 85 | name = models.CharField(max_length=64, help_text="Name of the Site Map") |
| 86 | description = models.TextField(null=True, blank=True,max_length=130) |
| 87 | map = models.FileField(upload_to="maps/", help_text="specifies how to map requests to hpc instances") |
| 88 | |
| 89 | def __unicode__(self): return self.name |