Skip to content

Commit

Permalink
'user name' -> 'username' batch 2
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjaustin committed Dec 26, 2024
1 parent 23175d2 commit 5f52362
Show file tree
Hide file tree
Showing 29 changed files with 327 additions and 221 deletions.
65 changes: 30 additions & 35 deletions app/controllers/pseuds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,42 @@ def index

# GET /users/:user_id/pseuds/:id
def show
if @user.blank?
raise ActiveRecord::RecordNotFound, "Couldn't find user '#{params[:user_id]}'"
end
raise ActiveRecord::RecordNotFound, t(".could_not_find_user", username: params[:user_id]) if @user.blank?

@pseud = @user.pseuds.find_by(name: params[:id])
unless @pseud
raise ActiveRecord::RecordNotFound, "Couldn't find pseud '#{params[:id]}'"
end
raise ActiveRecord::RecordNotFound, t(".could_not_find_pseud", pseud: params[:id]) unless @pseud

@page_subtitle = @pseud.name

# very similar to show under users - if you change something here, change it there too
if !(logged_in? || logged_in_as_admin?)
visible_works = @pseud.works.visible_to_all
visible_series = @pseud.series.visible_to_all
visible_bookmarks = @pseud.bookmarks.visible_to_all
else
if logged_in? || logged_in_as_admin?
visible_works = @pseud.works.visible_to_registered_user
visible_series = @pseud.series.visible_to_registered_user
visible_bookmarks = @pseud.bookmarks.visible_to_registered_user
else
visible_works = @pseud.works.visible_to_all
visible_series = @pseud.series.visible_to_all
visible_bookmarks = @pseud.bookmarks.visible_to_all
end

visible_works = visible_works.revealed.non_anon
visible_series = visible_series.exclude_anonymous

@fandoms = \
Fandom.select("tags.*, count(DISTINCT works.id) as work_count").
joins(:filtered_works).group("tags.id").merge(visible_works).
where(filter_taggings: { inherited: false }).
order('work_count DESC').load
Fandom.select("tags.*, count(DISTINCT works.id) as work_count")
.joins(:filtered_works).group("tags.id").merge(visible_works)
.where(filter_taggings: { inherited: false })
.order("work_count DESC").load

@works = visible_works.order("revised_at DESC").limit(ArchiveConfig.NUMBER_OF_ITEMS_VISIBLE_IN_DASHBOARD)
@series = visible_series.order("updated_at DESC").limit(ArchiveConfig.NUMBER_OF_ITEMS_VISIBLE_IN_DASHBOARD)
@bookmarks = visible_bookmarks.order("updated_at DESC").limit(ArchiveConfig.NUMBER_OF_ITEMS_VISIBLE_IN_DASHBOARD)

if current_user.respond_to?(:subscriptions)
@subscription = current_user.subscriptions.where(subscribable_id: @user.id,
subscribable_type: 'User').first ||
current_user.subscriptions.build(subscribable: @user)
end
return unless current_user.respond_to?(:subscriptions)

@subscription = current_user.subscriptions.where(subscribable_id: @user.id,
subscribable_type: "User").first ||
current_user.subscriptions.build(subscribable: @user)
end

# GET /pseuds/new
Expand All @@ -86,7 +84,7 @@ def create
@pseud.user_id = @user.id
old_default = @user.default_pseud
if @pseud.save
flash[:notice] = ts('Pseud was successfully created.')
flash[:notice] = t(".successfully_created")
if @pseud.is_default
# if setting this one as default, unset the attribute of the current default pseud
old_default.update_attribute(:is_default, false)
Expand All @@ -96,8 +94,8 @@ def create
render action: "new"
end
else
# user tried to add pseud he already has
flash[:error] = ts('You already have a pseud with that name.')
# user tried to add pseud they already have
flash[:error] = t(".already_have_pseud_with_name")
render action: "new"
end
end
Expand All @@ -115,12 +113,9 @@ def update
AdminActivity.log_action(current_admin, @pseud, action: "edit pseud", summary: summary)
end
# if setting this one as default, unset the attribute of the current default pseud
if @pseud.is_default and not(default == @pseud)
# if setting this one as default, unset the attribute of the current active pseud
default.update_attribute(:is_default, false)
end
flash[:notice] = ts('Pseud was successfully updated.')
redirect_to([@user, @pseud])
default.update_attribute(:is_default, false) if @pseud.is_default && default != @pseud
flash[:notice] = t(".successfully_updated")
redirect_to([@user, @pseud])
else
render action: "edit"
end
Expand All @@ -131,24 +126,24 @@ def update
def destroy
@hide_dashboard = true
if params[:cancel_button]
flash[:notice] = ts("The pseud was not deleted.")
flash[:notice] = t(".not_deleted")
redirect_to(user_pseuds_path(@user)) && return
end

