X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3369743d6c29f8e495d75ae64e96d42ce35e7643..3d874a5d61b332cefe944b77cfa38a1061425d3f:/app/controllers/diary_entry_controller.rb diff --git a/app/controllers/diary_entry_controller.rb b/app/controllers/diary_entry_controller.rb index ff1976a82..68d3a81ee 100644 --- a/app/controllers/diary_entry_controller.rb +++ b/app/controllers/diary_entry_controller.rb @@ -4,6 +4,7 @@ class DiaryEntryController < ApplicationController before_filter :authorize_web before_filter :set_locale before_filter :require_user, :only => [:new, :edit, :comment, :hide, :hidecomment] + before_filter :lookup_this_user, :only => [:view, :comments] before_filter :check_database_readable before_filter :check_database_writable, :only => [:new, :edit] before_filter :require_administrator, :only => [:hide, :hidecomment] @@ -84,10 +85,7 @@ class DiaryEntryController < ApplicationController :order => 'created_at DESC', :per_page => 20) else - @title = t'diary_entry.no_such_user.title' - @not_found_user = params[:display_name] - - render :action => 'no_such_user', :status => :not_found + render_unknown_user params[:display_name] end elsif params[:language] @title = t 'diary_entry.list.in_language_title', :language => Language.find(params[:language]).english_name @@ -167,34 +165,37 @@ class DiaryEntryController < ApplicationController end def view - user = User.active.find_by_display_name(params[:display_name]) - - if user - @entry = user.diary_entries.visible.where(:id => params[:id]).first - if @entry - @title = t 'diary_entry.view.title', :user => params[:display_name], :title => @entry.title - else - @title = t 'diary_entry.no_such_entry.title', :id => params[:id] - render :action => 'no_such_entry', :status => :not_found - end + @entry = @this_user.diary_entries.visible.where(:id => params[:id]).first + if @entry + @title = t 'diary_entry.view.title', :user => params[:display_name], :title => @entry.title else - @not_found_user = params[:display_name] - - render :action => 'no_such_user', :status => :not_found + @title = t 'diary_entry.no_such_entry.title', :id => params[:id] + render :action => 'no_such_entry', :status => :not_found end end def hide entry = DiaryEntry.find(params[:id]) - entry.update_attributes(:visible => false) + entry.update_attributes({:visible => false}, :without_protection => true) redirect_to :action => "list", :display_name => entry.user.display_name end def hidecomment comment = DiaryComment.find(params[:comment]) - comment.update_attributes(:visible => false) + comment.update_attributes({:visible => false}, :without_protection => true) redirect_to :action => "view", :display_name => comment.diary_entry.user.display_name, :id => comment.diary_entry.id end + + def comments + @comment_pages, @comments = paginate(:diary_comments, + :conditions => { + :user_id => @this_user, + :visible => true + }, + :order => 'created_at DESC', + :per_page => 20) + @page = (params[:page] || 1).to_i + end private ## # require that the user is a administrator, or fill out a helpful error message