From: Steve Singer Date: Sat, 25 Feb 2012 20:46:11 +0000 (-0500) Subject: Add a view to show diary comments left by a user X-Git-Tag: live~5776 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/1944372af802ba3096a9bd72bca2f7ab49095a33?ds=sidebyside Add a view to show diary comments left by a user --- diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index ff1976a82..f87b02ef9 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -195,6 +195,22 @@ class DiaryEntryController < ApplicationController comment.update_attributes(:visible => false) redirect_to :action => "view", :display_name => comment.diary_entry.user.display_name, :id => comment.diary_entry.id end + + def comments + @this_user = User.active.find_by_display_name(params[:display_name]) + + if @this_user + @comment_pages, @comments = paginate(:diary_comments, + :conditions => { :user_id => @this_user }, + :order => 'created_at DESC', + :per_page => 20) + @page = (params[:page] || 1).to_i + else + @title = t'diary_entry.no_such_user.title' + @not_found_user = params[:display_name] + render :action => 'no_such_user', :status => :not_found + end + end private ## # require that the user is a administrator, or fill out a helpful error message diff --git a/app/views/diary_entry/comments.html.erb b/app/views/diary_entry/comments.html.erb new file mode 100644 index 000000000..fbad59d47 --- /dev/null +++ b/app/views/diary_entry/comments.html.erb @@ -0,0 +1,23 @@ +

<%= @title%> + <%= t('diary_entry.comments.has_commented_on',:display_name => @this_user.display_name) %> +

+

+
+ + +<% for comment in @comments %> + + + + +<% end %> +
TitleDateComment
<%= comment.diary_entry.title %> + +<%= comment.created_at %> + +<%= htmlize(comment.body) %>
+<%= link_to t('diary_entry.comments.older_comments') , { :page => @comment_pages.current.next} if @comment_pages.current.next %> +<% if @comment_pages.current.next and @comment_pages.current.previous %> +| +<% end %> +<%= link_to t('diary_entry.comments.newer_comments'), { :page => @comment_pages.current.previous } if @comment_pages.current.previous %> diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index bd3a371aa..f6a4d8339 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -21,6 +21,8 @@ | <%= link_to t('user.view.new diary entry'), :controller => 'diary_entry', :action => 'new', :display_name => @user.display_name %> | + <%= link_to t('user.view.my comments' ), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %>
+ | <%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %> | <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %> @@ -39,6 +41,8 @@ | <%= link_to t('user.view.diary'), :controller => 'diary_entry', :action => 'list', :display_name => @this_user.display_name %> | + <%= link_to t('user.view.comments'), :controller => 'diary_entry', :action => 'comments', :display_name => @this_user.display_name %> + | <%= link_to t('user.view.edits'), :controller => 'changeset', :action => 'list', :display_name => @this_user.display_name %> | <%= link_to t('user.view.traces'), :controller => 'trace', :action => 'list', :display_name => @this_user.display_name %> diff --git a/config/locales/en.yml b/config/locales/en.yml index b5cfba61b..49b9d1d34 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -392,6 +392,10 @@ en: all: title: "OpenStreetMap diary entries" description: "Recent diary entries from users of OpenStreetMap" + comments: + has_commented_on: "%{display_name} has commented on the following diary entries" + newer_comments: "Newer Comments" + older_comments: "Older Comments" export: start: area_to_export: "Area to Export" @@ -1662,6 +1666,7 @@ en: my edits: my edits my traces: my traces my settings: my settings + my comments: my comments oauth settings: oauth settings blocks on me: blocks on me blocks by me: blocks by me @@ -1703,6 +1708,7 @@ en: moderator: "Revoke moderator access" block_history: "view blocks received" moderator_history: "view blocks given" + comments: "comments" create_block: "block this user" activate_user: "activate this user" deactivate_user: "deactivate this user" diff --git a/config/routes.rb b/config/routes.rb index 71af08b73..89f7e1951 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -160,6 +160,8 @@ OpenStreetMap::Application.routes.draw do match '/user/:display_name/diary/rss' => 'diary_entry#rss', :format => :rss match '/diary/:language/rss' => 'diary_entry#rss', :format => :rss match '/diary/rss' => 'diary_entry#rss', :format => :rss + match '/user/:display_name/diary/comments/:page' => 'diary_entry#comments', :page => /\d+/ + match '/user/:display_name/diary/comments/' => 'diary_entry#comments' match '/user/:display_name/diary' => 'diary_entry#list' match '/diary/:language' => 'diary_entry#list' match '/diary' => 'diary_entry#list'