@pseud = @user.pseuds.find_by(name: params[:id])
if @pseud.is_default
flash[:error] = ts("You cannot delete your default pseudonym, sorry!")
flash[:error] = t(".cannot_delete_default")
elsif @pseud.name == @user.login
flash[:error] = ts("You cannot delete the pseud matching your user name, sorry!")
flash[:error] = t(".cannot_delete_matching_username")
elsif params[:bookmarks_action] == "transfer_bookmarks"
@pseud.change_bookmarks_ownership
@pseud.replace_me_with_default
flash[:notice] = ts("The pseud was successfully deleted.")
flash[:notice] = t(".successfully_deleted")
elsif params[:bookmarks_action] == "delete_bookmarks" || @pseud.bookmarks.empty?
@pseud.replace_me_with_default
flash[:notice] = ts("The pseud was successfully deleted.")
flash[:notice] = t(".successfully_deleted")
else
render 'delete_preview' and return
render "delete_preview" and return
end

redirect_to(user_pseuds_path(@user))
Expand Down
2 changes: 1 addition & 1 deletion app/models/pseud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def self.parse_byline(byline)

# Parse a string of the "pseud.name (user.login)" format into a list of
# pseuds. Usually this will be just one pseud, but if the byline is of the
# form "pseud.name" with no parenthesized user name, it'll look for any pseud
# form "pseud.name" with no parenthesized username, it'll look for any pseud
# with that name.
def self.parse_byline_ambiguous(byline)
pseud_name, login = split_byline(byline)
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/admin_invitations/find.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!--main content-->
<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => 'find'), :method => :get do %>
<dl>
<dt><%= label_tag "invitation[user_name]", t(".user_name") %>:</dt>
<dt><%= label_tag "invitation[user_name]", t(".username") %>:</dt>
<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>
Expand Down
69 changes: 41 additions & 28 deletions app/views/admin/admin_invitations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,65 @@
</ul>
<!--/subnav-->
<!--main content-->
<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => :create) do |f| %>
<%= form_tag url_for(controller: "admin/admin_invitations", action: :create) do |f| %>
<fieldset class="simple">
<h3 class="heading">Send to email</h3>
<p>Send an invite code to the following email address:
<%= text_field_tag "invitation[invitee_email]", (@invitation.try(:invitee_email) || ""), :title => ts("invite by email") %>
<span class="submit actions"><%= submit_tag ts('Invite user') %></span>
<h3 class="heading"><%= t(".send_to_email.heading") %></h3>
<p>
<%= t(".send_to_email.description") %>
<%= text_field_tag "invitation[invitee_email]",
(@invitation.try(:invitee_email) || ""),
autocomplete: "email",
title: t(".send_to_email.invite_by_email") %>
<span class="submit actions"><%= submit_tag t(".send_to_email.invite_user") %></span>
</p>
</fieldset>
<% end %>

