Skip to content

Commit

Permalink
fix: log only for allowed_enroll email
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid committed Feb 19, 2025
1 parent 9f5fe30 commit 2e42ac3
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lms/djangoapps/instructor/enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Does not include any access control, be sure to check access before calling.
"""


import json
import logging
from contextlib import ExitStack, contextmanager
Expand Down Expand Up @@ -61,6 +60,7 @@

class EmailEnrollmentState:
""" Store the complete enrollment state of an email in a class """

def __init__(self, course_id, email):
# N.B. retired users are not a concern here because they should be
# handled at a higher level (i.e. in enroll_email). Besides, this
Expand Down Expand Up @@ -434,10 +434,10 @@ def _reset_module_attempts(studentmodule):


def _fire_score_changed_for_block(
course_id,
student,
block,
module_state_key,
course_id,
student,
block,
module_state_key,
):
"""
Fires a PROBLEM_RAW_SCORE_CHANGED event for the given module.
Expand Down Expand Up @@ -592,19 +592,17 @@ def send_mail_to_student(student, param_dict, language=None):
user_context=param_dict,
)

render_msg = presentation.render(DjangoEmailChannel, message)
if not render_msg.body_html.count(student) and message_type == 'allowed_enroll':
log.error(
{
'message': 'Email template does not contain required email address',
'email_address': student,
'message_type': message_type,
'render_msg': render_msg.body,
'count': render_msg.body_html.count(student),
'lms_user_id': lms_user_id,
**param_dict
}
)
if message_type == 'allowed_enroll':
log_data = {
'message': 'allowed_enroll email data log',
'message_type': message_type,
'student': student,
'recipient': message.recipient.email_address,
'context_email': message.context.get('email_address'),
'lms_user_id': lms_user_id,
**param_dict
}
log.error(log_data)
ace.send(message)


Expand Down

0 comments on commit 2e42ac3

Please sign in to comment.