forked from j2logo/tutorial-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.py
More file actions
26 lines (18 loc) · 704 Bytes
/
forms.py
File metadata and controls
26 lines (18 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
AUTOR: Juanjo
FECHA DE CREACIÓN: 24/01/2019
"""
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import (StringField, SubmitField, TextAreaField, BooleanField)
from wtforms.validators import DataRequired, Length
class PostForm(FlaskForm):
title = StringField('Título', validators=[DataRequired(), Length(max=128)])
content = TextAreaField('Contenido')
post_image = FileField('Imagen de cabecera', validators=[
FileAllowed(['jpg', 'png'], 'Solo se permiten imágenes')
])
submit = SubmitField('Guardar')
class UserAdminForm(FlaskForm):
is_admin = BooleanField('Administrador')
submit = SubmitField('Guardar')