summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-09-18 20:28:50 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2012-09-18 20:28:50 -0600
commit9097d8a9d76bdec9c5414f60acb8c61dc4b2cde0 (patch)
tree23fd284b20c58dcba0270e2c80974cada2332eb9
parent33a57fbcb64049a817998411e01cc37cc5315e75 (diff)
downloadaskbot-9097d8a9d76bdec9c5414f60acb8c61dc4b2cde0.tar.gz
askbot-9097d8a9d76bdec9c5414f60acb8c61dc4b2cde0.tar.bz2
askbot-9097d8a9d76bdec9c5414f60acb8c61dc4b2cde0.zip
added templates for hardcoded emails
-rw-r--r--askbot/management/commands/send_accept_answer_reminders.py21
-rw-r--r--askbot/management/commands/send_unanswered_question_reminders.py22
-rw-r--r--askbot/models/__init__.py10
-rw-r--r--askbot/skins/default/templates/email/accept_answer_reminder.html14
-rw-r--r--askbot/skins/default/templates/email/instant_notification.html (renamed from askbot/skins/default/templates/instant_notification.html)12
-rw-r--r--askbot/skins/default/templates/email/rejected_post.html12
-rw-r--r--askbot/skins/default/templates/email/unanswered_question_reminder.html14
-rw-r--r--askbot/views/commands.py20
8 files changed, 86 insertions, 39 deletions
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 = '<p>' + reminder_phrase + '</p>'
- body_text += '<ul>'
- for question in final_question_list:
- body_text += '<li><a href="%s%s?sort=latest">%s</a></li>' \
- % (
- askbot_settings.APP_URL,
- question.get_absolute_url(),
- question.thread.title
- )
- body_text += '</ul>'
+
+ 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<br>\nSubject:%s<br>\nText: %s<br>\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 = '<ul>'
- for question in final_question_list:
- body_text += '<li><a href="%s%s?sort=latest">%s</a></li>' \
- % (
- askbot_settings.APP_URL,
- question.get_absolute_url(),
- question.thread.title
- )
- body_text += '</ul>'
+ 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<br>\nSubject:%s<br>\nText: %s<br>\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 += '<p style="font-size:8px;color:#aaa">' + \
- reply_address + '</p>'
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 %}
+<ul>
+ {% for question in questions %}
+ <li><a href="{{site_url}}{{question.get_absolute_url()}}?sort=latest">{{question.thread.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endblock %}
+{%block footer %}
+{% include "email/footer.html" %}
+{% endblock %}
diff --git a/askbot/skins/default/templates/instant_notification.html b/askbot/skins/default/templates/email/instant_notification.html
index cd6e5427..3e8533b6 100644
--- a/askbot/skins/default/templates/instant_notification.html
+++ b/askbot/skins/default/templates/email/instant_notification.html
@@ -1,7 +1,17 @@
+{% extends "email/base_mail.html"%}
+
+{%block content %}
{{ reply_separator }}
<div>{{ content_preview }}</div>
{% trans %}
<p>Please note - you can easily <a href="{{user_subscriptions_url}}">change</a>
how often you receive these notifications or unsubscribe. Thank you for your interest in our forum!</p>
{% endtrans %}
-{% trans %}<p>Sincerely,<br/>Forum Administrator</p>{% endtrans %}
+{%endblock%}
+
+{%block footer %}
+{% include "email/footer.html" %}
+{% if can_reply %}
+<p style="font-size:8px;color:#aaa">{{reply_address}}</p>
+{%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 %}
+<p>{% trans %}Your post (copied in the end), was rejected for the following reason:{% endtrans %}</p>,
+<p>{{reject_reason|safe}}</p>
+<p>{% trans %}Here is your original post{% endtrans %}</p>
+<p>{{post|safe}}</p>
+{% 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 %}
+<ul>
+ {% for question in questions %}
+ <li><a href="{{site_url}}{{question.get_absolute_url()}}?sort=latest">{{question.thread.title}}</a></li>
+ {% endfor %}
+</ul>
+{% endblock %}
+{%block footer %}
+{% include "email/footer.html" %}
+{% endblock %}
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),'),
- '<br/>',
- _('was rejected for the following reason:'),
- '<br/><br/>',
- reject_reason.details.html,
- '<br/><br/>',
- _('Here is your original post'),
- '<br/><br/>',
- 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({