Skip to content

Conversation

@diox
Copy link
Member

@diox diox commented Oct 3, 2025

Fixes mozilla/addons#15831

Context

All fairly straightforward - just a couple annoyances:

  • Filters inheriting from django's FieldListFilter will get their title attribute set in __init__, hence the need for the custom __init__ method in the new classes - we already did that for existing filters
  • We didn't have a base numeric range filter class. Like with the date one, we don't want the JavaScript bits the one in rangefilter brings, so we need a custom template & fake choices, exactly like we already do for the date one (see amo.admin.DateRangeFilter)
  • Addon.last_updated is set automatically in addon_factory(), using the normal code to compute it, which depends on File.datestatuschanged. That field had auto_now_add so it couldn't be set by the factory, I had to change it to default=timezone.now to allow that.

@diox diox marked this pull request as ready for review October 3, 2025 16:36
@diox diox requested a review from eviljeff October 3, 2025 16:36
@diox diox force-pushed the scanners-query-results-more-filters branch from 0b71034 to 930bf98 Compare October 3, 2025 17:53
"""

template = 'admin/amo/numeric_range_filter.html'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing the label tags were empty (the label tag existed, but there was no text value). Date range filter fields get "To" and "From" labels; numeric range filter fields did not - though the placeholder texts did say "To" and "From".

Do you need to override _get_form_fields too?

At that point, you probably want to inherit from DateRangeFilter, or a common ancestor - it's worth considering anyway as your choices seems to be a direct copy and paste.

choices=STATUS_CHOICES.items(), default=amo.STATUS_AWAITING_REVIEW
)
datestatuschanged = models.DateTimeField(null=True, auto_now_add=True)
datestatuschanged = models.DateTimeField(null=True, default=timezone.now)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not saying this is a bad change to make ... but we could just special case datestatuschanged field in file_factory - pop the value and set it after the create, and so avoid any database/model change to prod.

@willdurand willdurand self-requested a review October 13, 2025 08:42
Copy link
Member

@willdurand willdurand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine

@eviljeff eviljeff merged commit 8b41d3f into mozilla:master Oct 14, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Add additional filters to scanners query rules

3 participants