def create_view(event_id): if request.method == 'POST': email = request.form['email'] user = DataGetter.get_user_by_email(email) event = DataGetter.get_event(event_id) if user: DataManager.add_invite_to_event(user.id, event_id) hash = DataGetter.get_invite_by_user_id(user.id).hash link = url_for('event_sessions.new_view', event_id=event_id, user_id=user.id, hash=hash, _external=True) Helper.send_email_invitation(email, event.name, link) cfs_link = url_for('event_detail.display_event_cfs', identifier=event.identifier) Helper.send_notif_invite_papers(user, event.name, cfs_link, link) return redirect(url_for('events.details_view', event_id=event_id))
def add_session_to_event(request, event_id, state=None, use_current_user=True): """ Session will be saved to database with proper Event id :param use_current_user: :param state: :param request: The request :param event_id: Session belongs to Event by event id """ form = request.form slide_temp_url = form.get('slides_url') video_temp_url = form.get('video_url') audio_temp_url = form.get('audio_url') slide_file = '' video_file = '' audio_file = '' if slide_temp_url: slide_file = UploadedFile(get_path_of_temp_url(slide_temp_url), slide_temp_url.rsplit('/', 1)[1]) if video_temp_url: video_file = UploadedFile(get_path_of_temp_url(video_temp_url), video_temp_url.rsplit('/', 1)[1]) if audio_temp_url: audio_file = UploadedFile(get_path_of_temp_url(audio_temp_url), audio_temp_url.rsplit('/', 1)[1]) if not state: state = form.get('state', 'draft') event = DataGetter.get_event(event_id) new_session = Session(title=form.get('title', ''), subtitle=form.get('subtitle', ''), long_abstract=form.get('long_abstract', ''), start_time=event.start_time, end_time=event.start_time + timedelta(hours=1), event_id=event_id, short_abstract=form.get('short_abstract', ''), level=form.get('level', ''), comments=form.get('comments', ''), language=form.get('language', ''), state=state) if form.get('track', None) != "": new_session.track_id = form.get('track', None) if form.get('session_type', None) != "": new_session.session_type_id = form.get('session_type', None) speaker = Speaker.query.filter_by(email=form.get('email', '')).filter_by(event_id=event_id).first() speaker = save_speaker( request, event_id=event_id, speaker=speaker, user=login.current_user if use_current_user else None ) new_session.speakers.append(speaker) save_to_db(new_session, "Session saved") if state == 'pending': trigger_new_session_notifications(new_session.id, event=event) if slide_temp_url != "" and slide_file: slide_url = upload( slide_file, UPLOAD_PATHS['sessions']['slides'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.slides = slide_url if audio_temp_url != "" and audio_file: audio_url = upload( audio_file, UPLOAD_PATHS['sessions']['audio'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.audio = audio_url if video_temp_url != "" and video_file: video_url = upload( video_file, UPLOAD_PATHS['sessions']['video'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.video = video_url record_activity('create_session', session=new_session, event_id=event_id) update_version(event_id, False, 'sessions_ver') invite_emails = form.getlist("speakers[email]") for index, email in enumerate(invite_emails): if not string_empty(email): new_invite = Invite(event_id=event_id, session_id=new_session.id) hash = random.getrandbits(128) new_invite.hash = "%032x" % hash save_to_db(new_invite, "Invite saved") link = url_for('event_sessions.invited_view', session_id=new_session.id, event_id=event_id, _external=True) Helper.send_email_invitation(email, new_session.title, link) # If a user is registered by the email, send a notification as well user = DataGetter.get_user_by_email(email, no_flash=True) if user: cfs_link = url_for('event_detail.display_event_cfs', identifier=event.identifier) Helper.send_notif_invite_papers(user, event.name, cfs_link, link)
def add_session_to_event(request, event_id, state=None, use_current_user=True, no_name=False): """ Session will be saved to database with proper Event id :param use_current_user: :param state: :param request: The request :param event_id: Session belongs to Event by event id """ form = request.form slide_temp_url = form.get('slides_url') video_temp_url = form.get('video_url') audio_temp_url = form.get('audio_url') slide_file = '' video_file = '' audio_file = '' if slide_temp_url: slide_file = UploadedFile(get_path_of_temp_url(slide_temp_url), slide_temp_url.rsplit('/', 1)[1]) if video_temp_url: video_file = UploadedFile(get_path_of_temp_url(video_temp_url), video_temp_url.rsplit('/', 1)[1]) if audio_temp_url: audio_file = UploadedFile(get_path_of_temp_url(audio_temp_url), audio_temp_url.rsplit('/', 1)[1]) if not state: state = form.get('state', 'draft') event = DataGetter.get_event(event_id) new_session = Session(title=form.get('title', ''), subtitle=form.get('subtitle', ''), long_abstract=form.get('long_abstract', ''), start_time=event.start_time, end_time=event.start_time + timedelta(hours=1), event_id=event_id, short_abstract=form.get('short_abstract', ''), level=form.get('level', ''), comments=form.get('comments', ''), language=form.get('language', ''), state=state) if form.get('track', None) != "": new_session.track_id = form.get('track', None) if form.get('session_type', None) != "": new_session.session_type_id = form.get('session_type', None) if form.get('email', '') != '': speaker = Speaker.query.filter_by(email=form.get('email', '')).filter_by(event_id=event_id).first() speaker = save_speaker( request, event_id=event_id, speaker=speaker, user=login.current_user if use_current_user else None, no_name=no_name ) new_session.speakers.append(speaker) save_to_db(new_session, "Session saved") if state == 'pending': trigger_new_session_notifications(new_session.id, event=event) if slide_temp_url != "" and slide_file: slide_url = upload( slide_file, UPLOAD_PATHS['sessions']['slides'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.slides = slide_url if audio_temp_url != "" and audio_file: audio_url = upload( audio_file, UPLOAD_PATHS['sessions']['audio'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.audio = audio_url if video_temp_url != "" and video_file: video_url = upload( video_file, UPLOAD_PATHS['sessions']['video'].format( event_id=int(event_id), id=int(new_session.id) )) new_session.video = video_url record_activity('create_session', session=new_session, event_id=event_id) update_version(event_id, False, 'sessions_ver') invite_emails = form.getlist("speakers[email]") for index, email in enumerate(invite_emails): if not string_empty(email): new_invite = Invite(event_id=event_id, session_id=new_session.id) hash = random.getrandbits(128) new_invite.hash = "%032x" % hash save_to_db(new_invite, "Invite saved") link = url_for('event_sessions.invited_view', session_id=new_session.id, event_id=event_id, _external=True) Helper.send_email_invitation(email, new_session.title, link) # If a user is registered by the email, send a notification as well user = DataGetter.get_user_by_email(email, no_flash=True) if user: cfs_link = url_for('event_detail.display_event_cfs', identifier=event.identifier) Helper.send_notif_invite_papers(user, event.name, cfs_link, link)