Exemplo n.º 1
0
def update_recap(post_id):
    post = Post.query.get_or_404(post_id)
    if post.author != current_user:
        abort(403)

    form = RecapForm()
    if form.validate_on_submit():
        post.title = f"{form.category.data} Div {', '.join(form.division.data)} - Week {form.week.data}"
        post.content = form.content.data
        post.category = form.category.data
        post.shortdesc = form.shortdesc.data
        post.video = form.video.data
        videoinput = form.video.data
        post.videoimg = parse_video_img(videoinput)
        post.videourl = parse_video_url(videoinput)
        post.division = ", ".join(form.division.data)
        post.week = form.week.data
        db.session.commit()
        flash("Your Recap Video has been updated!", "success")
        return redirect(url_for("posts.postslug", post_slug=post.slug))
    elif request.method == "GET":
        form.content.data = post.content
        form.shortdesc.data = post.shortdesc
        form.category.data = post.category
        form.video.data = post.video
        form.division.data = post.division.split(", ")
        form.week.data = post.week
    return render_template(
        "create_recap.html",
        title="Update Video Recap",
        form=form,
        legend="Update Video Recap",
    )
Exemplo n.º 2
0
def new_recap():
    form = RecapForm()
    if form.validate_on_submit():
        videoinput = form.video.data
        title_str = f"{form.category.data} Div {', '.join(form.division.data)} - Week {form.week.data}"
        post = Post(
            title=title_str,
            category=form.category.data,
            content=form.content.data,
            shortdesc=form.shortdesc.data,
            video=form.video.data,
            videoimg=parse_video_img(videoinput),
            videourl=parse_video_url(videoinput),
            division=", ".join(form.division.data),
            week=form.week.data,
            author=current_user,
            post_type="recap",
            published=False,
            sidebar=True,
        )
        db.session.add(post)
        db.session.commit()
        post.slug = slugify(str(title_str), max_length=35).lower() + "-" + str(
            post.id)
        db.session.commit()
        flash("Your Recap Video has been added!", "success")
        return redirect(url_for("posts.postslug", post_slug=post.slug))
    return render_template(
        "create_recap.html",
        title="New Video Recap",
        form=form,
        legend="New Video Recap",
    )
Exemplo n.º 3
0
def new_video():
    form = VideoForm()
    if form.validate_on_submit():
        # Insert logic to parse out video unique identifier to store as video
        videoinput = form.video.data
        post = Post(
            title=form.title.data,
            category=form.category.data,
            shortdesc=form.shortdesc.data,
            content=form.content.data,
            video=form.video.data,
            # post.videotype = form.videotype.data,
            videoimg=parse_video_img(videoinput),
            videourl=parse_video_url(videoinput),
            author=current_user,
            post_type="video",
            published=False,
            sidebar=True,
        )
        db.session.add(post)
        db.session.commit()
        post.slug = slugify(form.title.data,
                            max_length=35).lower() + "-" + str(post.id)
        db.session.commit()
        flash("Your video has been added!", "success")
        return redirect(url_for("posts.postslug", post_slug=post.slug))
    return render_template("create_video.html",
                           title="New Video Post",
                           form=form,
                           legend="New Video Post")
Exemplo n.º 4
0
def update_video(post_id):
    post = Post.query.get_or_404(post_id)
    if post.author != current_user:
        abort(403)

    form = VideoForm()
    if form.validate_on_submit():
        post.title = form.title.data
        post.content = form.content.data
        post.category = form.category.data
        post.shortdesc = form.shortdesc.data
        post.video = form.video.data
        videoinput = form.video.data
        post.videoimg = parse_video_img(videoinput)
        post.videourl = parse_video_url(videoinput)
        db.session.commit()
        flash("Your video post has been updated!", "success")
        return redirect(url_for("posts.postslug", post_slug=post.slug))
    elif request.method == "GET":
        form.title.data = post.title
        form.content.data = post.content
        form.category.data = post.category
        form.shortdesc.data = post.shortdesc
        form.video.data = post.video
    return render_template(
        "create_video.html",
        title="Update Video Post",
        form=form,
        legend="Update Video Post",
    )
Exemplo n.º 5
0
from slugify import slugify

app = create_app()
app.app_context().push()

df = pd.read_excel('flaskblog/Recap_Links.xlsx')

for index, row in df.iterrows():
    videoinput = row['Link']
    title_str = f'{row["Region"]} - Division {row["Division"]} - Week {row["Week"]}'
    user = User.query.filter_by(id=140).first()
    post = Post(
        title = title_str,
        category= row['Region'],
        content = "",
        shortdesc = row['Short Description'],
        video = videoinput,
        videoimg = parse_video_img(videoinput),
        videourl = parse_video_url(videoinput),
        division = row["Division"],
        week = row["Week"],
        author = user,
    )
    post.post_type = "recap"
    post.published = True
    post.sidebar = True
    db.session.add(post)
    db.session.commit()
    post.slug = slugify(title_str, max_length=35).lower() + "-" + str(post.id)
    db.session.commit()