Skip to content

Commit

Permalink
Don't show course and program ids in financial assistance emails (#2421)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cp-at-mit and pre-commit-ci[bot] authored Oct 22, 2024
1 parent b1ae30a commit b2a17cf
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions flexiblepricing/mail_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.core.exceptions import ValidationError
from mitol.mail.api import get_message_sender

from courses.models import Course
from flexiblepricing.constants import (
FLEXIBLE_PRICE_EMAIL_APPROVAL_MESSAGE,
FLEXIBLE_PRICE_EMAIL_APPROVAL_SUBJECT,
Expand Down Expand Up @@ -36,34 +35,23 @@ def generate_flexible_price_email(flexible_price):
Returns:
dict: {"subject": (str), "body": (str)}
"""
courseware_readable_id_formatted = (
flexible_price.courseware_object.course_number
if isinstance(flexible_price.courseware_object, Course)
else flexible_price.courseware_object.readable_id
)
program_name_with_course_number = (
courseware_readable_id_formatted + " " + flexible_price.courseware_object.title
)
program_name = flexible_price.courseware_object.title
if flexible_price.status == FlexiblePriceStatus.APPROVED:
price = flexible_price.tier.discount.friendly_format()
message = FLEXIBLE_PRICE_EMAIL_APPROVAL_MESSAGE.format(
program_name=program_name_with_course_number, price=price
program_name=program_name, price=price
)
subject = FLEXIBLE_PRICE_EMAIL_APPROVAL_SUBJECT.format(
program_name=program_name_with_course_number
program_name=program_name
)
elif flexible_price.status == FlexiblePriceStatus.PENDING_MANUAL_APPROVAL:
message = FLEXIBLE_PRICE_EMAIL_DOCUMENTS_RECEIVED_MESSAGE
subject = FLEXIBLE_PRICE_EMAIL_DOCUMENTS_RECEIVED_SUBJECT.format(
program_name=program_name_with_course_number
program_name=program_name
)
elif flexible_price.status == FlexiblePriceStatus.RESET:
message = FLEXIBLE_PRICE_EMAIL_RESET_MESSAGE.format(
program_name=program_name_with_course_number
)
subject = FLEXIBLE_PRICE_EMAIL_RESET_SUBJECT.format(
program_name=program_name_with_course_number
)
message = FLEXIBLE_PRICE_EMAIL_RESET_MESSAGE.format(program_name=program_name)
subject = FLEXIBLE_PRICE_EMAIL_RESET_SUBJECT.format(program_name=program_name)
else:
raise ValidationError(
"Invalid status on FlexiblePrice for generate_flexible_price_email()" # noqa: EM101
Expand All @@ -76,7 +64,7 @@ def generate_flexible_price_email(flexible_price):
"subject": subject,
"first_name": flexible_price.user.legal_address.first_name,
"message": message,
"program_name": program_name_with_course_number,
"program_name": program_name,
},
)
except: # noqa: E722
Expand Down

0 comments on commit b2a17cf

Please sign in to comment.