From: Andy Allan Date: Wed, 27 Mar 2019 16:15:18 +0000 (+0100) Subject: Refactor notes#mine to simplify code X-Git-Tag: live~3178^2~1 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/a5f412468107055f38b3f537b4bb8a01aec1db34?ds=sidebyside Refactor notes#mine to simplify code --- diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 54fdb2810..7c6b033ca 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -16,13 +16,11 @@ class NotesController < ApplicationController if @user = User.active.find_by(:display_name => params[:display_name]) @params = params.permit(:display_name) @title = t "notes.mine.title", :user => @user.display_name - @heading = t "notes.mine.heading", :user => @user.display_name - @description = t "notes.mine.subheading", :user => render_to_string(:partial => "user", :object => @user) @page = (params[:page] || 1).to_i @page_size = 10 @notes = @user.notes @notes = @notes.visible unless current_user&.moderator? - @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).to_a + @notes = @notes.order("updated_at DESC, id").distinct.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author) else @title = t "users.no_such_user.title" @not_found_user = params[:display_name] diff --git a/app/views/notes/_user.html.erb b/app/views/notes/_user.html.erb deleted file mode 100644 index 21bab618c..000000000 --- a/app/views/notes/_user.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= link_to user.display_name, user_path(user) %> diff --git a/app/views/notes/mine.html.erb b/app/views/notes/mine.html.erb index e019c1bfe..2966b81bb 100644 --- a/app/views/notes/mine.html.erb +++ b/app/views/notes/mine.html.erb @@ -1,6 +1,6 @@ <% content_for :heading do %> -

<%= @heading %>

-

<%= raw @description %>

+

<%= t "notes.mine.heading", :user => @user.display_name %>

+

<%= t "notes.mine.subheading_html", :user => link_to(@user.display_name, user_path(@user)) %>

<% end %> <%= render :partial => "notes_paging_nav" %> @@ -15,7 +15,7 @@ <%= t ".last_changed" %> <% @notes.each do |note| -%> - class="creator"<% end %>> + class="creator"<% end %>> <% if note.closed? %> <%= image_tag("closed_note_marker.png", :alt => "closed") %> @@ -23,7 +23,7 @@ <%= image_tag("open_note_marker.png", :alt => "open") %> <% end %> - <%= link_to note.id.to_s, :controller => "browse", :action => "note", :id => note.id %> + <%= link_to note.id, browse_note_path(note) %> <%= note_author(note.author) %> <%= note.comments.first.body.to_html %> <%= t ".ago_html", :when => friendly_date(note.created_at) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 71c081f49..569992599 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2361,7 +2361,7 @@ en: mine: title: "Notes submitted or commented on by %{user}" heading: "%{user}'s notes" - subheading: "Notes submitted or commented on by %{user}" + subheading_html: "Notes submitted or commented on by %{user}" id: "Id" creator: "Creator" description: "Description"