Skip to content

Commit

Permalink
fix: allow None for columns.default; remove debug log statement
Browse files Browse the repository at this point in the history
fix occasional error that appears particularly on new processors with no expected default, i.e.:
<option value="{{ choice }}"{% if choice in option_settings.default %} selected="selected"{% endif %}>{{ option_settings.options[choice] }}</option>
TypeError: argument of type 'NoneType' is not iterable
  • Loading branch information
dale-wahl committed Jan 22, 2025
1 parent b60e8cf commit a1cdd4c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion processors/filtering/unique_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ def get_options(cls, parent_dataset=None, user=None):
columns = parent_dataset.get_columns()
options["columns"]["type"] = UserInput.OPTION_MULTI
options["columns"]["options"] = {v: v for v in columns}
options["columns"]["default"] = "body" if "body" in columns else None
options["columns"]["default"] = "body" if "body" in columns else ""

return options
2 changes: 0 additions & 2 deletions webtool/static/js/fourcat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1851,8 +1851,6 @@ const ui_helpers = {
const other_field = 'option-' + requirement[1];
const other_element = form.querySelector("*[name='" + other_field + "']");

console.log(other_field);

if (!other_element) { //invalid reference
return;
}
Expand Down
4 changes: 2 additions & 2 deletions webtool/templates/components/processor-option.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
<div class="multichoice-wrapper{% if option_settings.inline %} inline{% endif %}" style="flex-basis: 100%;">
<select name="option-{{ option }}" multiple="multiple">
{% for choice in option_settings.options %}
<option value="{{ choice }}"{% if choice in option_settings.default %} selected="selected"{% endif %}>{{ option_settings.options[choice] }}</option>
<option value="{{ choice }}"{% if option_settings.default and choice in option_settings.default %} selected="selected"{% endif %}>{{ option_settings.options[choice] }}</option>
{% endfor %}
</select>
</div>
{% elif option_settings.type == "multi_select" %}
<div class="multi-select-wrapper">
<select name="option-{{ option }}" multiple="multiple">
{% for choice in option_settings.options %}
<option value="{{ choice }}"{% if choice in option_settings.default %} selected="selected"{% endif %}>{{ option_settings.options[choice] }}</option>
<option value="{{ choice }}"{% if option_settings.default and choice in option_settings.default %} selected="selected"{% endif %}>{{ option_settings.options[choice] }}</option>
{% endfor %}
</select>
</div>
Expand Down

0 comments on commit a1cdd4c

Please sign in to comment.