From c32479489db670904579a580a918f3513581fda9 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Fri, 5 Jan 2018 16:07:13 -0500 Subject: 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 --- dashboard/src/booking/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'dashboard/src/booking/models.py') 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): -- cgit 1.2.3-korg