djangoldp-notification/djangoldp_notification/models.py

24 lines
824 B
Python
Raw Normal View History

2019-01-09 09:27:54 +00:00
from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
class Notification(models.Model):
2019-01-11 08:09:24 +00:00
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='notifications_received')
author_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='notifications_sent')
2019-01-09 09:27:54 +00:00
object = models.URLField()
type = models.CharField(max_length=255)
summary = models.TextField()
date = models.DateTimeField(auto_now_add=True)
read = models.BooleanField()
class Meta:
2019-01-11 08:09:24 +00:00
rdf_type = 'sib:source'
2019-01-09 09:27:54 +00:00
permissions = (
('view_notification', 'Read'),
('control_notification', 'Control'),
)
auto_author = 'author_user'
ordering = ['date']
def __str__(self):
return '{}'.format(self.type)