Properly require files when users submit
This commit is contained in:
parent
204392362f
commit
03afc828ce
@ -15,6 +15,8 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from cgi import FieldStorage
|
||||||
|
|
||||||
from webob import Response, exc
|
from webob import Response, exc
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
|
||||||
@ -30,6 +32,12 @@ def submit_start(request):
|
|||||||
submit_form = submit_forms.SubmitStartForm(request.POST)
|
submit_form = submit_forms.SubmitStartForm(request.POST)
|
||||||
|
|
||||||
if request.method == 'POST' and submit_form.validate():
|
if request.method == 'POST' and submit_form.validate():
|
||||||
|
if not (request.POST.has_key('file')
|
||||||
|
and isinstance(request.POST['file'], FieldStorage)
|
||||||
|
and request.POST['file'].file):
|
||||||
|
submit_form.file.errors.append(
|
||||||
|
u'You must provide a file.')
|
||||||
|
else:
|
||||||
# create entry and save in database
|
# create entry and save in database
|
||||||
entry = request.db.MediaEntry()
|
entry = request.db.MediaEntry()
|
||||||
entry['title'] = request.POST['title']
|
entry['title'] = request.POST['title']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user