update: improve model

This commit is contained in:
Matthieu Fesselier 2019-01-11 15:09:24 +07:00
parent 0593530952
commit 9c1326905a
2 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2019-01-08 08:32
# Generated by Django 1.11 on 2019-01-11 08:04
from __future__ import unicode_literals
from django.conf import settings
@ -25,8 +25,8 @@ class Migration(migrations.Migration):
('summary', models.TextField()),
('date', models.DateTimeField(auto_now_add=True)),
('read', models.BooleanField()),
('author_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='author', to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL)),
('author_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications_sent', to=settings.AUTH_USER_MODEL)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications_received', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['date'],

View File

@ -3,14 +3,15 @@ from django.conf import settings
from django.contrib.auth.models import User
class Notification(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='user')
author_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='author')
user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='notifications_received')
author_user = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='notifications_sent')
object = models.URLField()
type = models.CharField(max_length=255)
summary = models.TextField()
date = models.DateTimeField(auto_now_add=True)
read = models.BooleanField()
class Meta:
rdf_type = 'sib:source'
permissions = (
('view_notification', 'Read'),
('control_notification', 'Control'),