diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index e25277b..001a402 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -224,7 +224,11 @@ class ProfileController < PublicController begin raise if !can_edit_profile activity = ActionTracker::Record.find(params[:activity_id]) - activity.destroy + if params[:only_hide] + activity.update_attribute(:visible, false) + else + activity.destroy + end render :text => _('Activity successfully removed.') rescue render :text => _('You could not remove this activity') diff --git a/app/models/comment.rb b/app/models/comment.rb index 65cde87..fc376a4 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -80,7 +80,10 @@ class Comment < ActiveRecord::Base Comment::Notifier.deliver_mail(comment) end - comment.article.activity.increment!(:comments_count) if comment.source.kind_of?(Article) && comment.article.activity + if comment.source.kind_of?(Article) && comment.article.activity + comment.article.activity.increment!(:comments_count) + comment.article.activity.update_attribute(:visible, true) + end end after_destroy do |comment| diff --git a/app/views/profile/_create_article.rhtml b/app/views/profile/_create_article.rhtml index d008103..b0f0611 100644 --- a/app/views/profile/_create_article.rhtml +++ b/app/views/profile/_create_article.rhtml @@ -11,6 +11,6 @@

<%= time_ago_as_sentence(activity.created_at) %>

<%= link_to _('Comment'), "#reply_content_#{activity.id}" %> - <%= link_to_remote(content_tag(:span, _('Remove')), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :confirm => _('Are you sure?'), :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> + <%= link_to_remote(content_tag(:span, _('Remove')), :url =>{:action => 'remove_activity', :activity_id => activity.id, :only_hide => true}, :confirm => _('Are you sure?'), :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %>
diff --git a/app/views/profile/_profile_activities_scraps.rhtml b/app/views/profile/_profile_activities_scraps.rhtml index 6d491df..e9fb670 100644 --- a/app/views/profile/_profile_activities_scraps.rhtml +++ b/app/views/profile/_profile_activities_scraps.rhtml @@ -1,7 +1,7 @@ <% activities.each do |a| %> <% activity = a.klass.constantize.find(a.id) %> <% if activity.kind_of?(ActionTracker::Record) %> - <%= render :partial => 'profile_activity', :locals => {:activity => activity} %> + <%= render :partial => 'profile_activity', :locals => {:activity => activity} if activity.visible? %> <% else %> <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %> <% end %> diff --git a/db/schema.rb b/db/schema.rb index 9a8ac15..03d8224 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -30,6 +30,7 @@ ActiveRecord::Schema.define(:version => 20120307200651) do t.datetime "created_at" t.datetime "updated_at" t.integer "comments_count", :default => 0 + t.boolean "visible", :default => true end add_index "action_tracker", ["target_id", "target_type"], :name => "index_action_tracker_on_dispatcher_id_and_dispatcher_type" -- libgit2 0.21.2