def save_and_send_status_notification(request, notification_data, status_update): """Called by send_and_save_new_status, Responsible for the 'notification'portion of a status update. """ sub = status_update.application.form_submission contact_info = sub.get_usable_contact_info() author_profile = status_update.author.profile notification_intro = get_notification_intro(author_profile) status_update_data = vars(status_update) status_update_data.update(author=status_update.author, status_type=status_update.status_type, application=status_update.application, next_steps=list(status_update.next_steps.all())) default_message = '\n\n'.join([ notification_intro, get_base_message_from_status_update_data(request, status_update_data) ]) edited_message = '\n\n'.join( [notification_intro, notification_data['sent_message']]) notification_data.update(base_message=default_message, sent_message=edited_message, status_update=status_update, contact_info=contact_info) status_notification = models.StatusNotification(**notification_data) status_notification.save() notifications.send_applicant_notification( contact_info, edited_message, subject="Update from Clear My Record", sender_profile=author_profile)
def send_application_transfer_notification(transfer_data): contact_info = transfer_data['form_submission'].get_usable_contact_info() if contact_info: intro, body = render_application_transfer_message(**transfer_data) base_message = "\n\n".join([intro, body]) sent_message = "\n\n".join( [intro, transfer_data.get('sent_message', body)]) notifications.send_simple_front_notification( contact_info, sent_message, subject="Update from Clear My Record") return models.StatusNotification(contact_info=contact_info, base_message=base_message, sent_message=sent_message) return None