Skip to content

Commit 2e42ac3

Browse files
fix: log only for allowed_enroll email
1 parent 9f5fe30 commit 2e42ac3

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

lms/djangoapps/instructor/enrollment.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Does not include any access control, be sure to check access before calling.
55
"""
66

7-
87
import json
98
import logging
109
from contextlib import ExitStack, contextmanager
@@ -61,6 +60,7 @@
6160

6261
class EmailEnrollmentState:
6362
""" Store the complete enrollment state of an email in a class """
63+
6464
def __init__(self, course_id, email):
6565
# N.B. retired users are not a concern here because they should be
6666
# handled at a higher level (i.e. in enroll_email). Besides, this
@@ -434,10 +434,10 @@ def _reset_module_attempts(studentmodule):
434434

435435

436436
def _fire_score_changed_for_block(
437-
course_id,
438-
student,
439-
block,
440-
module_state_key,
437+
course_id,
438+
student,
439+
block,
440+
module_state_key,
441441
):
442442
"""
443443
Fires a PROBLEM_RAW_SCORE_CHANGED event for the given module.
@@ -592,19 +592,17 @@ def send_mail_to_student(student, param_dict, language=None):
592592
user_context=param_dict,
593593
)
594594

595-
render_msg = presentation.render(DjangoEmailChannel, message)
596-
if not render_msg.body_html.count(student) and message_type == 'allowed_enroll':
597-
log.error(
598-
{
599-
'message': 'Email template does not contain required email address',
600-
'email_address': student,
601-
'message_type': message_type,
602-
'render_msg': render_msg.body,
603-
'count': render_msg.body_html.count(student),
604-
'lms_user_id': lms_user_id,
605-
**param_dict
606-
}
607-
)
595+
if message_type == 'allowed_enroll':
596+
log_data = {
597+
'message': 'allowed_enroll email data log',
598+
'message_type': message_type,
599+
'student': student,
600+
'recipient': message.recipient.email_address,
601+
'context_email': message.context.get('email_address'),
602+
'lms_user_id': lms_user_id,
603+
**param_dict
604+
}
605+
log.error(log_data)
608606
ace.send(message)
609607

610608

0 commit comments

Comments
 (0)