diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9492bfba..db47319e 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -296,10 +296,17 @@ class ProjectsController < ApplicationController #Ended by young def feedback + page = params[:page] + # Find the page of the requested reply @jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') @limit = 10 + if params[:r] && page.nil? + offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i]) + page = 1 + offset / @limit + end + @feedback_count = @jours.count - @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @feedback_pages = Paginator.new @feedback_count, @limit, page @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] @state = false diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 426d1b56..2c4f1088 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -27,8 +27,10 @@ class JournalsForMessage < ActiveRecord::Base :datetime => Proc.new {|o| o.updated_on }, :author => Proc.new {|o| o.user }, :description => Proc.new{|o| o.notes }, - :type => Proc.new {|o| o.jour_type }#, - #:url => Proc.new {|o| ''}#{:controller => 'documents', :action => 'show', :id => o.id}} + :type => Proc.new {|o| o.jour_type }, + :url => Proc.new {|o| + (o.jour.kind_of? Project) ? {:controller => 'projects', :action => 'feedback', :id => o.jour, :r => o.id, :anchor => "word_li_#{o.id}"} : {} + }#{:controller => 'documents', :action => 'show', :id => o.id}} acts_as_activity_provider :author_key => :user_id, :timestamp => "#{self.table_name}.updated_on", :find_options => {:include => :project }