Commit 727baee629102e3a91144f309371d1c445c6bb88
1 parent
cf24fb79
Exists in
master
and in
29 other branches
Added visibility to action trackers
Showing
5 changed files
with
12 additions
and
4 deletions
Show diff stats
app/controllers/public/profile_controller.rb
@@ -224,7 +224,11 @@ class ProfileController < PublicController | @@ -224,7 +224,11 @@ class ProfileController < PublicController | ||
224 | begin | 224 | begin |
225 | raise if !can_edit_profile | 225 | raise if !can_edit_profile |
226 | activity = ActionTracker::Record.find(params[:activity_id]) | 226 | activity = ActionTracker::Record.find(params[:activity_id]) |
227 | - activity.destroy | 227 | + if params[:only_hide] |
228 | + activity.update_attribute(:visible, false) | ||
229 | + else | ||
230 | + activity.destroy | ||
231 | + end | ||
228 | render :text => _('Activity successfully removed.') | 232 | render :text => _('Activity successfully removed.') |
229 | rescue | 233 | rescue |
230 | render :text => _('You could not remove this activity') | 234 | render :text => _('You could not remove this activity') |
app/models/comment.rb
@@ -80,7 +80,10 @@ class Comment < ActiveRecord::Base | @@ -80,7 +80,10 @@ class Comment < ActiveRecord::Base | ||
80 | Comment::Notifier.deliver_mail(comment) | 80 | Comment::Notifier.deliver_mail(comment) |
81 | end | 81 | end |
82 | 82 | ||
83 | - comment.article.activity.increment!(:comments_count) if comment.source.kind_of?(Article) && comment.article.activity | 83 | + if comment.source.kind_of?(Article) && comment.article.activity |
84 | + comment.article.activity.increment!(:comments_count) | ||
85 | + comment.article.activity.update_attribute(:visible, true) | ||
86 | + end | ||
84 | end | 87 | end |
85 | 88 | ||
86 | after_destroy do |comment| | 89 | after_destroy do |comment| |
app/views/profile/_create_article.rhtml
@@ -11,6 +11,6 @@ | @@ -11,6 +11,6 @@ | ||
11 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> | 11 | <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> |
12 | <div class='profile-wall-actions'> | 12 | <div class='profile-wall-actions'> |
13 | <%= link_to _('Comment'), "#reply_content_#{activity.id}" %> | 13 | <%= link_to _('Comment'), "#reply_content_#{activity.id}" %> |
14 | - <%= 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 %> | 14 | + <%= 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 %> |
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
app/views/profile/_profile_activities_scraps.rhtml
1 | <% activities.each do |a| %> | 1 | <% activities.each do |a| %> |
2 | <% activity = a.klass.constantize.find(a.id) %> | 2 | <% activity = a.klass.constantize.find(a.id) %> |
3 | <% if activity.kind_of?(ActionTracker::Record) %> | 3 | <% if activity.kind_of?(ActionTracker::Record) %> |
4 | - <%= render :partial => 'profile_activity', :locals => {:activity => activity} %> | 4 | + <%= render :partial => 'profile_activity', :locals => {:activity => activity} if activity.visible? %> |
5 | <% else %> | 5 | <% else %> |
6 | <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %> | 6 | <%= render :partial => 'profile_scrap', :locals => {:scrap => activity } %> |
7 | <% end %> | 7 | <% end %> |
db/schema.rb
@@ -30,6 +30,7 @@ ActiveRecord::Schema.define(:version => 20120307200651) do | @@ -30,6 +30,7 @@ ActiveRecord::Schema.define(:version => 20120307200651) do | ||
30 | t.datetime "created_at" | 30 | t.datetime "created_at" |
31 | t.datetime "updated_at" | 31 | t.datetime "updated_at" |
32 | t.integer "comments_count", :default => 0 | 32 | t.integer "comments_count", :default => 0 |
33 | + t.boolean "visible", :default => true | ||
33 | end | 34 | end |
34 | 35 | ||
35 | add_index "action_tracker", ["target_id", "target_type"], :name => "index_action_tracker_on_dispatcher_id_and_dispatcher_type" | 36 | add_index "action_tracker", ["target_id", "target_type"], :name => "index_action_tracker_on_dispatcher_id_and_dispatcher_type" |