-
Notifications
You must be signed in to change notification settings - Fork 555
Add bulk banning functionality to the admin #24939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5c7a43f
Add bulk banning functionality to the admin
diox 5388c2e
First pass of tests/fixes
diox 541b6d0
Should be a task
diox 7ef1d85
Avoiding create_chunked_signatures
diox 250b24e
Tests
diox 566ccb8
Record the user responsible for triggering the bulk ban
diox c724247
Trim whitespace
diox aac0dcc
Strip whitespace on each line
diox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/olympia/users/templates/admin/users/userprofile/bulk_ban.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {% extends "admin/base_site.html" %} | ||
| {% load i18n admin_urls static %} | ||
|
|
||
| {% block extrahead %} | ||
| {{ block.super }} | ||
| {{ media }} | ||
| <script src="{% static 'admin/js/cancel.js' %}" async></script> | ||
| {% endblock %} | ||
|
|
||
| {% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} bulk-ban-confirmation{% endblock %} | ||
|
|
||
| {% block breadcrumbs %} | ||
| <div class="breadcrumbs"> | ||
| <a href="{% url 'admin:index' %}">Home</a> | ||
| › <a href="{% url 'admin:app_list' app_label=opts.app_label %}">{{ opts.app_config.verbose_name }}</a> | ||
| › <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a> | ||
| › Bulk ban | ||
| </div> | ||
| {% endblock %} | ||
|
|
||
| {% block content %} | ||
| <form method="post"> | ||
| {% csrf_token %} | ||
| {% if user_ids_to_ban %} | ||
| <p>You're about to bulk-ban {{ user_ids_to_ban|length }} user(s). Are you sure ?</p> | ||
| {{ form.as_p }} | ||
| <input type="hidden" name="post" value="yes"> | ||
| <input type="submit" value="Yes, I'm sure"> | ||
| <a href="#" class="button cancel-link">No, take me back</a> | ||
| {% else %} | ||
| <p>Paste user ids to ban below, separated by newlines (only lines containing digits will be considered). A confirmation will be displayed on the next page.</p> | ||
| {{ form.as_p }} | ||
| <input type="submit" value="Submit"> | ||
| {% endif %} | ||
| </form> | ||
| {% endblock content %} |
12 changes: 12 additions & 0 deletions
12
src/olympia/users/templates/admin/users/userprofile/change_list_object_tools.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| {% extends "admin/change_list_object_tools.html" %} | ||
| {% load i18n admin_urls %} | ||
|
|
||
| {% block object-tools-items %} | ||
| {{ block.super }} | ||
| {% if has_users_ban_permission %} | ||
| <li> | ||
| {% url 'admin:users_userprofile_bulk_ban' as ban_url %} | ||
| <a href="{{ ban_url }}">Bulk ban</a> | ||
| </li> | ||
| {% endif %} | ||
| {% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)