<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => 'invite_from_queue') do %>
<%= form_tag url_for(controller: "admin/admin_invitations", action: :invite_from_queue) do %>
<fieldset class="simple">
<h3 class="heading">Send invite codes to people in our <%= link_to 'invitations queue', invite_requests_path %></h3>
<p>There are <%= InviteRequest.count %> requests in the queue.</p>
<h3 class="heading">
<%= t(".invite_from_queue.heading_html",
invitations_queue_link: link_to(t(".invite_from_queue.invitations_queue"), invite_requests_path)) %>
</h3>
<p><%= t(".invite_from_queue.requests_in_queue", count: InviteRequest.count) %></p>
<p>
<%= label_tag "invitation[invite_from_queue]", ts('Number of people to invite') %>: <%= text_field_tag "invitation[invite_from_queue]" %>
<span class="submit actions"><%= submit_tag ts('Invite from queue') %></span>
<%= label_tag "invitation[invite_from_queue]", t(".invite_from_queue.number_to_invite") %>
<%= text_field_tag "invitation[invite_from_queue]", nil, autocomplete: "on" %>
<span class="submit actions"><%= submit_tag t(".invite_from_queue.invite_from_queue") %></span>
</p>
</fieldset>
<% end %>

<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => 'grant_invites_to_users') do %>
<%= form_tag url_for(controller: "admin/admin_invitations", action: :grant_invites_to_users) do %>
<fieldset>
<h3 class="heading"><%=h 'Give invite codes to current users' %></h3>
<h3 class="heading"><%= t(".grant_invites.heading") %></h3>
<dl>
<dt><%= label_tag "invitation[number_of_invites]", ts('Number of invitations') %>:</dt>
<dd><%= text_field_tag "invitation[number_of_invites]" %></dd>
<dt><%= label_tag "invitation[user_group]", ts('Users') %>:</dt>
<dd><%= select_tag "invitation[user_group]", "<option>All</option><option>With no unused invitations</option>".html_safe %></dd>
<dt class="landmark">Submit</dt>
<dd class="submit actions"><%= submit_tag "Generate invitations" %></dd>
<dt><%= label_tag "invitation[number_of_invites]", t(".grant_invites.number_of_invitations") %></dt>
<dd><%= text_field_tag "invitation[number_of_invites]", nil, autocomplete: "on" %></dd>
<dt><%= label_tag "invitation[user_group]", t(".grant_invites.users") %></dt>
<dd><%= select_tag "invitation[user_group]", [t(".grant_invites.all"), t(".grant_invites.with_no_unused")] %></dd>
<dt class="landmark"><%= t(".grant_invites.landmark_submit") %></dt>
<dd class="submit actions"><%= submit_tag t(".grant_invites.generate_invitations") %></dd>
</fieldset>
<% end %>

<%= form_tag url_for(:controller => 'admin/admin_invitations', :action => 'find'), :method => :get do %>
<%= form_tag url_for(controller: "admin/admin_invitations", action: :find), method: :get do %>
<fieldset>
<h3 class="heading"><%=h 'Track invitations' %></h3>
<h3 class="heading"><%= t(".find.heading") %></h3>
<dl>
<dt><%= label_tag "invitation[user_name]", ts('Enter a user name') %>:</dt>
<dd><%= text_field_tag "invitation[user_name]" %></dd>
<dt><%= label_tag "invitation[token]", ts('Enter an invite token') %>:</dt>
<dd><%= text_field_tag "invitation[token]" %></dd>
<dt><%= label_tag "track_invitation_invitee_email", t(".email") %>:</dt>
<dd><%= text_field_tag "invitation[invitee_email]", nil, id: "track_invitation_invitee_email" %></dd>
<dt class="landmark">Submit</dt>
<dd class="submit actions"><%= submit_tag "Go" %></dd>
<dt><%= label_tag "invitation[user_name]", t(".find.enter_username") %></dt>
<dd><%= text_field_tag "invitation[user_name]", nil, autocomplete: "on" %></dd>
<dt><%= label_tag "invitation[token]", t(".find.enter_invite_token") %></dt>
<dd><%= text_field_tag "invitation[token]", nil, autocomplete: "on" %></dd>
<dt><%= label_tag "track_invitation_invitee_email", t(".find.email") %>:</dt>
<dd>
<%= text_field_tag "invitation[invitee_email]",
nil,
autocomplete: "email",
id: "track_invitation_invitee_email" %>
</dd>
<dt class="landmark"><%= t(".find.landmark_submit") %></dt>
<dd class="submit actions"><%= submit_tag t(".find.go") %></dd>
</dl>
</fieldset>
<% end %>
Expand Down
17 changes: 8 additions & 9 deletions app/views/admin_sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= ts("Log in as Admin") %></h2>
<h2 class="heading"><%= t(".page_heading") %></h2>
<!--/descriptions-->

