Ejemplo n.º 1
0
def video_edit(channel, playlist, video):
    """
    Edit video
    """
    if playlist != video.playlist:
        # This video isn't in this playlist. Redirect to canonical URL
        return redirect(video.url_for('edit'))

    form = VideoEditForm(obj=video)
    formvideo = VideoVideoForm(obj=video)
    formslides = VideoSlidesForm(obj=video)
    form_id = request.form.get('form.id')
    if request.method == "POST":
        if form_id == u'video':  # check whether done button is clicked
            if form.validate_on_submit():
                form.populate_obj(video)
                video.make_name()
                db.session.commit()
                flash(u"Edited video '%s'." % video.title, 'success')
                return render_redirect(video.url_for(), code=303)
        elif form_id == u'video_url':  # check video_url was updated
            if formvideo.validate_on_submit():
                formvideo.populate_obj(video)
                process_video(video, new=False)
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'slide_url':  # check slides_url was updated
            if formslides.validate_on_submit():
                formslides.populate_obj(video)
                process_slides(video)
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
    speakers = [
        plv.playlist.channel
        for plv in PlaylistVideo.query.filter_by(video=video)
        if plv.playlist.auto_type == PLAYLIST_AUTO_TYPE.SPEAKING_IN
    ]
    return render_template('videoedit.html',
                           channel=channel,
                           playlist=playlist,
                           video=video,
                           form=form,
                           formvideo=formvideo,
                           formslides=formslides,
                           speakers=speakers)
Ejemplo n.º 2
0
def video_edit(channel, playlist, video):
    """
    Edit video
    """
    if playlist != video.playlist:
        # This video isn't in this playlist. Redirect to canonical URL
        return redirect(video.url_for('edit'))

    form = VideoEditForm(obj=video)
    formvideo = VideoVideoForm(obj=video)
    formslides = VideoSlidesForm(obj=video)
    form_id = request.form.get('form.id')
    if request.method == "POST":
        if form_id == u'video':  # check whether done button is clicked
            if form.validate_on_submit():
                form.populate_obj(video)
                video.make_name()
                db.session.commit()
                flash(u"Edited video '%s'." % video.title, 'success')
                return render_redirect(video.url_for(), code=303)
        elif form_id == u'video_url':  # check video_url was updated
            if formvideo.validate_on_submit():
                formvideo.populate_obj(video)
                process_video(video, new=False)
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'slide_url':  # check slides_url was updated
            if formslides.validate_on_submit():
                formslides.populate_obj(video)
                process_slides(video)
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
    speakers = [plv.playlist.channel for plv in PlaylistVideo.query.filter_by(video=video) if plv.playlist.auto_type == PLAYLIST_AUTO_TYPE.SPEAKING_IN]
    return render_template('videoedit.html',
        channel=channel,
        playlist=playlist,
        video=video,
        form=form,
        formvideo=formvideo,
        formslides=formslides,
        speakers=speakers)
