fix: add logs and fix issues with reported content email template.
This commit is contained in:
@@ -124,4 +124,5 @@ def send_message(comment, site): # lint-amnesty, pylint: disable=missing-functi
|
||||
|
||||
def send_message_for_reported_content(user, post, site, sender): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
context = create_message_context_for_reported_content(user, post, site, sender)
|
||||
log.info('Reported content email notification task prepared.')
|
||||
tasks.send_ace_message_for_reported_content.apply_async(args=[context], countdown=120)
|
||||
|
||||
@@ -93,6 +93,7 @@ def send_ace_message(context): # lint-amnesty, pylint: disable=missing-function
|
||||
@shared_task(base=LoggedTask)
|
||||
@set_code_owner_attribute
|
||||
def send_ace_message_for_reported_content(context): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
log.info('Reported content email notification task started.')
|
||||
context['course_id'] = CourseKey.from_string(context['course_id'])
|
||||
context['course_name'] = modulestore().get_course(context['course_id']).display_name
|
||||
|
||||
@@ -104,7 +105,7 @@ def send_ace_message_for_reported_content(context): # lint-amnesty, pylint: dis
|
||||
return
|
||||
for moderator in moderators:
|
||||
with emulate_http_request(site=context['site'], user=User.objects.get(id=context['user_id'])):
|
||||
message_context = _build_message_context_for_reported_content(context)
|
||||
message_context = _build_message_context_for_reported_content(context, moderator)
|
||||
message = ReportedContentNotification().personalize(
|
||||
Recipient(moderator.id, moderator.email),
|
||||
_get_course_language(context['course_id']),
|
||||
@@ -113,6 +114,7 @@ def send_ace_message_for_reported_content(context): # lint-amnesty, pylint: dis
|
||||
log.info(f'Sending forum reported content email notification with context {message_context}')
|
||||
ace.send(message)
|
||||
# TODO: add tracking for reported content email
|
||||
log.info('Reported content email notification task completed.')
|
||||
|
||||
|
||||
def _track_notification_sent(message, context):
|
||||
@@ -215,11 +217,12 @@ def _build_message_context(context): # lint-amnesty, pylint: disable=missing-fu
|
||||
return message_context
|
||||
|
||||
|
||||
def _build_message_context_for_reported_content(context): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
def _build_message_context_for_reported_content(context, moderator): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
message_context = get_base_template_context(context['site'])
|
||||
message_context.update(context)
|
||||
message_context.update({
|
||||
'post_link': _get_thread_url(context),
|
||||
'moderator_email': moderator.email,
|
||||
})
|
||||
return message_context
|
||||
|
||||
|
||||
@@ -7,18 +7,20 @@
|
||||
<table width="100%" align="left" border="0" cellpadding="0" cellspacing="0" role="presentation">
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<h2>
|
||||
{% filter force_escape %}
|
||||
{% blocktrans trimmed asvar replied_to_text %}
|
||||
{{ course_name }} {{ course_id }} Reported content awaits review
|
||||
{% endblocktrans %}
|
||||
{% endfilter %}
|
||||
{% interpolate_html replied_to_text start_tag='<b>'|safe end_tag='</b>'|safe %}
|
||||
</p>
|
||||
</h2>
|
||||
<div style="border-left: 1px solid rgba(0,0,0,0.25);
|
||||
padding: 1px 1px 1px 15px;
|
||||
margin: 20px 20px 30px 30px;
|
||||
color: rgba(0,0,0,.75);">
|
||||
<b> You are receiving this email because the following {{ content_type }} was reported for review </b>
|
||||
<b> Title </b>
|
||||
{{ comment_body }}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user