def after_update_object(self, session, data, view_kwargs): """ Send email if session accepted or rejected """ if 'state' in data and (session.state == 'accepted' or session.state == 'rejected'): # Email for speaker speakers = session.speakers for speaker in speakers: frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}" \ .format(frontend_url, session.event_id, session.id) send_email_session_accept_reject(speaker.email, session, link) send_notif_session_accept_reject(speaker, session.title, session.state, link) # Email for organizer if session.event.get_organizer(): organizer = session.event.get_organizer() organizer_email = organizer.email frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}" \ .format(frontend_url, session.event_id, session.id) send_email_session_accept_reject(organizer_email, session, link) send_notif_session_accept_reject(organizer, session.title, session.state, link)
def after_update_object(self, session, data, view_kwargs): """ Send email if session accepted or rejected """ if 'state' in data and data.get('send_email', None) and (session.state == 'accepted' or session.state == 'rejected'): # Email for speaker speakers = session.speakers for speaker in speakers: frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}" \ .format(frontend_url, session.event_id, session.id) send_email_session_accept_reject(speaker.email, session, link) send_notif_session_accept_reject(speaker, session.title, session.state, link, session.id) # Email for organizer if session.event.get_organizer(): organizer = session.event.get_organizer() organizer_email = organizer.email frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}" \ .format(frontend_url, session.event_id, session.id) send_email_session_accept_reject(organizer_email, session, link) send_notif_session_accept_reject(organizer, session.title, session.state, link, session.id)
def after_update_object(self, session, data, view_kwargs): """ Send email if session accepted or rejected """ if ('state' in data and data.get('send_email', None) and (session.state == 'accepted' or session.state == 'rejected')): event = session.event # Email for speaker speakers = session.speakers for speaker in speakers: frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}".format( frontend_url, event.identifier, session.id) if not speaker.is_email_overridden: send_email_session_accept_reject(speaker.email, session, link) send_notif_session_accept_reject(speaker, session.title, session.state, link, session.id) # Email for owner if session.event.get_owner(): owner = session.event.get_owner() owner_email = owner.email frontend_url = get_settings()['frontend_url'] link = "{}/events/{}/sessions/{}".format( frontend_url, event.identifier, session.id) send_email_session_accept_reject(owner_email, session, link) send_notif_session_accept_reject(owner, session.title, session.state, link, session.id) if 'state' in data: entry_count = SessionsSpeakersLink.query.filter_by( session_id=session.id) if entry_count.count() == 0: is_patch_request = False else: is_patch_request = True if is_patch_request: for focus_session in entry_count: focus_session.session_state = session.state db.session.commit() else: current_session = Session.query.filter_by( id=session.id).first() for speaker in current_session.speakers: session_speaker_link = SessionsSpeakersLink( session_state=session.state, session_id=session.id, event_id=session.event.id, speaker_id=speaker.id, ) save_to_db(session_speaker_link, "Session Speaker Link Saved")
def test_send_notif_session_accept_reject(user): """Method to test session accept reject notification""" send_notif_session_accept_reject( user, 'Homeless Therapy', 'accepted', link, 1, ) notification = Notification.query.first() assert notification.title == 'Session Homeless Therapy has been accepted' assert ( notification.message == 'The session <strong>Homeless Therapy</strong> has been <strong>accepted</strong> ' 'by the Organizer.' )