Ejemplo n.º 3
0
def video_edit(channel, playlist, video):
    """
    Edit video
    """
    if playlist != video.playlist:
        # This video isn't in this playlist. Redirect to canonical URL
        return redirect(video.url_for('edit'))

    form = VideoEditForm(obj=video)
    formvideo = VideoVideoForm(obj=video)
    formslides = VideoSlidesForm(obj=video)
    formsync = VideoSlidesSyncForm(obj=video)
    form_id = request.form.get('form.id')
    if request.method == "POST":
        if form_id == u'video':  # check whether done button is clicked
            if form.validate_on_submit():
                form.populate_obj(video)
                video.make_name()
                db.session.commit()
                flash(u"Edited video '%s'." % video.title, 'success')
                return render_redirect(video.url_for(), code=303)
        elif form_id == u'video_url':  # check video_url was updated
            if formvideo.validate_on_submit():
                formvideo.populate_obj(video)
                try:
                    process_video(video, new=False)
                except (DataProcessingError, ValueError) as e:
                    flash(e.message, category="error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'slide_url':  # check slides_url was updated
            if formslides.validate_on_submit():
                formslides.populate_obj(video)
                try:
                    process_slides(video)
                    if video.video_slides_mapping:
                        video.video_slides_mapping_json = make_presentz_json(video, json.loads(video.video_slides_mapping))
                except (DataProcessingError, ValueError) as e:
                    flash(e.message, category="error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'video_slides_sync':
            if formsync.validate_on_submit():
                formsync.populate_obj(video)
                try:
                    if video.video_slides_mapping:
                        video.video_slides_mapping_json = make_presentz_json(video, json.loads(video.video_slides_mapping))
                    else:
                        flash(u"No value found for syncing video and slides", "error")
                except ValueError:
                    flash(u"SyntaxError in video slides mapping value", "error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)

    speakers = [plv.playlist.channel for plv in PlaylistVideo.query.filter_by(video=video) if plv.playlist.auto_type == PLAYLIST_AUTO_TYPE.SPEAKING_IN]
    return render_template('videoedit.html',
        channel=channel,
        playlist=playlist,
        video=video,
        form=form,
        formvideo=formvideo,
        formslides=formslides,
        formsync=formsync,
        speakers=speakers,
        autocomplete_url=lastuser.endpoint_url(lastuser.getuser_autocomplete_endpoint),
        slideshare_unique_value=get_slideshare_unique_value(video.slides_url) if video.slides_source == u'slideshare' else None)
Ejemplo n.º 4
0
def video_edit(channel, playlist, video):
    """
    Edit video
    """
    if playlist != video.playlist:
        # This video isn't in this playlist. Redirect to canonical URL
        return redirect(video.url_for('edit'))

    form = VideoEditForm(obj=video)
    formvideo = VideoVideoForm(obj=video)
    formslides = VideoSlidesForm(obj=video)
    formsync = VideoSlidesSyncForm(obj=video)
    form_id = request.form.get('form.id')
    if request.method == "POST":
        if form_id == u'video':  # check whether done button is clicked
            if form.validate_on_submit():
                form.populate_obj(video)
                video.make_name()
                db.session.commit()
                flash(u"Edited video '%s'." % video.title, 'success')
                return render_redirect(video.url_for(), code=303)
        elif form_id == u'video_url':  # check video_url was updated
            if formvideo.validate_on_submit():
                formvideo.populate_obj(video)
                try:
                    process_video(video, new=False)
                except (DataProcessingError, ValueError) as e:
                    flash(e.message, category="error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'slide_url':  # check slides_url was updated
            if formslides.validate_on_submit():
                formslides.populate_obj(video)
                try:
                    process_slides(video)
                    if video.video_slides_mapping:
                        video.video_slides_mapping_json = make_presentz_json(
                            video, json.loads(video.video_slides_mapping))
                except (DataProcessingError, ValueError) as e:
                    flash(e.message, category="error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)
        elif form_id == u'video_slides_sync':
            if formsync.validate_on_submit():
                formsync.populate_obj(video)
                try:
                    if video.video_slides_mapping:
                        video.video_slides_mapping_json = make_presentz_json(
                            video, json.loads(video.video_slides_mapping))
                    else:
                        flash(u"No value found for syncing video and slides",
                              "error")
                except ValueError:
                    flash(u"SyntaxError in video slides mapping value",
                          "error")
                db.session.commit()
                return render_redirect(video.url_for('edit'), code=303)

    speakers = [
        plv.playlist.channel
        for plv in PlaylistVideo.query.filter_by(video=video)
        if plv.playlist.auto_type == PLAYLIST_AUTO_TYPE.SPEAKING_IN
    ]
    return render_template(
        'videoedit.html.jinja2',
        channel=channel,
        playlist=playlist,
        video=video,
        form=form,
        formvideo=formvideo,
        formslides=formslides,
        formsync=formsync,
        speakers=speakers,
        autocomplete_url=lastuser.endpoint_url(
            lastuser.getuser_autocomplete_endpoint),
        slideshare_unique_value=get_slideshare_unique_value(video.slides_url)
        if video.slides_source == u'slideshare' else None)