Modèles de commentaires et de notifications #18

Merged
lstephan merged 21 commits from Aufinal/communication_models into master 2017-07-21 16:58:51 +02:00
4 changed files with 20 additions and 3 deletions
Showing only changes of commit 6f158638bf - Show all commits

4
communication/apps.py Normal file
View file

@ -0,0 +1,4 @@
from django.apps import AppConfig
class CommunicationConfig(AppConfig):
name = 'communication'

View file

@ -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):

View file

@ -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',

View file

@ -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,