<!--main content-->
<%= form_for @admin_session do |form| %>
<dl>
<dt><%= form.label :login, ts("Admin user name") %></dt>
<dd><%= form.text_field :login %></dd>
<dt><%= form.label :password, ts("Admin password") %></dt>
<dd><%= form.password_field :password %></dd>
</dl>
<p class="submit actions"><%= form.submit ts('Log in as admin') %></p>
<dl>
<dt><%= form.label :login, t(".admin_username") %></dt>
<dd><%= form.text_field :login %></dd>
<dt><%= form.label :password, t(".admin_password") %></dt>
<dd><%= form.password_field :password %></dd>
</dl>
<p class="submit actions"><%= form.submit t(".log_in_as_admin") %></p>
<% end %>
<!--/content-->

23 changes: 11 additions & 12 deletions app/views/challenge/gift_exchange/_challenge_signups.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!--descriptions-->
<h2 class="heading">
<% if @query %>
<%= search_header @challenge_signups, nil, "Sign-up" %>
<%= search_header @challenge_signups, nil, t(".heading.for_search") %>
<% else %>
<%= ts("Sign-ups for %{collection}", collection: @collection.title) %>
<%= t(".heading.for_collection", collection: @collection.title) %>
<% end %>
</h2>
<!--/descriptions-->
Expand All @@ -13,40 +13,40 @@
<li class="search" role="search">
<%= form_tag collection_signups_path(@collection), class: "simple search", method: :get do |form| %>
<fieldset>
<%= text_field_tag "query", @query, title: "search" %>
<%= submit_tag ts("Search By Pseud") %>
<%= text_field_tag "query", @query, title: t(".navigation.search"), autocomplete: "on" %>
<%= submit_tag t(".navigation.search_by_pseud") %>
</fieldset>
<% end %>
</li>
<li>
<%= link_to ts("Download (CSV)"), collection_signups_path(@collection, format: :csv) %>
<%= link_to t(".navigation.download_csv"), collection_signups_path(@collection, format: :csv) %>
<%= link_to_help "csv-download" %>
</li>
</ul>
<!--/subnav-->

<!--main content-->
<% if @challenge_signups.empty? %>
<p><%= ts("No sign-ups yet!")%></p>
<p><%= t(".no_sign_ups_yet") %></p>
<% else %>
<%= will_paginate(@challenge_signups) %>

<dl class="index group">
<% @challenge_signups.each do |signup| %>
<dt class="participant" title="<%= ts("user name") %>">
<dt class="participant" title="<%= t(".particpant_username") %>">
<%= link_to signup.pseud.name, collection_signup_path(@collection, signup) %>
<%= mailto_link signup.pseud.user, subject: "[#{h(@collection.title)}] Message from Collection Maintainer" %>
</dt>
<dd>
<%= render "challenge_signups/signup_controls", challenge_signup: signup, subnav: false %>
<ul class="actions">
<li>
<%= link_to h(ts("Requests")) + ' &#8595;'.html_safe, "#", class: "requests_#{signup.id}_open" %>
<%= link_to h(ts("Close Requests")) + ' &#8593;'.html_safe, "#", class: "requests_#{signup.id}_close" %>
<%= link_to t(".requests_html", down_arrow: "&#8595;"), "#", class: "requests_#{signup.id}_open" %>
<%= link_to t(".close_requests_html", up_arrow: "&#8593;"), "#", class: "requests_#{signup.id}_close" %>
</li>
<li>
<%= link_to h(ts("Offers")) + ' &#8595;'.html_safe, "#", class: "offers_#{signup.id}_open" %>
<%= link_to h(ts("Close Offers")) + ' &#8593;'.html_safe, "#", class: "offers_#{signup.id}_close" %>
<%= link_to t(".offers_html", down_arrow: "&#8595;"), "#", class: "offers_#{signup.id}_open" %>
<%= link_to t(".close_offers_html", up_arrow: "&#8593;"), "#", class: "offers_#{signup.id}_close" %>
</li>
</ul>
<div class="toggled" id="<%= "requests_#{signup.id}" %>">
Expand All @@ -62,4 +62,3 @@
<%= will_paginate(@challenge_signups) %>
<% end %>
<!--/content-->

