fix(parts): make the not-equals toggle work on theme and year

This commit is contained in:
2026-08-01 12:23:42 +02:00
parent 2d593fb500
commit b356df46b9
2 changed files with 18 additions and 8 deletions
+6 -6
View File
@@ -126,17 +126,17 @@ class BrickPartList(BrickRecordList[BrickPart]):
if current_app.config.get('HIDE_SPARE_PARTS', False):
context['skip_spare_parts'] = True
# Everything that is data rather than a column name gets bound
# Everything that is data rather than a column name gets bound. The query
# decides what "not this" means, so the value itself is bound without its
# leading "-".
self.filter_parameters = {}
for name in BOUND_FILTERS:
value = context.get(name)
if value is None:
continue
if name == 'storage_id':
if value in STORAGE_SENTINELS:
continue
value = without_negation(value)
self.filter_parameters[name] = value
if name == 'storage_id' and value in STORAGE_SENTINELS:
continue
self.filter_parameters[name] = without_negation(value)
if search_query:
self.filter_parameters['search_query'] = '%{query}%'.format(
+12 -2
View File
@@ -132,12 +132,22 @@ ON "combined"."id" IS NOT DISTINCT FROM "bricktracker_set_tags"."id"
{# Theme and year only exist for set sourced parts. The LEFT JOIN gives NULL for
everything else, and NULL = x is never true, so individual parts drop out on
their own. #}
{# The negated forms stay set only too. A part with no set behind it has no theme and
no year, so it is neither "from 2023" nor "from a year that is not 2023". #}
{% if theme_id %}
{% set _ = conditions.append('"rebrickable_sets"."theme_id" = :theme_id') %}
{% if theme_id.startswith('-') %}
{% set _ = conditions.append('"rebrickable_sets"."theme_id" IS NOT NULL AND "rebrickable_sets"."theme_id" != :theme_id') %}
{% else %}
{% set _ = conditions.append('"rebrickable_sets"."theme_id" = :theme_id') %}
{% endif %}
{% endif %}
{% if year %}
{% set _ = conditions.append('"rebrickable_sets"."year" = :year') %}
{% if year.startswith('-') %}
{% set _ = conditions.append('"rebrickable_sets"."year" IS NOT NULL AND "rebrickable_sets"."year" != :year') %}
{% else %}
{% set _ = conditions.append('"rebrickable_sets"."year" = :year') %}
{% endif %}
{% endif %}
{% if storage_id %}