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.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class Notifying(models.Model):
|
class Notifying(models.Model):
|
||||||
|
@ -14,8 +15,14 @@ class Notifying(models.Model):
|
||||||
|
|
||||||
|
|
||||||
class Notification(models.Model):
|
class Notification(models.Model):
|
||||||
sent_by = models.ForeignKey(Notifying)
|
sent_by = models.ForeignKey(
|
||||||
about = models.ForeignKey(Notifying)
|
Notifying,
|
||||||
|
related_name="notifs_sent"
|
||||||
|
)
|
||||||
|
about = models.ForeignKey(
|
||||||
|
Notifying,
|
||||||
|
related_name="notifs",
|
||||||
|
)
|
||||||
to = models.ForeignKey(
|
to = models.ForeignKey(
|
||||||
User,
|
User,
|
||||||
verbose_name=_("envoyée à")
|
verbose_name=_("envoyée à")
|
||||||
|
@ -32,7 +39,7 @@ class Commentable(Notifying):
|
||||||
|
|
||||||
|
|
||||||
class Thread(models.Model):
|
class Thread(models.Model):
|
||||||
topic = models.OneToOne(Commentable)
|
topic = models.OneToOneField(Commentable)
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
|
|
|
@ -44,6 +44,7 @@ BASE_DIR = os.path.dirname(
|
||||||
|
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'communication.apps.CommunicationConfig',
|
||||||
'equipment.apps.EquipmentConfig',
|
'equipment.apps.EquipmentConfig',
|
||||||
'event.apps.EventConfig',
|
'event.apps.EventConfig',
|
||||||
'users.apps.UsersConfig',
|
'users.apps.UsersConfig',
|
||||||
|
|
|
@ -7,6 +7,11 @@ from communication.models import Commentable, Notifying
|
||||||
|
|
||||||
|
|
||||||
class Event(Commentable):
|
class Event(Commentable):
|
||||||
|
commentable_model = models.OneToOneField(
|
||||||
|
Commentable,
|
||||||
|
related_name="event_model",
|
||||||
|
parent_link=True
|
||||||
|
)
|
||||||
title = models.CharField(
|
title = models.CharField(
|
||||||
_("nom de l'évènement"),
|
_("nom de l'évènement"),
|
||||||
max_length=200,
|
max_length=200,
|
||||||
|
|
Loading…
Reference in a new issue