def after_create_object(self, session, data, view_kwargs): """ method to send email for creation of new session mails session link to the concerned user :param session: :param data: :param view_kwargs: :return: """ if session.event.get_owner(): event_name = session.event.name owner = session.event.get_owner() owner_email = owner.email event = session.event link = make_frontend_url("/events/{}/sessions/{}".format( event.identifier, session.id)) send_email_new_session(owner_email, event_name, link) send_notif_new_session_organizer(owner, event_name, link, session.id) for speaker in 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 after_update_object(self, session, data, view_kwargs): """ Send email if session accepted or rejected """ if data.get('send_email', None) and g.get('send_email'): notify_for_session(session) 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 after_create_object(self, session, data, view_kwargs): """ method to send email for creation of new session mails session link to the concerned user :param session: :param data: :param view_kwargs: :return: """ for speaker in session.speakers: session_speaker_link = SessionsSpeakersLink( session_id=session.id, event_id=session.event.id, speaker_id=speaker.id, ) save_to_db(session_speaker_link, "Session Speaker Link Saved") if session.event.get_owner(): owner = session.event.get_owner() owner_email = owner.email if session.speakers: send_email_new_session( owner_email, session, session.speakers) # TODO: Send to all organizers notify_new_session(session)
def after_update_object(self, session, data, view_kwargs): """ Send email if session accepted or rejected """ if data.get('send_email', None) and g.get('send_email'): notify_for_session(session) 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 not is_patch_request: current_session = Session.query.filter_by( id=session.id).first() for speaker in current_session.speakers: session_speaker_link = SessionsSpeakersLink( session_id=session.id, event_id=session.event.id, speaker_id=speaker.id, ) save_to_db(session_speaker_link, "Session Speaker Link Saved") if current_session.event.get_owner( ) and current_session.speakers: owner = session.event.get_owner() owner_email = owner.email send_email_new_session(owner_email, session, current_session.speakers ) # TODO: Send to all organizers
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 after_patch(self, result): """ method to create session speaker link :param result: """ # This method is executed when a new speaker is created # and added to an existing session speaker_id = result['data']['id'] speaker = Speaker.query.filter_by(id=speaker_id).first() if SessionsSpeakersLink.query.filter_by(speaker_id=speaker_id).count() == 0: all_sessions = Session.query.filter_by(deleted_at=None) for session in all_sessions: if speaker in 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")