Modèles de commentaires et de notifications #18

Merged
lstephan merged 21 commits from Aufinal/communication_models into master 2017-07-21 16:58:51 +02:00
Showing only changes of commit 26c02df53d - Show all commits

View file

@ -2,32 +2,6 @@ from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
class Commentable(models.Model):
pass
class Thread(models.Model):
topic = models.OneToOne(Commentable)
class Comment(models.Model):
thread = models.ForeignKey(Thread)
parent = models.ForeignKey(
'Comment',
related_name="replies",
)
author = models.ForeignKey(
User,
verbose_name=_("auteur"),
editable=False
)
at = models.DateTimeField(
_("date d'écriture"),
auto_now_add=True
)
text = models.TextField(_("corps du message"))
class Notifying(models.Model): class Notifying(models.Model):
subscribed = models.ManyToManyField( subscribed = models.ManyToManyField(
User, User,
@ -51,3 +25,29 @@ class Notification(models.Model):
blank=True blank=True
) )
text = models.TextField(_("corps de la notification")) text = models.TextField(_("corps de la notification"))
class Commentable(Notifying):
pass
class Thread(models.Model):
topic = models.OneToOne(Commentable)
class Comment(models.Model):
thread = models.ForeignKey(Thread)
parent = models.ForeignKey(
'Comment',
related_name="replies",
)
author = models.ForeignKey(
User,
verbose_name=_("auteur"),
editable=False
)
at = models.DateTimeField(
_("date d'écriture"),
auto_now_add=True
)
text = models.TextField(_("corps du message"))