From 6f158638bfd0c8d2b7c84d8ed3f4e9cfd71f0fb3 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sat, 15 Jul 2017 21:22:15 +0200 Subject: [PATCH] Various bugfixes --- communication/apps.py | 4 ++++ communication/models.py | 13 ++++++++++--- evenementiel/settings/common.py | 1 + event/models.py | 5 +++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 communication/apps.py diff --git a/communication/apps.py b/communication/apps.py new file mode 100644 index 0000000..e6c488d --- /dev/null +++ b/communication/apps.py @@ -0,0 +1,4 @@ +from django.apps import AppConfig + +class CommunicationConfig(AppConfig): + name = 'communication' diff --git a/communication/models.py b/communication/models.py index 5ac52a3..c0d19a0 100644 --- a/communication/models.py +++ b/communication/models.py @@ -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): diff --git a/evenementiel/settings/common.py b/evenementiel/settings/common.py index 61bf2d6..5d291cb 100644 --- a/evenementiel/settings/common.py +++ b/evenementiel/settings/common.py @@ -44,6 +44,7 @@ BASE_DIR = os.path.dirname( INSTALLED_APPS = [ + 'communication.apps.CommunicationConfig', 'equipment.apps.EquipmentConfig', 'event.apps.EventConfig', 'users.apps.UsersConfig', diff --git a/event/models.py b/event/models.py index 186a3db..c1c89ce 100644 --- a/event/models.py +++ b/event/models.py @@ -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,