-
Notifications
You must be signed in to change notification settings - Fork 512
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
AO3-6672 Allow some admins to set a generic username #4994
base: master
Are you sure you want to change the base?
AO3-6672 Allow some admins to set a generic username #4994
Conversation
If you're up for changing copy in a whole bunch of places, I'm up for testing! We ultimately want to switch from "user name" to "username" but it's in soooo many places I didn't want to inflict that on anyone. I think this covers all the references to this page so we could at least have some consistency in this area:
|
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.
Just a couple quick frontend suggestions since we were talking about text changes!
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.
Besides the comments I left, I think it would be good to have a feature test that goes through renaming a user as an admin. Just to make sure nothing gets missed because the specs test pretty close to the implementation itself.
end | ||
|
||
it_behaves_like "an action only authorized admins can access", authorized_roles: %w[superadmin policy_and_abuse] do | ||
let(:user) { create(:user, banned: true) } |
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.
Why a banned user?
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.
Non-exhaustive checking that users who cannot access this page themselves can be renamed by an admin
end | ||
|
||
it "does not prevent changing the username" do | ||
allow(existing_user).to receive(:justification_enabled?).and_return(false) |
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.
What about ticket_number?
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.
Since https://github.com/otwcode/otwarchive/pull/4994/files#diff-a55bf747ae62cffdcdb15d898d6bde2ab06b44df40317d8c44330e1615b6c50fR133 already tests that, I disabled the ticket_number
requirement here. I'd rather not turn it back on, because we have to mock quite a few things to make the Zoho validation happy
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 was reviewing in two tabs simultaneously so I could go back and forth between the views and the locales, so I'm sure this will be quality. If anything is confusing or contradictory, my bad, please yell!
app/models/user.rb
Outdated
@@ -564,11 +572,25 @@ def reindex_user_creations_after_rename | |||
end | |||
|
|||
def add_renamed_at | |||
return if User.current_user.is_a?(Admin) |
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 agree with Brian here. Since we're already supposed to be ignoring the renamed_at
when an admin goes to change a name, I think it makes sense that admin renames just ignore the renamed_at
entirely.
However, we could add a separate admin_renamed_at
column to the users
table for general tracking purposes. That does feel like something that could be both useful and clarifying if you're looking at an audit or just a user in the database.
@@ -1,29 +1,29 @@ | |||
<dl> | |||
<dt>Sender</dt> | |||
<dd><%= creator_link(invitation) %></dd> | |||
<dd><%= creator_link(@invitation) %></dd> |
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 needed to make changes here to fix issues with how @invitation
is referenced (locals
versus just passing it in). For everyone's sanity, I'll do the rest of the erb lint fixes in #5000 since that has most of them already anyways
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.
Thank you!
<!--/descriptions--> | ||
|
||
<!--subnav--> | ||
<!--/subnav--> | ||
|
||
<!--main content--> | ||
<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => 'find'), :method => :get do %> | ||
<%= form_tag url_for(controller: "admin/admin_invitations", action: "find"), autocomplete: "off", method: :get do %> |
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.
Since we're now updating the actual form
tags, let's add the classes that are missing on so many forms:
<%= form_tag url_for(controller: "admin/admin_invitations", action: "find"), autocomplete: "off", method: :get do %> | |
<%= form_tag url_for(controller: "admin/admin_invitations", action: "find"), autocomplete: "off", class: "invitation simple search", method: :get do %> |
<dd><%= text_field_tag "invitation[user_name]", params[:invitation][:user_name] %></dd> | ||
<dt><%= label_tag "invitation[token]", t(".token") %></dt> | ||
<dd><%= text_field_tag "invitation[token]", params[:invitation][:token] %></dd> | ||
<dt><%= label_tag "invitee_email", t(".email") %></dt> | ||
<dd><%= text_field_tag "invitation[invitee_email]", params[:invitation][:invitee_email], id: "invitee_email" %></dd> | ||
</dl> | ||
<p class="submit actions"><%= submit_tag "Go" %></p> |
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.
Missed a string, although it could really be "Search" instead of "Go."
<dd><%= text_field_tag "invitation[invitee_email]", params[:invitation][:invitee_email], id: "invitee_email" %></dd> | ||
</dl> | ||
<p class="submit actions"><%= submit_tag "Go" %></p> | ||
<% end %> | ||
|
||
<% if @user %> | ||
<h3 class="heading"><%h= 'Invitations for' %> <%= link_to @user.login, user_invitations_path(@user) %></h3> | ||
<%= render :partial => 'invitations/user_invitations', :locals => {:invitations => @invitations} %> | ||
<h3 class="heading"><%= t(".invitations_for") %> <%= link_to @user.login, user_invitations_path(@user) %></h3> |
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 think this needs some interpolation so the link to the name is part of the translated text.
<%= form_tag url_for(controller: "admin/admin_invitations", action: :invite_from_queue), autocomplete: "off" do %> | ||
<fieldset class="simple"> |
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.
<%= form_tag url_for(controller: "admin/admin_invitations", action: :invite_from_queue), autocomplete: "off" do %> | |
<fieldset class="simple"> | |
<%= form_tag url_for(controller: "admin/admin_invitations", action: :invite_from_queue), class: "queue invitation simple post", autocomplete: "off" do %> | |
<fieldset> |
<%= form_tag url_for(controller: "admin/admin_invitations", action: :create), autocomplete: "off" do |f| %> | ||
<fieldset class="simple"> |
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.
<%= form_tag url_for(controller: "admin/admin_invitations", action: :create), autocomplete: "off" do |f| %> | |
<fieldset class="simple"> | |
<%= form_tag url_for(controller: "admin/admin_invitations", action: :create), class: "invitation simple post", autocomplete: "off" do |f| %> | |
<fieldset> |
Conveniently, this will move the submit button closer to the fields. simple
was in the wrong place to have any effect before.
<%= form_tag changed_username_user_path(@user), autocomplete: "off" do %> | ||
<dl> |
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.
Same suggestion for the legend and heading as in the admin partial:
<%= form_tag changed_username_user_path(@user), autocomplete: "off" do %> | |
<dl> | |
<%= form_tag changed_username_user_path(@user), class: "simple post", autocomplete: "off" do %> | |
<legend><%= t(".legend") %></legend> | |
<h3 class="landmark heading"><%= t(".heading") %></h3> | |
<dl> |
</p> | ||
</dd> | ||
<dt><%= label_tag :password, t(".password") %></dt> | ||
<dd><%= password_field_tag :password, nil, autocomplete: "disabled" %></dd> |
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.
Does this need autocomplete: "disabled"
when the form has autocomplete: "off"
because it's a password field?
<h3 class="heading"><%h= 'Invitations for' %> <%= link_to @user.login, user_invitations_path(@user) %></h3> | ||
<%= render :partial => 'invitations/user_invitations', :locals => {:invitations => @invitations} %> | ||
<h3 class="heading"><%= t(".invitations_for") %> <%= link_to @user.login, user_invitations_path(@user) %></h3> | ||
<%= render partial: "invitations/user_invitations", invitations: @invitations %> |
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.
<%= render partial: "invitations/user_invitations", invitations: @invitations %> | |
<%= render "invitations/user_invitations", invitations: @invitations %> |
<% elsif @invitation %> | ||
<%= render :partial => 'invitations/invitation', :locals => {:invitation => @invitation} %> | ||
<%= render partial: "invitations/invitation", invitation: @invitation %> |
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.
<%= render partial: "invitations/invitation", invitation: @invitation %> | |
<%= render "invitations/invitation", invitation: @invitation %> |
<% elsif @invitations %> | ||
<%= render :partial => 'invitations/user_invitations', :locals => {:invitations => @invitations} %> | ||
<%= render partial: "invitations/user_invitations", invitations: @invitations %> |
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.
<%= render partial: "invitations/user_invitations", invitations: @invitations %> | |
<%= render "invitations/user_invitations", invitations: @invitations %> |
(Sorry for all the comments! If it makes you feel any better, the review took me three days to finish. 😆) |
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing
)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-6672
Purpose
Allow superadmins and policy_and_abuse to set a generic username for users (even when banned). Because #4991 is already open, I have not added the subscript for "Ticket ID" as noted in the ticket.
Side question: do we want to update some of the copy/variables here to be more consistent? I observed
login
(has to stay),user name
, andusername
in different spots...