@@ -88,6 +88,54 @@ def send_thank_you_email(ar: AppointmentRequest, user, request, email: str, appo
88
88
)
89
89
90
90
91
+ def send_reset_link_to_staff_member (user , request , email : str , account_details = None ):
92
+ """Email the staff member to set a password.
93
+
94
+ :param user: The user who booked the appointment.
95
+ :param email: The email address of the client.
96
+ :param account_details: Additional details about the account (default None).
97
+ :param request: The request object.
98
+ :return: None
99
+ """
100
+ # Month and year like "J A N 2 0 2 1"
101
+ token = PasswordResetToken .create_token (user = user , expiration_minutes = 10080 ) # 7 days expiration
102
+ ui_db64 = urlsafe_base64_encode (force_bytes (user .pk ))
103
+ relative_set_passwd_link = reverse ('appointment:set_passwd' , args = [ui_db64 , token .token ])
104
+ set_passwd_link = get_absolute_url_ (relative_set_passwd_link , request = request )
105
+
106
+ message = _ ("""
107
+ Hello {first_name},
108
+
109
+ A request has been received to set a password for your staff account for the year {current_year} at {company}.
110
+
111
+ Please click the link below to set up your new password:
112
+ {activation_link}
113
+
114
+ To login, if ask for a username, use '{username}', otherwise use your email address.
115
+
116
+ If you did not request this, please ignore this email.
117
+
118
+ {account_details}
119
+
120
+ Regards,
121
+ {company}
122
+ """ ).format (
123
+ first_name = user .first_name ,
124
+ current_year = datetime .datetime .now ().year ,
125
+ company = get_website_name (),
126
+ activation_link = set_passwd_link ,
127
+ account_details = account_details if account_details else _ ("No additional details provided." ),
128
+ username = user .username
129
+ )
130
+
131
+ # Assuming send_email is a method you have that sends an email
132
+ send_email (
133
+ recipient_list = [email ],
134
+ subject = _ ("Set Your Password for {company}" ).format (company = get_website_name ()),
135
+ message = message ,
136
+ )
137
+
138
+
91
139
def notify_admin_about_appointment (appointment , client_name : str ):
92
140
"""Notify the admin and the staff member about a new appointment request."""
93
141
email_context = {
0 commit comments