Scott Baker | 3de3e37 | 2013-05-10 16:50:44 -0700 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
| 3 | from core.models import PlCoreBase |
Scott Baker | 3de3e37 | 2013-05-10 16:50:44 -0700 | [diff] [blame] | 4 | |
Scott Baker | cfe0fd9 | 2014-09-12 12:24:24 -0700 | [diff] [blame] | 5 | def get_default_serviceclass(): |
| 6 | try: |
| 7 | return ServiceClass.objects.get(name="Best Effort") |
| 8 | except ServiceClass.DoesNotExist: |
| 9 | return None |
Scott Baker | 3de3e37 | 2013-05-10 16:50:44 -0700 | [diff] [blame] | 10 | |
| 11 | class 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 Baker | fcd688f | 2013-05-13 12:40:53 -0700 | [diff] [blame] | 20 | class Meta(PlCoreBase.Meta): |
| 21 | verbose_name_plural = "Service classes" |
| 22 | |
Scott Baker | 3de3e37 | 2013-05-10 16:50:44 -0700 | [diff] [blame] | 23 | def __unicode__(self): return u'%s' % (self.name) |
| 24 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 25 | def save_by_user(self, user, *args, **kwds): |
| 26 | if self.can_update(user): |
| 27 | super(ServiceClass, self).save(*args, **kwds) |