utils.py¶
This module contains functions for sending email and SMS messages to Remote Care users.
Function definitions:
-
apps.utils.utils.send_email_to(email_adres, email_content, subject='Remote Care - notificatie')[source]¶ Generic function for sending email to email_adres with email_content
- Args:
- email_adres: the receiver of the email
- email_content: the body of the email
Wrapper function for later usage
- Args:
- mobile_number: the mobile number to sent auth_code to
- auth_code: the SMS message to sent
-
apps.utils.utils.send_sms_to_patient(patient, content)[source]¶ Generic function for sending an SMS message to a patient Automatic strips the content so it fits within 160 characters.
- Args:
- patient: the patient to sent the SMS to
- content: The content of the SMS message
-
apps.utils.utils.send_sms_to(mobile_number, auth_code)[source]¶ Generic function which sents the sms using Mollie services.
- Args:
- mobile_number: the mobile_number to sent the SMS message to
- auth_code: The content of the SMS message
-
apps.utils.utils.generic_sent_notification_to_patient(patient, sms_template, email_template, notification_setting)[source]¶ Generic function which is used for sending regular control reminders to a patient
- Args:
- patient: the patient to sent the message(s) to
- sms_template: the sms message to sent to a patient
- email_template: the email message to sent to a patient
-
apps.utils.utils.send_notification_of_new_report(patient)[source]¶ Send a notification of a new report to a patient
- Args:
- patient: the patient to sent the message(s) to
-
apps.utils.utils.send_notification_of_new_message(patient)[source]¶ Send a notification of a new message to a patient
- Args:
- patient: the patient to sent the message(s) to
-
apps.utils.utils.get_password_change_request(email_key)[source]¶ Try to get the current password request and automatically remove expired ones.
- Args:
- email_key: The original email_key stored in HMAC format in the passwordchangerequest.
- Returns:
- The associated PasswordChangeRequest instance or None
-
apps.utils.utils.get_user_for_password_change_request(email_key)[source]¶ Retrieves the user coupled to a password change_request
- Args:
- email_key: The original email_key stored in HMAC format in the passwordchangerequest.
- Returns:
- The User for the associated PasswordChangeRequest instance or None
-
apps.utils.utils.change_password(email_key, password, sms_code)[source]¶ Change password by checking email_key, password and sms_code
- Args:
- email_key: The original email_key stored in HMAC format in the passwordchangerequest.
- password: the new password to set
- sms_code: the SMS authorization code to check
- Returns:
- True if the password has been changed else False
-
apps.utils.utils.sent_password_change_sms(email_key, email, date_of_birth, sent_sms=True, sms_code=None)[source]¶ Sent password change sms, last two parameters are for debugging which can be removed in production stage.
- Args:
- email_key: The original email_key stored in HMAC format in the passwordchangerequest.
- date_of_birth: the date_of_birth to check
- sent_sms: need to sent SMS authorization code? (default=True)
- sms_code: override sms authorization code
- Returns:
- True if the password change authorization SMS has been sent
-
apps.utils.utils.sent_password_change_request(user, url_prefix, change_request_by_manager=False, new_account=False)[source]¶ Sent an e-mail with a password change request to an users e-mail address
- Args:
- user: the user to sent the password change request email to.
- url_prefix: the url prefix to use in the email
- change_request_by_manager: is this change initialized by a manager?
- new_account: is this a new user?
-
apps.utils.utils.create_login_sms_code(user, send_sms=True, sms_code=None)[source]¶ Create and sent a login SMS code to an user the sms_code is stored in HMAC format.
- Args:
- user: the user to sent the login SMS authorization code to.
- send_sms: do sent a SMS authorization code? (default=True)
- sms_code: override the random sms_code
-
apps.utils.utils.check_login_sms_code(sms_code)[source]¶ Check if the sms_code is correct, returns the user coupled to this sms_code which can be further validated.
- Args:
- sms_code: the SMS authorization code sent during login, stored in HMAC form in a LoginSMSCode instance.
- Returns:
- The User instance for the login SMS authorization code or None