subscribe reviewer to participant conversation

This commit is contained in:
Élie Bouttier 2016-06-15 19:03:18 +02:00
parent 61127a0770
commit ee6bd5cc8a

View File

@ -30,10 +30,13 @@ def create_conversation_about_talk(sender, instance, created, **kwargs):
@receiver(new_talk, dispatch_uid="Notify new talk") @receiver(new_talk, dispatch_uid="Notify new talk")
def notify_new_talk(sender, instance, **kwargs): def notify_new_talk(sender, instance, **kwargs):
# Subscribe reviewer for these topics to the conversation # Subscribe reviewer for these topics to conversations
topics = instance.topics.all() topics = instance.topics.all()
reviewers = User.objects.filter(participation__review_topics=topics).all() reviewers = User.objects.filter(participation__review_topics=topics).all()
instance.conversation.subscribers.add(*reviewers) instance.conversation.subscribers.add(*reviewers)
for user in instance.speakers.all():
participation = Participation.on_site.get(user=user)
participation.conversation.subscribers.add(*reviewers)
# Notification of this new talk # Notification of this new talk
message = Message(conversation=instance.conversation, author=instance.proposer, message = Message(conversation=instance.conversation, author=instance.proposer,
content='The talk has been proposed.') content='The talk has been proposed.')