set default for omf_friendly, move get_default_serviceclass outside of model for compaitibility with migrations
diff --git a/planetstack/core/models/serviceclass.py b/planetstack/core/models/serviceclass.py
index 3b6ee82..c339b67 100644
--- a/planetstack/core/models/serviceclass.py
+++ b/planetstack/core/models/serviceclass.py
@@ -4,7 +4,11 @@
from core.models import Site
from core.models import Deployment
-# Create your models here.
+def get_default_serviceclass():
+ try:
+ return ServiceClass.objects.get(name="Best Effort")
+ except ServiceClass.DoesNotExist:
+ return None
class ServiceClass(PlCoreBase):
name = models.CharField(max_length=32)
@@ -20,13 +24,6 @@
def __unicode__(self): return u'%s' % (self.name)
- @staticmethod
- def get_default():
- try:
- return ServiceClass.objects.get(name="Best Effort")
- except ServiceClass.DoesNotExist:
- return None
-
def save_by_user(self, user, *args, **kwds):
if self.can_update(user):
super(ServiceClass, self).save(*args, **kwds)
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index 0ecc99d..1023856 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -7,6 +7,7 @@
from core.models import Role
from core.models import Deployment
from core.models import ServiceClass
+from core.models.serviceclass import get_default_serviceclass
from core.models import Tag
from django.contrib.contenttypes import generic
from core.models import Service
@@ -18,18 +19,18 @@
class Slice(PlCoreBase):
name = models.CharField(unique=True, help_text="The Name of the Slice", max_length=80)
enabled = models.BooleanField(default=True, help_text="Status for this Slice")
- omf_friendly = models.BooleanField()
+ omf_friendly = models.BooleanField(default=False)
description=models.TextField(blank=True,help_text="High level description of the slice and expected activities", max_length=1024)
slice_url = models.URLField(blank=True, max_length=512)
site = models.ForeignKey(Site, related_name='slices', help_text="The Site this Slice belongs to")
- max_slivers = models.IntegerField(default=10)
+ max_slivers = models.IntegerField(default=10)
imagePreference = models.CharField(default="Ubuntu 12.04 LTS", null=True, blank=True, max_length=256)
service = models.ForeignKey(Service, related_name='service', null=True, blank=True)
network = models.CharField(default="Private Only",null=True, blank=True, max_length=256)
mountDataSets = models.CharField(default="GenBank",null=True, blank=True, max_length=256)
tags = generic.GenericRelation(Tag)
- serviceClass = models.ForeignKey(ServiceClass, related_name = "slices", null=True, default=ServiceClass.get_default)
+ serviceClass = models.ForeignKey(ServiceClass, related_name = "slices", null=True, default=get_default_serviceclass)
creator = models.ForeignKey(User, related_name='slices', blank=True, null=True)
def __unicode__(self): return u'%s' % (self.name)