diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 001a402..3e63569 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -178,8 +178,8 @@ class ProfileController < PublicController @scrap.receiver= receiver @tab_action = params[:tab_action] @message = @scrap.save ? _("Message successfully sent.") : _("You can't leave an empty message.") - @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? - render :partial => 'profile_activities_list' + activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? + render :partial => 'profile_activities_list', :locals => {:activities => activities} end def leave_comment_on_activity @@ -191,8 +191,8 @@ class ProfileController < PublicController @comment.source_type, @comment.source_id = (@activity.target_type == 'Article' ? ['Article', @activity.target_id] : [@activity.class.to_s, @activity.id]) @tab_action = params[:tab_action] @message = @comment.save ? _("Comment successfully added.") : _("You can't leave an empty comment.") - @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? - render :partial => 'profile_activities_list' + activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) if params[:not_load_scraps].nil? + render :partial => 'profile_activities_list', :locals => {:activities => activities} end def view_more_scraps @@ -202,7 +202,7 @@ class ProfileController < PublicController def view_more_activities @activities = @profile.activities.paginate(:per_page => 30, :page => params[:page]) - render :partial => 'profile_activities_scraps', :locals => {:activities => @activities} + render :partial => 'profile_activities_list', :locals => {:activities => @activities} end def view_more_network_activities diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 16d132e..c3f84fe 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -181,4 +181,8 @@ class Enterprise < Organization true end + def activities + Scrap.find_by_sql("SELECT id, updated_at, 'Scrap' AS klass FROM scraps WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, 'ActionTracker::Record' AS klass FROM action_tracker WHERE action_tracker.target_id = #{self.id} UNION SELECT action_tracker.id, action_tracker.updated_at, 'ActionTracker::Record' AS klass FROM action_tracker INNER JOIN articles ON action_tracker.target_id = articles.id WHERE articles.profile_id = #{self.id} AND action_tracker.target_type = 'Article' ORDER BY action_tracker.updated_at DESC") + end + end diff --git a/app/models/scrap.rb b/app/models/scrap.rb index d84dcd6..4fc3ac5 100644 --- a/app/models/scrap.rb +++ b/app/models/scrap.rb @@ -13,6 +13,8 @@ class Scrap < ActiveRecord::Base track_actions :leave_scrap, :after_create, :keep_params => ['sender.name', 'content', 'receiver.name', 'receiver.url'], :if => Proc.new{|s| s.receiver != s.sender}, :custom_target => :action_tracker_target + track_actions :leave_scrap_to_self, :after_create, :keep_params => ['sender.name', 'content'], :if => Proc.new{|s| s.receiver == s.sender} + after_create do |scrap| scrap.root.update_attribute('updated_at', DateTime.now) unless scrap.root.nil? Scrap::Notifier.deliver_mail(scrap) if scrap.send_notification? diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index f90fbd3..a032766 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -140,4 +140,9 @@ class UploadedFile < Article def uploaded_file? true end + + def action_tracker_target + self + end + end diff --git a/app/views/profile/_comment.rhtml b/app/views/profile/_comment.rhtml index a4de820..b9d886f 100644 --- a/app/views/profile/_comment.rhtml +++ b/app/views/profile/_comment.rhtml @@ -1,26 +1,27 @@ +<%# Comment %>
  • - <% if Person.find(comment.author_id) %> - <%= link_to image_tag(profile_icon(Person.find(comment.author_id), :minor)), + <% if comment.author %> + <%= link_to image_tag(profile_icon(comment.author, :minor)), Person.find(comment.author_id).url, :class => 'comment-picture', - :title => Person.find(comment.author_id).name + :title => comment.author_name %> <% end %>
    - <%= link_to(Person.find(comment.author_id).name, Person.find(comment.author_id).url) %> <%= txt2html comment.body %> + <%= link_to(comment.author_name, comment.author.url) %> <%= txt2html comment.body %>
    <%= time_ago_as_sentence(comment.created_at) %>
    - <% if logged_in? && (user == profile || user == Person.find(comment.author_id) || user.has_permission?(:moderate_comments, profile)) %> + <% if logged_in? && (user == profile || user == comment.author || user.has_permission?(:moderate_comments, profile)) %> <% button_bar(:style => 'float: right; margin-top: 0px;') do %> <%= icon_button(:delete, _('Remove'), { :action => :remove_comment, :comment_id => comment.id }, :method => :get, :confirm => _('Are you sure you want to remove this comment and all its replies?')) %> <% end %> @@ -37,7 +38,7 @@ }); <% end %> - <%= report_abuse(Person.find(comment.author_id), :comment_link, comment) if Person.find(comment.author_id) %> + <%= report_abuse(comment.author, :comment_link, comment) if comment.author %> <%= link_to_function _('Reply'), "var f = add_comment_reply_form(this, %s); f.find('input[name=comment[title]], textarea').val(''); return false" % comment.id, :class => 'comment-footer comment-footer-link comment-footer-hide', @@ -47,7 +48,7 @@
    - <% unless Comment.find(comment.id).replies.blank? %> + <% unless comment.replies.blank? %>