From 1d688a412356036b85306fa49e729f5adfae9a0c Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Fri, 22 Jul 2022 14:33:30 -0600 Subject: [PATCH] Add recipient list to comment section --- src/core/models.py | 3 ++- src/core/templates/core/post_detail.html | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/models.py b/src/core/models.py index 5dfff2d..4715b42 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -130,7 +130,8 @@ class Post(models.Model): recipients = models.ManyToManyField( User, blank=True, - related_name='subscriptions' + related_name='subscriptions', + help_text='will be notified when creating or commenting on a post' ) tags = GenericRelation(Tag) diff --git a/src/core/templates/core/post_detail.html b/src/core/templates/core/post_detail.html index 855a5c5..c601d76 100644 --- a/src/core/templates/core/post_detail.html +++ b/src/core/templates/core/post_detail.html @@ -51,6 +51,20 @@
{% csrf_token %} {{ comment_create_form.as_p }} +

+ {% for recipient in post.recipients.all %} + {% if post.recipients.all|length > 2 %} + {% if not forloop.last %}{{ recipient }},{% else %}and {{ recipient }}{% endif %} + {% elif post.recipients.all|length is 2 %} + {% if forloop.last %}and {{ recipient }} {% else %} {{ recipient }}{% endif %} + {% else %} + {{ recipient }} + {% endif %} + {% empty %} + No one + {% endfor %} + will be notified when you post your comment. +