1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, 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 ##############################################################################
10 from django.db import models
11 from account.models import UserProfile
12 from booking.models import Booking
15 class Notification(models.Model):
16 title = models.CharField(max_length=150)
17 content = models.TextField()
18 recipients = models.ManyToManyField(UserProfile, related_name='notifications')
19 is_html = models.BooleanField(default=True)
20 read_by = models.ManyToManyField(UserProfile, related_name='read_notifications')
25 def to_preview_html(self):
26 return "<h3>" + self.title + "</h3>" # TODO - template?
29 class Emailed(models.Model):
30 """A simple record to remember who has already gotten an email to avoid resending."""
32 begin_booking = models.OneToOneField(
35 on_delete=models.CASCADE,
36 related_name="begin_mail"
38 almost_end_booking = models.OneToOneField(
41 on_delete=models.CASCADE,
42 related_name="warning_mail"
44 end_booking = models.OneToOneField(
47 on_delete=models.CASCADE,
48 related_name="over_mail"
52 class Email(models.Model):
53 sent = models.BooleanField(default=False)
54 title = models.CharField(max_length=150)
55 message = models.TextField()
56 recipient = models.CharField(max_length=150)