Modèles de commentaires et de notifications #18
1 changed files with 26 additions and 26 deletions
|
@ -2,32 +2,6 @@ from django.db import models
|
|||
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):
|
||||
subscribed = models.ManyToManyField(
|
||||
User,
|
||||
|
@ -51,3 +25,29 @@ class Notification(models.Model):
|
|||
blank=True
|
||||
)
|
||||
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"))
|
||||
|
|
Loading…
Reference in a new issue