blob: c339b67aadda2354b56807edf84f787966b4bfd5 [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
Scott Bakerd6dc5052014-09-12 12:24:24 -07007def get_default_serviceclass():
8 try:
9 return ServiceClass.objects.get(name="Best Effort")
10 except ServiceClass.DoesNotExist:
11 return None
Scott Baker3de3e372013-05-10 16:50:44 -070012
13class ServiceClass(PlCoreBase):
14 name = models.CharField(max_length=32)
15 description = models.CharField(max_length=255)
16 commitment = models.IntegerField(default=365)
17 membershipFee = models.IntegerField(default=0)
18 membershipFeeMonths = models.IntegerField(default=12)
19 upgradeRequiresApproval = models.BooleanField(default=False)
20 upgradeFrom = models.ManyToManyField('self', blank=True, null=True)
21
Scott Bakerfcd688f2013-05-13 12:40:53 -070022 class Meta(PlCoreBase.Meta):
23 verbose_name_plural = "Service classes"
24
Scott Baker3de3e372013-05-10 16:50:44 -070025 def __unicode__(self): return u'%s' % (self.name)
26
Tony Mack5b061472014-02-04 07:57:10 -050027 def save_by_user(self, user, *args, **kwds):
28 if self.can_update(user):
29 super(ServiceClass, self).save(*args, **kwds)