blob: 42685685325621f0e4ca19d2f2fdf8c00f485bbc [file] [log] [blame]
Scott Baker3de3e372013-05-10 16:50:44 -07001import os
2from django.db import models
3from core.models import PlCoreBase
Scott Baker3de3e372013-05-10 16:50:44 -07004
Scott Bakercfe0fd92014-09-12 12:24:24 -07005def get_default_serviceclass():
6 try:
7 return ServiceClass.objects.get(name="Best Effort")
8 except ServiceClass.DoesNotExist:
9 return None
Scott Baker3de3e372013-05-10 16:50:44 -070010
11class ServiceClass(PlCoreBase):
12 name = models.CharField(max_length=32)
13 description = models.CharField(max_length=255)
14 commitment = models.IntegerField(default=365)
15 membershipFee = models.IntegerField(default=0)
16 membershipFeeMonths = models.IntegerField(default=12)
17 upgradeRequiresApproval = models.BooleanField(default=False)
18 upgradeFrom = models.ManyToManyField('self', blank=True, null=True)
19
Scott Bakerfcd688f2013-05-13 12:40:53 -070020 class Meta(PlCoreBase.Meta):
21 verbose_name_plural = "Service classes"
22
Scott Baker3de3e372013-05-10 16:50:44 -070023 def __unicode__(self): return u'%s' % (self.name)
24
Tony Mack5b061472014-02-04 07:57:10 -050025 def save_by_user(self, user, *args, **kwds):
26 if self.can_update(user):
27 super(ServiceClass, self).save(*args, **kwds)