1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from django.db import models
13 class BookingNotification(models.Model):
14 id = models.AutoField(primary_key=True)
15 type = models.CharField(max_length=100)
16 booking = models.ForeignKey('booking.Booking', on_delete=models.CASCADE)
17 submit_time = models.DateTimeField()
18 submitted = models.BooleanField(default=False)
20 def get_content(self):
22 'resource_id': self.booking.resource.id,
23 'booking_id': self.booking.id,
24 'user': self.booking.user.username,
25 'user_id': self.booking.user.id,
28 def save(self, *args, **kwargs):
29 notifications = self.booking.bookingnotification_set.filter(type=self.type).exclude(
31 #if notifications.count() > 0:
32 # raise ValueError('Doubled Notification')
33 return super(BookingNotification, self).save(*args, **kwargs)