From a22ab92e87164d3ffcc4333c1ffe3ada04716304 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sat, 15 Jul 2017 18:13:45 +0200 Subject: [PATCH] Add comment and notification models --- communication/__init__.py | 0 communication/migrations/__init__.py | 0 communication/models.py | 53 ++++++++++++++++++++++++++++ communication/views.py | 3 ++ 4 files changed, 56 insertions(+) create mode 100644 communication/__init__.py create mode 100644 communication/migrations/__init__.py create mode 100644 communication/models.py create mode 100644 communication/views.py diff --git a/communication/__init__.py b/communication/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/communication/migrations/__init__.py b/communication/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/communication/models.py b/communication/models.py new file mode 100644 index 0000000..25584c9 --- /dev/null +++ b/communication/models.py @@ -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")) diff --git a/communication/views.py b/communication/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/communication/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.