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 | |
| 7 | # Create your models here. |
| 8 | |
| 9 | class 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 Baker | fcd688f | 2013-05-13 12:40:53 -0700 | [diff] [blame] | 18 | class Meta(PlCoreBase.Meta): |
| 19 | verbose_name_plural = "Service classes" |
| 20 | |
Scott Baker | 3de3e37 | 2013-05-10 16:50:44 -0700 | [diff] [blame] | 21 | def __unicode__(self): return u'%s' % (self.name) |
| 22 | |
Scott Baker | ed0d1b6 | 2013-05-13 22:27:47 -0700 | [diff] [blame] | 23 | @staticmethod |
| 24 | def get_default(): |
| 25 | try: |
| 26 | return ServiceClass.objects.get(name="Best Effort") |
| 27 | except ServiceClass.DoesNotExist: |
| 28 | return None |
| 29 | |
Tony Mack | 5b06147 | 2014-02-04 07:57:10 -0500 | [diff] [blame] | 30 | def save_by_user(self, user, *args, **kwds): |
| 31 | if self.can_update(user): |
| 32 | super(ServiceClass, self).save(*args, **kwds) |