diff --git a/competition/templates/competition/emails/comment_added.txt b/competition/templates/competition/emails/comment_added.txt index f4458221..a598d911 100644 --- a/competition/templates/competition/emails/comment_added.txt +++ b/competition/templates/competition/emails/comment_added.txt @@ -1 +1,2 @@ -Bol pridaný nový komentár. +Bol pridaný nový komentár k úlohe {{problem}}: +{{comment}} diff --git a/competition/templates/competition/emails/comment_hidden.txt b/competition/templates/competition/emails/comment_hidden.txt index 5e11e571..74292dec 100644 --- a/competition/templates/competition/emails/comment_hidden.txt +++ b/competition/templates/competition/emails/comment_hidden.txt @@ -1 +1,4 @@ -Tvoj komentár bol skrytý a dostal si k nemu súkromnú odpoveď. +Tvoj komentár +{{comment}} +k úloje {{problem}} bol skrytý a dostal si k nemu súkromnú odpoveď: +{{response}} diff --git a/competition/templates/competition/emails/comment_published.txt b/competition/templates/competition/emails/comment_published.txt index 2d9f7ad4..2f4e3f67 100644 --- a/competition/templates/competition/emails/comment_published.txt +++ b/competition/templates/competition/emails/comment_published.txt @@ -1 +1,3 @@ -Tvoj komentár bol zverejnený a dostal si k nemu odpoveď. +Tvoj komentár +{{comment}} +k úlohe {{problem}} bol zverejnený a dostal/a si k nemu odpoveď. diff --git a/competition/views.py b/competition/views.py index 0ddbd954..aec1028d 100644 --- a/competition/views.py +++ b/competition/views.py @@ -149,12 +149,17 @@ def get_serializer_context(self): @action(methods=['post'], detail=True) def publish(self, request, pk=None): """Publikovanie, teda zverejnenie komentára""" - comment = self.get_object() + comment: Comment = self.get_object() comment.publish() send_mail( 'Zverejnený komentár', - render_to_string('competition/emails/comment_published.txt'), + render_to_string( + 'competition/emails/comment_published.txt', + context={ + 'comment': comment.text, + 'problem': comment.problem + }), None, [comment.posted_by.email], ) @@ -166,12 +171,17 @@ def publish(self, request, pk=None): @action(methods=['post'], detail=True) def hide(self, request, pk=None): """Skrytie komentára""" - comment = self.get_object() + comment: Comment = self.get_object() comment.hide(message=request.data.get('hidden_response')) send_mail( 'Skrytý komentár', - render_to_string('competition/emails/comment_hidden.txt'), + render_to_string('competition/emails/comment_hidden.txt', + context={ + 'comment': comment.text, + 'problem': comment.problem, + 'response': comment.hidden_response + }), None, [comment.posted_by.email], ) @@ -224,14 +234,18 @@ def comments(self, request, pk=None): permission_classes=[IsAuthenticated]) def add_comment(self, request, pk=None): """Pridá komentár (otázku) k úlohe""" - problem = self.get_object() + problem: Problem = self.get_object() also_publish = problem.can_user_modify(request.user) problem.add_comment(request.data['text'], request.user, also_publish) send_mail( 'Nový komentár', - render_to_string('competition/emails/comment_added.txt'), + render_to_string('competition/emails/comment_added.txt', + context={ + 'problem': problem, + 'comment': request.data['text'] + }), None, [EMAIL_ALERT], )