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