From 9097d8a9d76bdec9c5414f60acb8c61dc4b2cde0 Mon Sep 17 00:00:00 2001 From: Adolfo Fitoria Date: Tue, 18 Sep 2012 20:28:50 -0600 Subject: added templates for hardcoded emails --- .../commands/send_accept_answer_reminders.py | 21 +++++++++++---------- .../commands/send_unanswered_question_reminders.py | 22 ++++++++++++---------- askbot/models/__init__.py | 10 ++++------ .../templates/email/accept_answer_reminder.html | 14 ++++++++++++++ .../templates/email/instant_notification.html | 17 +++++++++++++++++ .../default/templates/email/rejected_post.html | 12 ++++++++++++ .../email/unanswered_question_reminder.html | 14 ++++++++++++++ .../default/templates/instant_notification.html | 7 ------- askbot/views/commands.py | 20 ++++++++------------ 9 files changed, 92 insertions(+), 45 deletions(-) create mode 100644 askbot/skins/default/templates/email/accept_answer_reminder.html create mode 100644 askbot/skins/default/templates/email/instant_notification.html create mode 100644 askbot/skins/default/templates/email/rejected_post.html create mode 100644 askbot/skins/default/templates/email/unanswered_question_reminder.html delete mode 100644 askbot/skins/default/templates/instant_notification.html diff --git a/askbot/management/commands/send_accept_answer_reminders.py b/askbot/management/commands/send_accept_answer_reminders.py index 3a20ba27..119d7611 100644 --- a/askbot/management/commands/send_accept_answer_reminders.py +++ b/askbot/management/commands/send_accept_answer_reminders.py @@ -8,6 +8,8 @@ from django.utils.translation import ugettext as _ from django.utils.translation import ungettext from askbot import mail from askbot.utils.classes import ReminderSchedule +from askbot.skins.loaders import get_template +from django.template import Context DEBUG_THIS_COMMAND = False @@ -63,16 +65,15 @@ class Command(NoArgsCommand): reminder_phrase = _('Please accept the best answer for this question:') else: reminder_phrase = _('Please accept the best answer for these questions:') - body_text = '

' + reminder_phrase + '

' - body_text += '' + + data = { + 'site_url': askbot_settings.APP_URL, + 'questions': final_question_list, + 'reminder_phrase': reminder_phrase + } + + template = get_template('email/accept_answer_reminder.html') + body_text = template.render(Context(data)) if DEBUG_THIS_COMMAND: print "User: %s
\nSubject:%s
\nText: %s
\n" % \ diff --git a/askbot/management/commands/send_unanswered_question_reminders.py b/askbot/management/commands/send_unanswered_question_reminders.py index 39402b25..3fa390ad 100644 --- a/askbot/management/commands/send_unanswered_question_reminders.py +++ b/askbot/management/commands/send_unanswered_question_reminders.py @@ -6,11 +6,13 @@ from django.utils.translation import ungettext from askbot import mail from askbot.utils.classes import ReminderSchedule from askbot.models.question import Thread +from askbot.skins.loaders import get_template +from django.template import Context DEBUG_THIS_COMMAND = False class Command(NoArgsCommand): - """management command that sends reminders + """management command that sends reminders about unanswered questions to all users """ def handle_noargs(self, **options): @@ -69,15 +71,15 @@ class Command(NoArgsCommand): 'topics': tag_summary } - body_text = '' + data = { + 'site_url': askbot_settings.APP_URL, + 'questions': final_question_list, + 'subject_line': subject_line + } + + template = get_template('email/unanswered_question_reminder.html') + body_text = template.render(Context(data)) + if DEBUG_THIS_COMMAND: print "User: %s
\nSubject:%s
\nText: %s
\n" % \ diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index f5e67189..2044dc16 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -2266,7 +2266,7 @@ def user_get_group_membership(self, group): return GroupMembership.objects.get(user=self, group=group) except GroupMembership.DoesNotExist: return None - + def user_get_groups_membership_info(self, groups): """returns a defaultdict with values that are @@ -2973,14 +2973,12 @@ def format_instant_notification_email( 'post_url': post_url, 'origin_post_title': origin_post.thread.title, 'user_subscriptions_url': user_subscriptions_url, - 'reply_separator': reply_separator + 'reply_separator': reply_separator, + 'reply_address': reply_address } subject_line = _('"%(title)s"') % {'title': origin_post.thread.title} content = template.render(Context(update_data)) - if can_reply: - content += '

' + \ - reply_address + '

