summaryrefslogtreecommitdiffstats
path: root/dashboard/src/booking/models.py
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2018-01-05 16:07:13 -0500
committerSawyer Bergeron <sbergeron@iol.unh.edu>2018-01-09 15:03:34 -0500
commitc32479489db670904579a580a918f3513581fda9 (patch)
tree9f4778cbd48ce5bf83c86830e7e5117931c73a47 /dashboard/src/booking/models.py
parentdc387ea4307eeb4c676c796ec1380d20564e5ef9 (diff)
Implement Booking Modification Interface
Jira: PHAROS-330 Users can change start date if it has not already occurred, and can change end date, purpose, and both installer and scenario. Standard checks apply similar to when initially creating a booking. Change-Id: Ibae7fe91a58bd6e0741db065265c05c3823bdc27 Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'dashboard/src/booking/models.py')
-rw-r--r--dashboard/src/booking/models.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/dashboard/src/booking/models.py b/dashboard/src/booking/models.py
index 0bf5961..9156484 100644
--- a/dashboard/src/booking/models.py
+++ b/dashboard/src/booking/models.py
@@ -13,6 +13,8 @@ from django.contrib.auth.models import User
from django.db import models
from jira import JIRA
from jira import JIRAError
+from django.utils.crypto import get_random_string
+import hashlib
from dashboard.models import Resource
@@ -40,10 +42,12 @@ class Opsys(models.Model):
class Booking(models.Model):
id = models.AutoField(primary_key=True)
+ changeid = models.TextField(default='initial', blank=True, null=True)
user = models.ForeignKey(User, models.CASCADE) # delete if user is deleted
resource = models.ForeignKey(Resource, models.PROTECT)
start = models.DateTimeField()
end = models.DateTimeField()
+ reset = models.BooleanField(default=False)
jira_issue_id = models.IntegerField(null=True)
jira_issue_status = models.CharField(max_length=50)
@@ -78,6 +82,10 @@ class Booking(models.Model):
conflicting_dates = conflicting_dates.filter(start__lt=self.end)
if conflicting_dates.count() > 0:
raise ValueError('This booking overlaps with another booking')
+ if not self.changeid:
+ self.changeid = self.id
+ else:
+ self.changeid = hashlib.md5(self.changeid.encode() + get_random_string(length=32).encode()).hexdigest()
return super(Booking, self).save(*args, **kwargs)
def __str__(self):