Skip to content

Add bulk banning functionality to the admin#24939

Merged
diox merged 8 commits into
mozilla:masterfrom
diox:admin-mass-ban
May 26, 2026
Merged

Add bulk banning functionality to the admin#24939
diox merged 8 commits into
mozilla:masterfrom
diox:admin-mass-ban

Conversation

@diox
Copy link
Copy Markdown
Member

@diox diox commented May 22, 2026

Also make banning through the changelist action use the same async task underneath to scale to a larger number of users.

Fixes mozilla/addons#16224
Fixes mozilla/addons#15580

diox added 5 commits May 21, 2026 16:48
Also make banning through the changelist action use the
same async task underneath to scale to a larger number of users.
@diox diox marked this pull request as ready for review May 25, 2026 12:36
@diox diox requested a review from eviljeff May 25, 2026 12:36
Copy link
Copy Markdown
Member

@eviljeff eviljeff left a comment

Choose a reason for hiding this comment

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

I expected there to be ADMIN_USER_BANNED entries in activitylog but there wasn't - potentially because it's being run in the task?

Also some comments about cleaning/validation.

Comment thread src/olympia/users/forms.py Outdated

def clean_user_ids(self):
data = self.cleaned_data.get('user_ids', '')
user_ids = {id_ for id_ in data.splitlines() if id_.isdigit()}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We probably want to trim here too - a trailing space makes the number no longer isdigit() is True.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

data = self.cleaned_data.get('user_ids', '')
user_ids = {id_ for id_ in data.splitlines() if id_.isdigit()}
if not user_ids:
raise forms.ValidationError('This field must contain a least one user id')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do wonder if the form shouldn't raise on bad input rather than just silently ignore. I don't see a use case of Operations pasting in content with a mix of valid user ids and other random text they want to be ignored - accidentaly adding an extra character on the same line as a user id seems a more common case, that they would want to know about and correct.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

My reasoning was, it could be coming from a csv with headers and we should ignore those, but for the rest, the confirmation that shows how many users we found should be enough (Operations folks can ensure what they paste has unique ids to compare the number shown in the confirmation page with the number of lines from their input)

@diox

This comment was marked as resolved.

@diox diox requested a review from eviljeff May 26, 2026 13:41
@diox diox merged commit daf780b into mozilla:master May 26, 2026
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]: Allow Operations to mass ban users [Bug]: 502 error on django admin when banning multiple users at once

2 participants