Allow query to fail
[pharos-tools.git] / dashboard / src / notifier / models.py
1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, and others.
3 #
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 ##############################################################################
9
10 from django.db import models
11 from account.models import UserProfile
12
13
14 class Notification(models.Model):
15     title = models.CharField(max_length=150)
16     content = models.TextField()
17     recipients = models.ManyToManyField(UserProfile, related_name='notifications')
18     is_html = models.BooleanField(default=True)
19     read_by = models.ManyToManyField(UserProfile, related_name='read_notifications')
20
21     def __str__(self):
22         return self.title
23
24     def to_preview_html(self):
25         return "<h3>" + self.title + "</h3>"  # TODO - template?