crunk
6 months ago
7 changed files with 95 additions and 52 deletions
@ -1,29 +0,0 @@ |
|||
"""Describe File Form to describe files in the distribusi archive""" |
|||
|
|||
from flask_wtf import FlaskForm |
|||
from wtforms import StringField, SubmitField, validators |
|||
from wtforms.validators import Length |
|||
|
|||
|
|||
class DescribeFileForm(FlaskForm): |
|||
"""DescribeFileForm selection form.""" |
|||
|
|||
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), |
|||
], |
|||
) |
|||
save = SubmitField("Save") |
@ -0,0 +1,47 @@ |
|||
"""Describe File Form to describe files in the distribusi archive""" |
|||
|
|||
from flask_wtf import FlaskForm |
|||
from wtforms import StringField, SubmitField, validators |
|||
from wtforms.validators import Length |
|||
from wtforms.widgets import TextArea |
|||
|
|||
|
|||
class DescribeFilesForm(FlaskForm): |
|||
"""DescribeFileForm selection form.""" |
|||
|
|||
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") |
|||
|
|||
def __init__(self, id, file_path=None): |
|||
super(DescribeFilesForm, self).__init__() |
|||
self.id = id |
|||
self.file_path = file_path |
|||
self.alttext.id = f"alttext-{id}" |
|||
self.searchtags.id = f"searchtags-{id}" |
|||
self.description.id = f"description-{id}" |
|||
self.save.id = f"save-{id}" |
|||
|
|||
|
|||
# def StringFieldWithId(form_name, **kwargs): |
|||
# name = kwargs.get('name', 'Bar') |
|||
# return wtf.StringField(name, render_kw={ |
|||
# 'id': f'{}{}'.format(form_name, name.lower(), |
|||
# **kwargs.get('render_kw', {})}) |
Loading…
Reference in new issue