blob: e445228b563b88c822e19a84c20b5d76e0dcd5af [file] [log] [blame]
Scott Bakerea03c932013-05-17 09:06:44 -07001import os
Scott Bakere444a002013-05-19 16:04:49 -07002import datetime
Scott Bakerea03c932013-05-17 09:06:44 -07003from django.db import models
4from core.models import PlCoreBase
5from core.models import Sliver
6from core.models import Slice
7from core.models import ServiceResource
8
9# Create your models here.
10
11class Reservation(PlCoreBase):
12 startTime = models.DateTimeField()
13 slice = models.ForeignKey(Slice, related_name="reservations")
14 duration = models.IntegerField(default=1)
15
Scott Bakerfc7879e2013-05-19 16:19:48 -070016 def __unicode__(self): return u'%s to %s' % (self.startTime, self.endTime)
Scott Bakerea03c932013-05-17 09:06:44 -070017
Scott Bakere444a002013-05-19 16:04:49 -070018 @property
19 def endTime(self):
20 return self.startTime + datetime.timedelta(hours=self.duration)
21
Scott Bakerea03c932013-05-17 09:06:44 -070022class 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