|
16 | 16 |
|
17 | 17 | from appointment import messages_ as email_messages
|
18 | 18 | from appointment.email_sender import notify_admin, send_email
|
| 19 | +from appointment.logger_config import get_logger |
19 | 20 | from appointment.models import AppointmentRequest, EmailVerificationCode, PasswordResetToken
|
20 | 21 | from appointment.settings import APPOINTMENT_PAYMENT_URL
|
21 | 22 | from appointment.utils.date_time import convert_24_hour_time_to_12_hour_time
|
22 | 23 | from appointment.utils.db_helpers import get_absolute_url_, get_website_name
|
23 | 24 |
|
| 25 | +logger = get_logger(__name__) |
| 26 | + |
24 | 27 |
|
25 | 28 | def get_thank_you_message(ar: AppointmentRequest) -> str:
|
26 | 29 | """
|
@@ -83,8 +86,8 @@ def send_thank_you_email(ar: AppointmentRequest, user, request, email: str, appo
|
83 | 86 | 'reschedule_link': reschedule_link,
|
84 | 87 | }
|
85 | 88 | send_email(
|
86 |
| - recipient_list=[email], subject=_("Thank you for booking us."), |
87 |
| - template_url='email_sender/thank_you_email.html', context=email_context |
| 89 | + recipient_list=[email], subject=_("Thank you for booking us."), |
| 90 | + template_url='email_sender/thank_you_email.html', context=email_context |
88 | 91 | )
|
89 | 92 |
|
90 | 93 |
|
@@ -121,34 +124,36 @@ def send_reset_link_to_staff_member(user, request, email: str, account_details=N
|
121 | 124 | Regards,
|
122 | 125 | {company}
|
123 | 126 | """).format(
|
124 |
| - first_name=user.first_name, |
125 |
| - current_year=datetime.datetime.now().year, |
126 |
| - company=website_name, |
127 |
| - activation_link=set_passwd_link, |
128 |
| - account_details=account_details if account_details else _("No additional details provided."), |
129 |
| - username=user.username |
| 127 | + first_name=user.first_name, |
| 128 | + current_year=datetime.datetime.now().year, |
| 129 | + company=website_name, |
| 130 | + activation_link=set_passwd_link, |
| 131 | + account_details=account_details if account_details else _("No additional details provided."), |
| 132 | + username=user.username |
130 | 133 | )
|
131 | 134 |
|
132 | 135 | # Assuming send_email is a method you have that sends an email
|
133 | 136 | send_email(
|
134 |
| - recipient_list=[email], |
135 |
| - subject=_("Set Your Password for {company}").format(company=website_name), |
136 |
| - message=message, |
| 137 | + recipient_list=[email], |
| 138 | + subject=_("Set Your Password for {company}").format(company=website_name), |
| 139 | + message=message, |
137 | 140 | )
|
138 | 141 |
|
139 | 142 |
|
140 | 143 | def notify_admin_about_appointment(appointment, client_name: str):
|
141 | 144 | """Notify the admin and the staff member about a new appointment request."""
|
| 145 | + logger.info(f"Sending admin notification for new appointment {appointment.id}") |
142 | 146 | email_context = {
|
143 | 147 | 'client_name': client_name,
|
144 | 148 | 'appointment': appointment
|
145 | 149 | }
|
146 | 150 |
|
147 | 151 | subject = _("New Appointment Request for ") + client_name
|
148 | 152 | staff_member = appointment.get_staff_member()
|
149 |
| - # Assuming notify_admin and send_email are previously defined functions |
150 | 153 | notify_admin(subject=subject, template_url='email_sender/admin_new_appointment_email.html', context=email_context)
|
151 | 154 | if staff_member.user.email not in settings.ADMINS:
|
| 155 | + logger.info( |
| 156 | + f"Let's notify the staff member as well for new appointment {appointment.id} since they are not an admin.") |
152 | 157 | send_email(recipient_list=[staff_member.user.email], subject=subject,
|
153 | 158 | template_url='email_sender/admin_new_appointment_email.html', context=email_context)
|
154 | 159 |
|
@@ -190,8 +195,8 @@ def send_reschedule_confirmation_email(request, reschedule_history, appointment_
|
190 | 195 |
|
191 | 196 | subject = _("Confirm Your Appointment Rescheduling")
|
192 | 197 | send_email(
|
193 |
| - recipient_list=[email], subject=subject, |
194 |
| - template_url='email_sender/reschedule_email.html', context=email_context |
| 198 | + recipient_list=[email], subject=subject, |
| 199 | + template_url='email_sender/reschedule_email.html', context=email_context |
195 | 200 | )
|
196 | 201 |
|
197 | 202 |
|
|
0 commit comments