]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/skins/default/templates/notifications/newquestion.html
Added extra check to avoid empty tags been sent in notifications.
[osqa.git] / forum / skins / default / templates / notifications / newquestion.html
index e408950cc6d78294d96855678fc785dc11dcb142..3425c98b1c05ef4e05cdf3f7af3eeee7b5dab66d 100644 (file)
@@ -1,31 +1,36 @@
 {% load i18n extra_tags email_tags %}
 
 {% declare %}
-    prefix = settings.EMAIL_SUBJECT_PREFIX
-    app_name = settings.APP_SHORT_NAME
-    question_author = question.author.username
-    question_url = settings.APP_URL + question.get_absolute_url()
-    question_title = question.title
-    question_tags = question.tagnames
-    safe_body = html.html2text(question.html)
+    prefix = html.mark_safe(smart_str(settings.EMAIL_SUBJECT_PREFIX))
+    app_name = smart_str(settings.APP_SHORT_NAME)
+    safe_app_name = html.mark_safe(smart_str(settings.APP_SHORT_NAME))
+    question_author = html.mark_safe(smart_str(question.author.username))
+    question_url = smart_str(settings.APP_URL + question.get_absolute_url())
+    question_title = html.mark_safe(smart_str(question.title))
+    question_tags = html.mark_safe(smart_str(question.tagnames))
+    safe_body = html.html2text(smart_str(question.html))
+    author_link = html.objlink(question.author, style=settings.EMAIL_ANCHOR_STYLE)
+    question_link = html.objlink(question, style=settings.EMAIL_ANCHOR_STYLE)
+    tag_links = html.mark_safe(smart_str(" ".join([html.objlink(t, style=settings.EMAIL_ANCHOR_STYLE) for t in question.tags.all()])))
 {% enddeclare %}
 
 {% email %}
-    {% subject %}{% blocktrans %}{{ prefix }} New question on {{ app_name }}{% endblocktrans %}{% endsubject %}
+    {% subject %}{% blocktrans %}{{ prefix }} New question: {{ question_title }} on {{ safe_app_name }}{% endblocktrans %}{% endsubject %}
 
     {% htmlcontent notifications/base.html %}
-        {% declare %}
-            author_link = html.objlink(question.author, style=a_style)
-            question_link = html.objlink(question, style=a_style)
-            tag_links = html.mark_safe(" ".join([html.objlink(t, style=a_style) for t in question.tags.all()]))
-        {% enddeclare %}
-
         <p style="{{ p_style }}">
+            {% if tag_links != "" %}
             {% blocktrans %}
             {{ author_link }} has just posted a new question on {{ app_name }}, entitled
             {{ question_link }}
              and tagged "<em>{{ tag_links }}</em>". Here's what it says:
             {% endblocktrans %}
+            {%else%}
+            {% blocktrans %}
+            {{ author_link }} has just posted a new question on {{ app_name }}, entitled
+            {{ question_link }}. Here's what it says:
+            {% endblocktrans %}
+            {%endif%}
         </p>
 
         <blockquote>
@@ -37,7 +42,7 @@
 
 {% textcontent notifications/base_text.html %}
 {% blocktrans %}
-{{ question_author }} has just posted a new question on {{ app_name }}, entitled
+{{ question_author }} has just posted a new question on {{ safe_app_name }}, entitled
 "{{ question_title }}" and tagged {{ question_tags }}:
 {% endblocktrans %}
 {{ safe_body }}