Scott Baker | ea03c93 | 2013-05-17 09:06:44 -0700 | [diff] [blame] | 1 | import os |
Scott Baker | e444a00 | 2013-05-19 16:04:49 -0700 | [diff] [blame] | 2 | import datetime |
Scott Baker | ea03c93 | 2013-05-17 09:06:44 -0700 | [diff] [blame] | 3 | from django.db import models |
| 4 | from core.models import PlCoreBase |
| 5 | from core.models import Sliver |
| 6 | from core.models import Slice |
| 7 | from core.models import ServiceResource |
| 8 | |
| 9 | # Create your models here. |
| 10 | |
| 11 | class Reservation(PlCoreBase): |
| 12 | startTime = models.DateTimeField() |
| 13 | slice = models.ForeignKey(Slice, related_name="reservations") |
| 14 | duration = models.IntegerField(default=1) |
| 15 | |
Scott Baker | fc7879e | 2013-05-19 16:19:48 -0700 | [diff] [blame] | 16 | def __unicode__(self): return u'%s to %s' % (self.startTime, self.endTime) |
Scott Baker | ea03c93 | 2013-05-17 09:06:44 -0700 | [diff] [blame] | 17 | |
Scott Baker | e444a00 | 2013-05-19 16:04:49 -0700 | [diff] [blame] | 18 | @property |
| 19 | def endTime(self): |
| 20 | return self.startTime + datetime.timedelta(hours=self.duration) |
| 21 | |
Scott Baker | ea03c93 | 2013-05-17 09:06:44 -0700 | [diff] [blame] | 22 | class ReservedResource(PlCoreBase): |
| 23 | sliver = models.ForeignKey(Sliver, related_name="reservedResourrces") |
| 24 | resource = models.ForeignKey(ServiceResource, related_name="reservedResources") |
| 25 | quantity = models.IntegerField(default=1) |
| 26 | reservationSet = models.ForeignKey(Reservation, related_name="reservedResources") |
| 27 | |
| 28 | class Meta(PlCoreBase.Meta): |
| 29 | verbose_name_plural = "Reserved Resources" |
| 30 | |
| 31 | def __unicode__(self): return u'%d %s on %s' % (self.quantity, self.resource, self.sliver) |
| 32 | |
| 33 | |
| 34 | |
| 35 | |