-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforms.py
54 lines (45 loc) · 1.77 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
48
49
50
51
52
53
54
from flask import request
from flask_wtf import FlaskForm, Form
from wtforms import DateField, HiddenField, SelectField, SelectMultipleField, \
StringField
from wtforms import (
TimeField,
FormField
)
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()]
translations = [('', 'None')] + [(h.translation, f'{h.translation}') for h in
Music.neh_hymns()]
class AnthemForm(Form):
title = StringField('Anthem')
composer = StringField('Anthem composer')
lyrics = StringField('Anthem lyrics', widget=TextArea())
translation = SelectField('Anthem Translation', choices=translations)
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_group = FormField(AnthemForm)
class Meta:
csrf = False
# https://discord.com/channels/531221516914917387/590290790241009673/948217938459107339
def is_submitted(self):
return bool(request.args)