35 changes: 19 additions & 16 deletions app/views/invitations/_user_invitations.html.erb
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
<% unless invitations.blank? %>
<table summary="<%= ts('List of your invitation tokens and information regarding who you shared them with, along with the option to share unused tokens.') %>">
<caption><%= ts('Invitation Information') %></caption>
<thead>
<tr>
<th scope="col"><%= ts('Token') %></th>
<th scope="col"><%= ts('Sent To') %></th>
<th scope="col"><%= ts('User Name') %></th>
<th scope="col"><%= ts('External Author') %></th>
<th scope="col"><%= ts('Copy Link') %></th>
<table summary="<%= t(".list_of_your_invitations") %>">
<caption><%= t(".invitation_information") %></caption>
<thead>
<tr>
<th scope="col"><%= t(".token") %></th>
<th scope="col"><%= t(".sent_to") %></th>
<th scope="col"><%= t(".username") %></th>
<th scope="col"><%= t(".external_author") %></th>
<th scope="col"><%= t(".copy_link") %></th>
</tr>
</thead>
<tbody>
</thead>
<tbody>
<% for invitation in invitations %>
<tr>
<td><%= link_to invitation.token, (invitation.creator.is_a?(User) ? [invitation.creator, invitation] : invitation) %></td>
<td><%= invitation.invitee_email %></td>
<td><%=invitee_link(invitation) %></td>
<td><%= invitation.external_author ? "#{invitation.external_author.email} (#{invitation.external_author.names.collect(&:name).delete_if {|name| name == invitation.external_author.email}.join(",")})" : "" %></td>
<td><%= invitee_link(invitation) %></td>
<td>
<%= invitation.external_author ? "#{invitation.external_author.email} (#{invitation.external_author.names.collect(&:name).delete_if { |name| name == invitation.external_author.email }
.join(',')})" : "" %>
</td>
<td>
<% unless invitation.redeemed_at %>
<% if invitation.external_author %>
<%= link_to ts("copy and use"), claim_path(:invitation_token => invitation.token) %>
<%= link_to t(".copy_and_use"), claim_path(invitation_token: invitation.token) %>
<% else %>
<%= link_to ts("copy and use"), signup_path(:invitation_token => invitation.token) %><% end %>
<%= link_to t(".copy_and_use"), signup_path(invitation_token: invitation.token) %><% end %>
<% end %>
</td>
<% if logged_in_as_admin? && invitation.redeemed_at.blank? %>
<td><%= link_to("Delete", invitation, data: {confirm: "Are you sure you want to delete this invitation?"}, :method => :delete) %></td>
<td><%= link_to(t(".delete"), invitation, data: { confirm: t(".delete_confirmation") }, method: :delete) %></td>
<% end %>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/_admin_change_username.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</p>
</dd>
<dt><%= label_tag :ticket_id, t(".ticket_id") %></dt>
<dd><%= text_field_tag :ticket_id, nil, autocomplete: "disabled" %></dd>
<dd><%= text_field_tag :ticket_id, nil, autocomplete: "off" %></dd>
<dt class="landmark"><%= t("users.change_username.submit_landmark") %></dt>
<dd class="submit actions">
<%= submit_tag t("users.change_username.change_username") %>
Expand Down
Loading

0 comments on commit 5f52362

Please sign in to comment.