From 241fba6a32b1791cb859abc6da27fada5faa5d1b Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 30 Mar 2017 16:30:04 +0200 Subject: [PATCH] filtering by true/false params added --- smash/web/api_views.py | 12 ++++++------ smash/web/templates/subjects/index.html | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/smash/web/api_views.py b/smash/web/api_views.py index 649c4f35..3fa93ecc 100644 --- a/smash/web/api_views.py +++ b/smash/web/api_views.py @@ -93,16 +93,16 @@ def get_subjects_filtered(subjects, filters): result = result.filter(nd_number__contains=value) elif column == "screening_number": result = result.filter(screening_number__contains=value) + elif column == "dead": + result = result.filter(dead=(value=="true")) + elif column == "resigned": + result = result.filter(resigned=(value=="true")) + elif column == "postponed": + result = result.filter(postponed=(value=="true")) else: print row # elif order_column == "default_location": # result = subjects.order_by(order_direction + 'default_location') - # elif order_column == "dead": - # result = subjects.order_by(order_direction + 'dead') - # elif order_column == "resigned": - # result = subjects.order_by(order_direction + 'resigned') - # elif order_column == "postponed": - # result = subjects.order_by(order_direction + 'postponed') return result diff --git a/smash/web/templates/subjects/index.html b/smash/web/templates/subjects/index.html index f203816c..f637cd23 100644 --- a/smash/web/templates/subjects/index.html +++ b/smash/web/templates/subjects/index.html @@ -59,8 +59,12 @@ <th> <div name="yes_no_filter">---</div> </th> - <th>Resigned</th> - <th>Postponed</th> + <th> + <div name="yes_no_filter">---</div> + </th> + <th> + <div name="yes_no_filter">---</div> + </th> </tr> </tfoot> @@ -114,6 +118,13 @@ .draw(); } }); + $('select', this.footer()).on('keyup change', function () { + if (that.search() !== this.value) { + that + .search(this.value) + .draw(); + } + }); }); }); </script> -- GitLab