-
Notifications
You must be signed in to change notification settings - Fork 1
/
forms.py
47 lines (39 loc) · 1.51 KB
/
forms.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from flask import request
from flask_wtf import FlaskForm
from wtforms import DateField, HiddenField, SelectField, SelectMultipleField, \
StringField
from wtforms import (
TimeField,
)
from wtforms.validators import DataRequired
from wtforms.widgets import TextArea
from models import Feast, Music
hymns = [('', 'None')] + [(h.ref, f'{h.ref} - {h.title}') for h in
Music.neh_hymns()]
class PewSheetForm(FlaskForm):
title = HiddenField('Title')
feasts = Feast.upcoming()
feast_choices = [(feast.slug, feast.name) for feast in feasts]
primary_feast = SelectField(
'Primary Feast',
choices=feast_choices,
)
secondary_feasts = SelectMultipleField(
'Secondary Feasts',
choices=[('', '')] + feast_choices,
)
date = DateField('Date', validators=[DataRequired()])
time = TimeField('Time', validators=[DataRequired()])
celebrant = StringField('Celebrant')
preacher = StringField('Preacher')
introit_hymn = SelectField('Introit Hymn', choices=hymns)
offertory_hymn = SelectField('Offertory Hymn', choices=hymns)
recessional_hymn = SelectField('Recessional Hymn', choices=hymns)
anthem_title = StringField('Anthem')
anthem_composer = StringField('Anthem composer')
anthem_lyrics = StringField('Anthem lyrics', widget=TextArea())
class Meta:
csrf = False
# https://discord.com/channels/531221516914917387/590290790241009673/948217938459107339
def is_submitted(self):
return bool(request.args)