Skip to content

Commit

Permalink
Merge branch 'issue_544_include_unknowns_in_term_listing' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Dec 23, 2024
2 parents e76803f + 0265ddb commit 5d12302
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
42 changes: 19 additions & 23 deletions lute/templates/term/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@
<td>Status range</td>
<td>
<select id="filtStatusMin">
<option value=0>(all)</option>
<option value=1>New (1)</option>
<option value=2>New (2)</option>
<option value=3>Learn (3)</option>
<option value=4>Learn (4)</option>
<option value=5>Learned</option>
<option value=99>Well Known</option>
<option value="0" selected>Unknown</option>
<option value="1">New (1)</option>
<option value="2">New (2)</option>
<option value="3">Learn (3)</option>
<option value="4">Learn (4)</option>
<option value="5">Learned</option>
<option value="99">Well Known</option>
</select>
to
<select id="filtStatusMax">
<option value=0>(all)</option>
<option value=1>New (1)</option>
<option value=2>New (2)</option>
<option value=3>Learn (3)</option>
<option value=4>Learn (4)</option>
<option value=5>Learned</option>
<option value=99>Well Known</option>
<option value="0">Unknown</option>
<option value="1">New (1)</option>
<option value="2">New (2)</option>
<option value="3">Learn (3)</option>
<option value="4">Learn (4)</option>
<option value="5">Learned</option>
<option value="99" selected>Well Known</option>
</select>
</td>
</tr>
Expand Down Expand Up @@ -344,18 +344,15 @@
store = JSON.parse(fs);
$('#filterControls').css('display', store.filtDisplay);

if (store.filtDisplay == 'none')
return;

$('#showHideFilters').prop('src', "{{ url_for('static', filename='icn/minus-button.png') }}");
$('#filtLanguage').val(parseInt(store.filtLanguage ?? '0'));
$('#filtParentsOnly').prop('checked', store.filtParentsOnly ?? false);
if ((store.filtAgeMin ?? '') != '')
$('#filtAgeMin').val(parseInt(store.filtAgeMin));
if ((store.filtAgeMax ?? '') != '')
$('#filtAgeMax').val(parseInt(store.filtAgeMax));
$('#filtStatusMin').val(parseInt(store.filtStatusMin));
$('#filtStatusMax').val(parseInt(store.filtStatusMax));
$('#filtStatusMin').val(parseInt(store.filtStatusMin ?? '1'));
$('#filtStatusMax').val(parseInt(store.filtStatusMax ?? '99'));
$('#filtIncludeIgnored').prop('checked', store.filtIncludeIgnored);
};

Expand All @@ -364,8 +361,7 @@
const is_hidden = (fc.css('display') == 'none');
const new_src = is_hidden ? "{{ url_for('static', filename='icn/minus-button.png') }}" : "{{ url_for('static', filename='icn/plus-button.png') }}";
$('#showHideFilters').prop('src', new_src);
if (! is_hidden)
handle_clear_filters();
handle_clear_filters();
fc.css('display', is_hidden ? 'block' : 'none');
handle_filter_update();
};
Expand All @@ -375,8 +371,8 @@
$('#filtParentsOnly').prop('checked', false);
$('#filtAgeMin').val('');
$('#filtAgeMax').val('');
$('#filtStatusMin').val(0);
$('#filtStatusMax').val(0);
$('#filtStatusMin').val(1);
$('#filtStatusMax').val(99);
$('#filtIncludeIgnored').prop('checked', false);
handle_filter_update();
};
Expand Down
18 changes: 8 additions & 10 deletions lute/term/datatables.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,15 @@ def get_data_tables_list(parameters, session):
if age_max:
wheres.append(f"{sql_age_calc} <= {int(age_max)}")

status_wheres = ["StID not in (0, 98)"]
status_min = int(parameters["filtStatusMin"])
status_max = int(parameters["filtStatusMax"])
if status_min > 0:
status_wheres.append(f"StID >= {status_min}")
if status_max > 0:
status_wheres.append(f"StID <= {status_max}")
status_wheres = " AND ".join(status_wheres)
st_range = ["StID != 98"]
status_min = int(parameters.get("filtStatusMin", "0"))
status_max = int(parameters.get("filtStatusMax", "99"))
st_range.append(f"StID >= {status_min}")
st_range.append(f"StID <= {status_max}")
st_where = " AND ".join(st_range)
if parameters["filtIncludeIgnored"] == "true":
status_wheres = f"({status_wheres} OR StID = 98)"
wheres.append(status_wheres)
st_where = f"({st_where} OR StID = 98)"
wheres.append(st_where)

# Phew.
return DataTablesSqliteQuery.get_data(
Expand Down
8 changes: 6 additions & 2 deletions tests/acceptance/lute_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def get_term_table_content(self):
self.visit("/")
self.browser.find_by_css("#menu_terms").mouse_over()
self.browser.find_by_id("term_index").first.click()
css = "#termtable tbody tr"

# clear any filters!
self.browser.find_by_id("showHideFilters").first.click()

# The last column of the table is the "date added", but that's
# a hassle to check, so ignore it.
Expand All @@ -271,8 +273,10 @@ def _to_string(row):
return ret
return "; ".join(rowtext[:-1]).strip()

css = "#termtable tbody tr"
rows = list(self.browser.find_by_css(css))
return "\n".join([_to_string(row) for row in rows])
rowstring = [_to_string(row) for row in rows]
return "\n".join(rowstring)

################################3
# Reading/rendering
Expand Down

0 comments on commit 5d12302

Please sign in to comment.