diff --git a/templates/pay_poster_add.html b/templates/pay_poster_action.html
similarity index 71%
rename from templates/pay_poster_add.html
rename to templates/pay_poster_action.html
index d5721027..6768bd32 100644
--- a/templates/pay_poster_add.html
+++ b/templates/pay_poster_action.html
@@ -1,7 +1,7 @@
{% extends "generic/base.html" %}
{% block title %}
- Upload a Pay Poster
+ {{ action }} a Pay Poster
{% endblock %}
{% block content %}
@@ -17,7 +17,11 @@
{{ form.movie.label(class_="label") }} {{ form.movie(size=32) }}
- {{ form.poster.label(class_="label") }} {{ form.poster(size=32) }}
+ {{ form.poster.label(class_="label") }}
+ {% if poster_id %}
+ {{ existing_image('poster', url_for('get_pay_poster', poster=poster_id)) }}
+ {% endif %}
+ {{ form.poster(size=32) }}
{{ form.upload(class_="button is-success") }}
diff --git a/templates/pay_poster_list.html b/templates/pay_poster_list.html index e66e707d..15b143ce 100644 --- a/templates/pay_poster_list.html +++ b/templates/pay_poster_list.html @@ -29,7 +29,7 @@
-
+
diff --git a/theunderground/forms.py b/theunderground/forms.py
index 958e6914..0a630055 100644
--- a/theunderground/forms.py
+++ b/theunderground/forms.py
@@ -200,8 +200,8 @@ class PosterForm(FlaskForm):
class PayPosterForm(FlaskForm):
title = StringField("Title", validators=[DataRequired(), Length(max=47)])
msg = StringField("Message", validators=[DataRequired(), Length(max=15)])
- poster = FileField("Poster", validators=[FileRequired()])
- movie = FileField("Movie", validators=[FileRequired()])
+ poster = FileField("Poster")
+ movie = FileField("Movie")
upload = SubmitField("Create Poster!")
diff --git a/theunderground/pay_posters.py b/theunderground/pay_posters.py
index 57a7a926..63ebc213 100644
--- a/theunderground/pay_posters.py
+++ b/theunderground/pay_posters.py
@@ -1,6 +1,7 @@
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from flask import render_template, flash, url_for, redirect
+from werkzeug import exceptions
from theunderground.forms import PayPosterForm
from theunderground.operations import manage_delete_item
@@ -8,6 +9,7 @@
from asset_data import PosterAsset, PayMovieAsset
from models import PayPosters, db
from room import app
+from flask_wtf.file import FileRequired
import os
@@ -34,6 +36,10 @@ def list_pay_posters():
def add_pay_poster():
form = PayPosterForm()
+ # Add the file validators
+ form.poster.validators = [FileRequired()]
+ form.movie.validators = [FileRequired()]
+
if form.validate_on_submit():
db_poster = PayPosters(
msg=form.msg.data, title=form.title.data, type=1, aspect=False
@@ -62,7 +68,43 @@ def add_pay_poster():
return redirect(url_for("list_pay_posters"))
- return render_template("pay_poster_add.html", form=form)
+ return render_template("pay_poster_action.html", form=form, action="Upload")
+
+
+@app.route("/theunderground/payposters/