diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-25 12:05:19 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-25 12:05:19 +0200 |
commit | e040d30e0a61077f2777beba5853103f327ec130 (patch) | |
tree | b5306d51e8ca89f974a427a4e36afcf1e8a082f9 /pharos-dashboard/booking/models.py | |
parent | 6a7f6ab08eee8c2d6fdf600e699feb941e85d033 (diff) |
Add a Booking detail view
JIRA: RELENG-12
This adds a pop-up to the booking calendar, containing information
about a selected booking.
Change-Id: Ie780006963cb927d073103edbaefbdab3de403fb
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'pharos-dashboard/booking/models.py')
-rw-r--r-- | pharos-dashboard/booking/models.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pharos-dashboard/booking/models.py b/pharos-dashboard/booking/models.py index 8011fa4..4be8cca 100644 --- a/pharos-dashboard/booking/models.py +++ b/pharos-dashboard/booking/models.py @@ -1,7 +1,9 @@ from django.contrib.auth.models import User from django.db import models +from jira import JIRA from dashboard.models import Resource +from pharos_dashboard import settings class Booking(models.Model): @@ -17,6 +19,11 @@ class Booking(models.Model): class Meta: db_table = 'booking' + def get_jira_issue(self): + jira = JIRA(server=settings.JIRA_URL, basic_auth=(settings.JIRA_USER_NAME, settings.JIRA_USER_PASSWORD)) + issue = jira.issue(self.jira_issue_id) + return issue + def authorization_test(self): """ Return True if self.user is authorized to make this booking. @@ -41,13 +48,12 @@ class Booking(models.Model): if self.start >= self.end: raise ValueError('Start date is after end date') # conflicts end after booking starts, and start before booking ends - conflicting_dates = Booking.objects.filter(resource=self.resource) + conflicting_dates = Booking.objects.filter(resource=self.resource).exclude(id=self.id) conflicting_dates = conflicting_dates.filter(end__gt=self.start) conflicting_dates = conflicting_dates.filter(start__lt=self.end) if conflicting_dates.count() > 0: raise ValueError('This booking overlaps with another booking') return super(Booking, self).save(*args, **kwargs) - def __str__(self): return str(self.resource) + ' from ' + str(self.start) + ' until ' + str(self.end) |