Add player choice to episode editor.

This commit is contained in:
2019-02-19 21:10:27 +01:00
parent b2f06fa9a1
commit 41ee32646c
4 changed files with 42 additions and 27 deletions

View File

@@ -13,6 +13,15 @@ def season_choices():
return choices
def player_choice():
"""
Query database for a list of available players to bind them to a select box
"""
sql, args = db.load_players()
players = db.query_db(sql, args, cls=models.Player)
return [(p.id, p.name) for p in players]
class SeasonChoicesIterable:
"""
This is used to declare choices for WTForms SelectFields at class definition time.
@@ -22,3 +31,14 @@ class SeasonChoicesIterable:
def __iter__(self):
for choice in season_choices():
yield choice
class PlayerChoiceIterable:
"""
This is used to declare choices for WTForms SelectFields at class definition time.
Be aware that this uses an undocumented WTForms feature and is not guaranteed to work.
"""
def __iter__(self):
for choice in player_choice():
yield choice