Skip to content

Commit

Permalink
enhancement issue #21
Browse files Browse the repository at this point in the history
  • Loading branch information
MonEstCha committed Jul 22, 2024
1 parent b4e477e commit 14cd053
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
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 PewSheetForm(FlaskForm):
title = HiddenField('Title')
Expand All @@ -38,6 +41,7 @@ class PewSheetForm(FlaskForm):
anthem_title = StringField('Anthem')
anthem_composer = StringField('Anthem composer')
anthem_lyrics = StringField('Anthem lyrics', widget=TextArea())
anthem_translation = SelectField('Anthem Translation', choices=translations)

class Meta:
csrf = False
Expand Down
11 changes: 8 additions & 3 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class Music:
composer: Optional[str] = field()
lyrics: Optional[str] = field()
ref: Optional[str] = field()
translation: Optional[str] = field()

@classmethod
def neh_hymns(cls) -> List['Music']:
Expand All @@ -203,7 +204,8 @@ def nehref2num(nehref: str) -> typing.Tuple[int, str]:
category='Hymn',
composer=None,
lyrics=None,
ref=f'NEH: {record.number}'
ref=f'NEH: {record.number}',
translation=f'Words/translation available at NEH: {record.number}, {record.firstLine}'
) for record in records
]
hymns.sort(key=lambda m: nehref2num(m.ref or ""))
Expand Down Expand Up @@ -419,7 +421,7 @@ def items(self) -> List[PewSheetItem]:

if self.anthem:
items.append(
ServiceItem('Anthem', [self.anthem.lyrics],
ServiceItem('Anthem', [self.anthem.lyrics, self.anthem.translation],
f'{self.anthem.title}. {self.anthem.composer}'))

if self.recessional_hymn:
Expand All @@ -444,11 +446,14 @@ def from_form(cls, form: 'PewSheetForm') -> 'Service':
composer=form.anthem_composer.data,
lyrics=form.anthem_lyrics.data,
category='Anthem',
ref=None
ref=None,
translation=form.anthem_translation.data
)
else:
anthem = None

print(form.anthem_translation.data)

return Service(
title=form.title.data,
date=form.date.data,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ python-dotenv~=0.21.0
python-slugify~=7.0.0
PyYAML~=6.0
WTForms~=3.0.1
setuptools~=50.3.2
setuptools~=71.1.0
openpyxl==3.0.9
Werkzeug~=2.2.2
14 changes: 14 additions & 0 deletions templates/serviceForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ <h3 id="titleH3"></h3>
</div>
</div>

<div class="row mb-3">
{{ form.anthem_translation.label(class='col-sm-2 col-form-label') }}
<div class="col-sm-5">
{{ form.anthem_translation(class='form-control') }}
{% if form.anthem_translation.errors %}
{% for error in form.anthem_translation.errors %}
<small class="font-small text-danger">
{{ error }}
</small>
{% endfor %}
{% endif %}
</div>
</div>

<div class="row mb-3">
{{ form.anthem_composer.label(class='col-sm-2 col-form-label') }}
<div class="col-sm-5">
Expand Down

0 comments on commit 14cd053

Please sign in to comment.