From 88be32db4e28a546a474523d835d209cb7ec9f13 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Thu, 31 May 2012 03:31:48 -0400 Subject: changed some phrasing in the email notification --- askbot/models/__init__.py | 2 +- askbot/models/post.py | 15 +++++++-- askbot/skins/default/templates/email/macros.html | 38 ++++++++++++++++++++-- .../skins/default/templates/email/quoted_post.html | 5 ++- 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index cc1209d2..24d4a3fc 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -2653,7 +2653,7 @@ def format_instant_notification_email( ) #todo: remove hardcoded style else: - content_preview = post.format_for_email() + content_preview = post.format_for_email(is_leaf_post = True) #add indented summaries for the parent posts content_preview += post.format_for_email_as_parent_thread_summary() diff --git a/askbot/models/post.py b/askbot/models/post.py index 81edcc6d..673b4c6f 100644 --- a/askbot/models/post.py +++ b/askbot/models/post.py @@ -604,7 +604,9 @@ class Post(models.Model): """ return html_utils.strip_tags(self.html)[:max_length] + ' ...' - def format_for_email(self, quote_level = 0): + def format_for_email( + self, quote_level = 0, is_leaf_post = False, format = None + ): """format post for the output in email, if quote_level > 0, the post will be indented that number of times todo: move to views? @@ -617,7 +619,9 @@ class Post(models.Model): data = { 'post': self, 'quote_level': quote_level, - 'html': absolutize_urls_func(self.html) + #'html': absolutize_urls_func(self.html), + 'is_leaf_post': is_leaf_post, + 'format': format } return template.render(Context(data)) @@ -632,6 +636,7 @@ class Post(models.Model): if parent_post is None: break quote_level += 1 + """ output += '

' output += _( 'In reply to %(user)s %(post)s of %(date)s' @@ -641,7 +646,11 @@ class Post(models.Model): 'date': parent_post.added_at.strftime(const.DATETIME_FORMAT) } output += '

' - output += parent_post.format_for_email(quote_level = quote_level) + """ + output += parent_post.format_for_email( + quote_level = quote_level, + format = 'parent_subthread' + ) current_post = parent_post return output diff --git a/askbot/skins/default/templates/email/macros.html b/askbot/skins/default/templates/email/macros.html index f69dc541..078c5c16 100644 --- a/askbot/skins/default/templates/email/macros.html +++ b/askbot/skins/default/templates/email/macros.html @@ -1,4 +1,10 @@ -{% macro quoted_post(post = None, quote_level = 0) %} +{% macro quoted_post( + post = None, + quote_level = 0, + format = None, + is_leaf_post = False + ) +%} {% spaceless %} {{ start_quote(quote_level) }} {% set author = post.author.username %} @@ -21,11 +27,37 @@ {% endif %} {% elif post.post_type == 'answer' %}

- {% trans %}Answered by {{ author }}:{% endtrans %} + {% if format == 'parent_subthread' %} + {% if is_leaf_post %} + {% trans -%} + {{ author }}'s answer: + {%- endtrans %} + {% else %} + {% trans -%} + In reply to {{ author }}'s answer: + {%- endtrans %} + {% endif %} + {% else %} + {% trans %}Answered by {{ author }}:{% endtrans %} + {% endif %}

{% else %}

- {% trans author %}Commented by {{ author }}:{% endtrans %} + {% if format == 'parent_subthread' %} + {% if is_leaf_post %} + {% trans -%} + {{ author }}'s comment: + {%- endtrans %} + {% else %} + {% trans -%} + In reply to {{ author }}'s comment: + {%- endtrans %} + {% endif %} + {% else %} + {% trans author -%} + Commented by {{ author }}: + {%- endtrans %} + {% endif %}

{% endif %} {{ post.html }} diff --git a/askbot/skins/default/templates/email/quoted_post.html b/askbot/skins/default/templates/email/quoted_post.html index d93661a1..ecc20ad9 100644 --- a/askbot/skins/default/templates/email/quoted_post.html +++ b/askbot/skins/default/templates/email/quoted_post.html @@ -1,2 +1,5 @@ {% from "email/macros.html" import quoted_post %} -{{ quoted_post(post, quote_level) }} +{{ quoted_post( + post, quote_level, is_leaf_post = is_leaf_post, format = format + ) +}} -- cgit v1.2.3-1-g7c22