distribusi-verse/verse/describer/forms/describe_files_form.py

42 lines
1.1 KiB
Python
Raw Normal View History

2024-05-27 17:25:27 +02:00
"""Describe File Form to describe files in the distribusi archive"""
from flask_wtf import FlaskForm
2024-11-25 15:00:09 +01:00
from wtforms import StringField, SubmitField
2024-05-27 17:25:27 +02:00
from wtforms.validators import Length
from wtforms.widgets import TextArea
class DescribeFilesForm(FlaskForm):
2024-05-28 23:02:17 +02:00
"""DescribeFileForm selection form."""
2024-05-27 17:25:27 +02:00
2024-05-28 23:02:17 +02:00
alttext = StringField(
"Alt-text for this file:",
validators=[
Length(3, 255),
],
)
searchtags = StringField(
"Add search tags, seperated by commas. No need for the '#' sign:",
validators=[
Length(3, 500),
],
)
description = StringField(
"Description of this file:",
validators=[
Length(3, 4096),
],
widget=TextArea(),
)
save = SubmitField("Save")
2024-05-27 17:25:27 +02:00
2024-05-28 23:02:17 +02:00
def __init__(self, id, file_path=None, type=None):
super(DescribeFilesForm, self).__init__()
self.id = id
self.file_path = file_path
self.type = type
self.alttext.id = f"alttext-{id}"
self.searchtags.id = f"searchtags-{id}"
self.description.id = f"description-{id}"
self.save.id = f"save-{id}"