Add comment and notification models
This commit is contained in:
parent
f1afadda76
commit
a22ab92e87
4 changed files with 56 additions and 0 deletions
0
communication/__init__.py
Normal file
0
communication/__init__.py
Normal file
0
communication/migrations/__init__.py
Normal file
0
communication/migrations/__init__.py
Normal file
53
communication/models.py
Normal file
53
communication/models.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
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,
|
||||
verbose_name=_("abonnés"),
|
||||
related_name="subscribed_to"
|
||||
)
|
||||
|
||||
def get_url(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class Notification(models.Model):
|
||||
sent_by = models.ForeignKey(Notifying)
|
||||
about = models.ForeignKey(Notifying)
|
||||
to = models.ForeignKey(
|
||||
User,
|
||||
verbose_name=_("envoyée à")
|
||||
)
|
||||
viewed_at = models.DateTimeField(
|
||||
_("Vue à"),
|
||||
blank=True
|
||||
)
|
||||
text = models.TextField(_("corps de la notification"))
|
3
communication/views.py
Normal file
3
communication/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Loading…
Reference in a new issue