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 | |
Scott Baker | 7a09076 | 2014-05-07 09:04:07 -0700 | [diff] [blame] | 31 | # legacy vicci content providers already have names. |
| 32 | CP_TO_ACCOUNT = {"ON.LAB": "onlabcp", |
| 33 | "Syndicate": "syndicatecp"} |
| 34 | |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 35 | content_provider_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 36 | name = models.CharField(max_length=254) |
| 37 | enabled = models.BooleanField(default=True) |
| 38 | description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider") |
| 39 | serviceProvider = models.ForeignKey(ServiceProvider) |
| 40 | |
| 41 | # Note user relationships are directed not requiring a role. |
| 42 | users = models.ManyToManyField(User) |
| 43 | |
| 44 | def __unicode__(self): return u'%s' % (self.name) |
| 45 | |
Scott Baker | 7a09076 | 2014-05-07 09:04:07 -0700 | [diff] [blame] | 46 | @property |
| 47 | def account(self): |
| 48 | return self.CP_TO_ACCOUNT.get(self.name, self.name) |
| 49 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 50 | class OriginServer(PlCoreBase): |
| 51 | class Meta: |
| 52 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 53 | |
| 54 | origin_server_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 55 | url = models.URLField() |
| 56 | contentProvider = models.ForeignKey(ContentProvider) |
| 57 | |
| 58 | authenticated = models.BooleanField(default=False, help_text="Status for this Site") |
| 59 | enabled = models.BooleanField(default=True, help_text="Status for this Site") |
| 60 | PROTOCOL_CHOICES = (('http', 'HTTP'),('rtmp', 'RTMP'), ('rtp', 'RTP'),('shout', 'SHOUTcast')) |
| 61 | protocol = models.CharField(default="HTTP", max_length = 12, choices=PROTOCOL_CHOICES) |
| 62 | redirects = models.BooleanField(default=True, help_text="Indicates whether Origin Server redirects should be used for this Origin Server") |
| 63 | description = models.TextField(null=True, blank=True, max_length=255) |
| 64 | |
| 65 | def __unicode__(self): return u'%s' % (self.url) |
| 66 | |
Siobhan Tully | cf04fb6 | 2014-01-11 11:25:57 -0500 | [diff] [blame] | 67 | class CDNPrefix(PlCoreBase): |
| 68 | class Meta: |
| 69 | app_label = "hpc" |
Scott Baker | e728c89 | 2014-01-12 11:41:09 -0800 | [diff] [blame] | 70 | |
| 71 | cdn_prefix_id = models.IntegerField(null=True, blank=True) |
Siobhan Tully | bfd11dc | 2013-09-03 12:59:24 -0400 | [diff] [blame] | 72 | prefix = models.CharField(max_length=200, help_text="Registered Prefix for Domain") |
| 73 | contentProvider = models.ForeignKey(ContentProvider) |
| 74 | description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Content Provider") |
| 75 | |
| 76 | defaultOriginServer = models.ForeignKey(OriginServer) |
| 77 | enabled = models.BooleanField(default=True) |
| 78 | |
| 79 | def __unicode__(self): return u'%s' % (self.prefix) |
| 80 | |
Scott Baker | 5349108 | 2014-03-13 23:15:19 -0700 | [diff] [blame] | 81 | class AccessMap(models.Model): |
| 82 | contentProvider = models.ForeignKey(ContentProvider) |
| 83 | name = models.CharField(max_length=64, help_text="Name of the Access Map") |
| 84 | description = models.TextField(null=True, blank=True,max_length=130) |
| 85 | map = models.FileField(upload_to="maps/", help_text="specifies which client requests are allowed") |
| 86 | |
| 87 | def __unicode__(self): return self.name |
| 88 | |
| 89 | class SiteMap(models.Model): |
| 90 | """ can be bound to a ContentProvider, ServiceProvider, or neither """ |
| 91 | contentProvider = models.ForeignKey(ContentProvider, blank=True, null=True) |
| 92 | serviceProvider = models.ForeignKey(ServiceProvider, blank=True, null=True) |
| 93 | name = models.CharField(max_length=64, help_text="Name of the Site Map") |
| 94 | description = models.TextField(null=True, blank=True,max_length=130) |
| 95 | map = models.FileField(upload_to="maps/", help_text="specifies how to map requests to hpc instances") |
| 96 | |
| 97 | def __unicode__(self): return self.name |