Reduce to_learn, callable, review into one status field
This commit is contained in:
parent
507531fbff
commit
d1e99c51de
4 changed files with 84 additions and 29 deletions
|
|
@ -17,9 +17,7 @@ def list_tunes():
|
|||
instrument_id=1
|
||||
key=D
|
||||
tuning_id=1
|
||||
callable=true|false
|
||||
review=true|false
|
||||
to_learn=true|false
|
||||
status=callable|review|to_learn
|
||||
difficulty=easy|hard
|
||||
modal=true|false
|
||||
source_id=1
|
||||
|
|
@ -45,26 +43,17 @@ def list_tunes():
|
|||
|
||||
instrument_id = request.args.get("instrument_id")
|
||||
tuning = request.args.get("tuning")
|
||||
callable_ = request.args.get("callable")
|
||||
review = request.args.get("review")
|
||||
to_learn = request.args.get("to_learn")
|
||||
status = request.args.get("status")
|
||||
difficulty = request.args.get("difficulty")
|
||||
|
||||
def _bool(val):
|
||||
return val.lower() in ("true", "1", "yes")
|
||||
|
||||
if any([instrument_id, tuning, callable_, review, to_learn, difficulty]):
|
||||
if any([instrument_id, tuning, status, difficulty]):
|
||||
q = q.join(Tune.instruments)
|
||||
if instrument_id:
|
||||
q = q.filter(TuneByInstrument.instrument_id == int(instrument_id))
|
||||
if tuning:
|
||||
q = q.filter(TuneByInstrument.tuning_id == int(tuning))
|
||||
if callable_ is not None:
|
||||
q = q.filter(TuneByInstrument.callable == _bool(callable_))
|
||||
if review is not None:
|
||||
q = q.filter(TuneByInstrument.review == _bool(review))
|
||||
if to_learn is not None:
|
||||
q = q.filter(TuneByInstrument.to_learn == _bool(to_learn))
|
||||
if status:
|
||||
q = q.filter(TuneByInstrument.status == status)
|
||||
if difficulty:
|
||||
q = q.filter(TuneByInstrument.difficulty.ilike(difficulty))
|
||||
|
||||
|
|
@ -105,9 +94,7 @@ def create_tune():
|
|||
learned_from_id=inst_data.get("learned_from_id"),
|
||||
tuning_id=inst_data.get("tuning_id"),
|
||||
date_learned=inst_data.get("date_learned"),
|
||||
callable=inst_data.get("callable"),
|
||||
review=inst_data.get("review"),
|
||||
to_learn=inst_data.get("to_learn", False),
|
||||
status=inst_data.get("status"),
|
||||
difficulty=inst_data.get("difficulty"),
|
||||
)
|
||||
db.session.add(entry)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue