Modèles de commentaires et de notifications #18
4 changed files with 20 additions and 3 deletions
4
communication/apps.py
Normal file
4
communication/apps.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
class CommunicationConfig(AppConfig):
|
||||
name = 'communication'
|
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class Notifying(models.Model):
|
||||
|
@ -14,8 +15,14 @@ class Notifying(models.Model):
|
|||
|
||||
|
||||
class Notification(models.Model):
|
||||
sent_by = models.ForeignKey(Notifying)
|
||||
about = models.ForeignKey(Notifying)
|
||||
sent_by = models.ForeignKey(
|
||||
Notifying,
|
||||
related_name="notifs_sent"
|
||||
)
|
||||
about = models.ForeignKey(
|
||||
Notifying,
|
||||
related_name="notifs",
|
||||
)
|
||||
to = models.ForeignKey(
|
||||
User,
|
||||
verbose_name=_("envoyée à")
|
||||
|
@ -32,7 +39,7 @@ class Commentable(Notifying):
|
|||
|
||||
|
||||
class Thread(models.Model):
|
||||
topic = models.OneToOne(Commentable)
|
||||
topic = models.OneToOneField(Commentable)
|
||||
|
||||
|
||||
class Comment(models.Model):
|
||||
|
|
|
@ -44,6 +44,7 @@ BASE_DIR = os.path.dirname(
|
|||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'communication.apps.CommunicationConfig',
|
||||
'equipment.apps.EquipmentConfig',
|
||||
'event.apps.EventConfig',
|
||||
'users.apps.UsersConfig',
|
||||
|
|
|
@ -7,6 +7,11 @@ from communication.models import Commentable, Notifying
|
|||
|
||||
|
||||
class Event(Commentable):
|
||||
commentable_model = models.OneToOneField(
|
||||
Commentable,
|
||||
related_name="event_model",
|
||||
parent_link=True
|
||||
)
|
||||
title = models.CharField(
|
||||
_("nom de l'évènement"),
|
||||
max_length=200,
|
||||
|
|
Loading…
Reference in a new issue