blob: 3b6ee825953b51f851ddb37d8ebabe437f07bf03 [file] [log] [blame]
Scott Baker3de3e372013-05-10 16:50:44 -07001import os
2from django.db import models
3from core.models import PlCoreBase
4from core.models import Site
Siobhan Tullybf1153a2013-05-27 20:53:48 -04005from core.models import Deployment
Scott Baker3de3e372013-05-10 16:50:44 -07006
7# Create your models here.
8
9class ServiceClass(PlCoreBase):
10 name = models.CharField(max_length=32)
11 description = models.CharField(max_length=255)
12 commitment = models.IntegerField(default=365)
13 membershipFee = models.IntegerField(default=0)
14 membershipFeeMonths = models.IntegerField(default=12)
15 upgradeRequiresApproval = models.BooleanField(default=False)
16 upgradeFrom = models.ManyToManyField('self', blank=True, null=True)
17
Scott Bakerfcd688f2013-05-13 12:40:53 -070018 class Meta(PlCoreBase.Meta):
19 verbose_name_plural = "Service classes"
20
Scott Baker3de3e372013-05-10 16:50:44 -070021 def __unicode__(self): return u'%s' % (self.name)
22
Scott Bakered0d1b62013-05-13 22:27:47 -070023 @staticmethod
24 def get_default():
25 try:
26 return ServiceClass.objects.get(name="Best Effort")
27 except ServiceClass.DoesNotExist:
28 return None
29
Tony Mack5b061472014-02-04 07:57:10 -050030 def save_by_user(self, user, *args, **kwds):
31 if self.can_update(user):
32 super(ServiceClass, self).save(*args, **kwds)