' return subject_line, content @@ -3083,7 +3081,7 @@ def send_instant_notifications_about_activity_in_post( reply_address = reply_address, alt_reply_address = alt_reply_address, update_type = update_type, - template = get_template('instant_notification.html') + template = get_template('email/instant_notification.html') ) headers['Reply-To'] = reply_address diff --git a/askbot/skins/default/templates/email/accept_answer_reminder.html b/askbot/skins/default/templates/email/accept_answer_reminder.html new file mode 100644 index 00000000..7b922cd4 --- /dev/null +++ b/askbot/skins/default/templates/email/accept_answer_reminder.html @@ -0,0 +1,14 @@ +{% extends "email/base_mail.html"%} +{%block title%}{{reminder_phrase}}{% endblock %} +{%block headline%}{{reminder_phrase}}{% endblock %} + +{%block content %} + +{% endblock %} +{%block footer %} +{% include "email/footer.html" %} +{% endblock %} diff --git a/askbot/skins/default/templates/email/instant_notification.html b/askbot/skins/default/templates/email/instant_notification.html new file mode 100644 index 00000000..3e8533b6 --- /dev/null +++ b/askbot/skins/default/templates/email/instant_notification.html @@ -0,0 +1,17 @@ +{% extends "email/base_mail.html"%} + +{%block content %} +{{ reply_separator }} +
{{ content_preview }}
+{% trans %} +

Please note - you can easily change +how often you receive these notifications or unsubscribe. Thank you for your interest in our forum!

+{% endtrans %} +{%endblock%} + +{%block footer %} +{% include "email/footer.html" %} +{% if can_reply %} +

{{reply_address}}

+{%endif%} +{%endblock%} diff --git a/askbot/skins/default/templates/email/rejected_post.html b/askbot/skins/default/templates/email/rejected_post.html new file mode 100644 index 00000000..7106d37f --- /dev/null +++ b/askbot/skins/default/templates/email/rejected_post.html @@ -0,0 +1,12 @@ +{% extends "email/base_mail.html"%} +{%block headline%}{% trans %} Your post was rejected. {% endtrans %}{%endblock%} +{%block title%}{% trans %} Your post was rejected. {% endtrans %}{%endblock%} +{%block content %} +

{% trans %}Your post (copied in the end), was rejected for the following reason:{% endtrans %}

, +

{{reject_reason|safe}}

+

{% trans %}Here is your original post{% endtrans %}

+

{{post|safe}}

+{% endblock %} +{%block footer %} +{% include "email/footer.html" %} +{% endblock %} diff --git a/askbot/skins/default/templates/email/unanswered_question_reminder.html b/askbot/skins/default/templates/email/unanswered_question_reminder.html new file mode 100644 index 00000000..8eaa6f40 --- /dev/null +++ b/askbot/skins/default/templates/email/unanswered_question_reminder.html @@ -0,0 +1,14 @@ +{% extends "email/base_mail.html"%} +{%block title%}{{subject_line}}{% endblock %} +{%block headline%}{{subject_line}}{% endblock %} + +{%block content %} + +{% endblock %} +{%block footer %} +{% include "email/footer.html" %} +{% endblock %} diff --git a/askbot/skins/default/templates/instant_notification.html b/askbot/skins/default/templates/instant_notification.html deleted file mode 100644 index cd6e5427..00000000 --- a/askbot/skins/default/templates/instant_notification.html +++ /dev/null @@ -1,7 +0,0 @@ -{{ reply_separator }} -
{{ content_preview }}
-{% trans %} -

Please note - you can easily change -how often you receive these notifications or unsubscribe. Thank you for your interest in our forum!

-{% endtrans %} -{% trans %}

Sincerely,
Forum Administrator

{% endtrans %} diff --git a/askbot/views/commands.py b/askbot/views/commands.py index e967a080..2ab15c35 100644 --- a/askbot/views/commands.py +++ b/askbot/views/commands.py @@ -32,6 +32,7 @@ from askbot.utils import decorators from askbot.utils import url_utils from askbot.utils.forms import get_db_object_or_404 from askbot import mail +from django.template import Context from askbot.skins.loaders import render_into_skin, get_template from askbot.skins.loaders import render_into_skin_as_string from askbot.skins.loaders import render_text_into_skin @@ -106,17 +107,12 @@ def manage_inbox(request): reject_reason = models.PostFlagReason.objects.get( id = post_data['reject_reason_id'] ) - body_text = string_concat( - _('Your post (copied in the end),'), - '
', - _('was rejected for the following reason:'), - '

', - reject_reason.details.html, - '

', - _('Here is your original post'), - '

', - post.text - ) + template = get_template('email/rejected_post.html') + data = { + 'post': post.html, + 'reject_reason': reject_reason.details.html + } + body_text = template.render(Context(data)) mail.send_mail( subject_line = _('your post was not accepted'), body_text = unicode(body_text), @@ -1355,7 +1351,7 @@ def get_editor(request): #parse out javascript and dom, and return them separately #we need that, because js needs to be added in a special way html_soup = BeautifulSoup(editor_html) - + parsed_scripts = list() for script in html_soup.find_all('script'): parsed_scripts.append({ -- cgit v1.2.3-1-g7c22