make maps subclassed from plcorebase, add cdnPrefix to maps, prevent map from being bound to multiple things
diff --git a/xos/hpc/models.py b/xos/hpc/models.py
index 1b7535f..2244421 100644
--- a/xos/hpc/models.py
+++ b/xos/hpc/models.py
@@ -78,7 +78,10 @@
def __unicode__(self): return u'%s' % (self.prefix)
-class AccessMap(models.Model):
+class AccessMap(PlCoreBase):
+ class Meta:
+ app_label = "hpc"
+
contentProvider = models.ForeignKey(ContentProvider)
name = models.CharField(max_length=64, help_text="Name of the Access Map")
description = models.TextField(null=True, blank=True,max_length=130)
@@ -86,12 +89,24 @@
def __unicode__(self): return self.name
-class SiteMap(models.Model):
+class SiteMap(PlCoreBase):
+ class Meta:
+ app_label = "hpc"
+
""" can be bound to a ContentProvider, ServiceProvider, or neither """
contentProvider = models.ForeignKey(ContentProvider, blank=True, null=True)
serviceProvider = models.ForeignKey(ServiceProvider, blank=True, null=True)
+ cdnPrefix = models.ForeignKey(CDNPrefix, blank = True, null=True)
name = models.CharField(max_length=64, help_text="Name of the Site Map")
description = models.TextField(null=True, blank=True,max_length=130)
map = models.FileField(upload_to="maps/", help_text="specifies how to map requests to hpc instances")
def __unicode__(self): return self.name
+
+ def save(self, *args, **kwds):
+ if (self.contentProvider) and (self.serviceProvider or self.cdnPrefix):
+ raise ValueError("You may only set one of contentProvider, serviceProvider, or cdnPrefix")
+ if (self.serviceProvider) and (self.cdnPrefix):
+ raise ValueError("You may only set one of contentProvider, serviceProvider, or cdnPrefix")
+
+ super(SiteMap, self).save(*args, **kwds)