Add a view to show diary comments left by a user

This commit is contained in:
Steve Singer 2012-02-25 15:46:11 -05:00 committed by Tom Hughes
parent e45f8855c4
commit 1944372af8
5 changed files with 51 additions and 0 deletions

View file

@ -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

View file

@ -0,0 +1,23 @@
<h1><%= @title%>
<%= t('diary_entry.comments.has_commented_on',:display_name => @this_user.display_name) %>
</h1>
<p>
<br>
<table id="comment-list-container">
<tr><th>Title</th><th>Date</th><th>Comment</th></tr>
<% for comment in @comments %>
<tr id="comment-row">
<td><a href="/user/<%= comment.diary_entry.user.display_name %>/diary/<%= comment.diary_entry.id %>"><%= comment.diary_entry.title %></a>
</td>
<td>
<span class="date"><%= comment.created_at %></span>
</td>
<td>
<%= htmlize(comment.body) %></td></tr>
<% end %>
</table>
<%= 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 %>

View file

@ -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 %><br/>
|
<%= 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 %>

View file

@ -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"

View file

@ -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'