diff --git a/app/models/memo.rb b/app/models/memo.rb index 4ca5f888c..56dd3e99c 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -34,9 +34,9 @@ class Memo < ActiveRecord::Base "forum_id", "last_memo_id", "lock", + "sticky", "parent_id", - "replies_count", - "sticky" + "replies_count" after_create :add_author_as_watcher, :reset_counters! # after_update :update_memos_forum @@ -67,10 +67,6 @@ class Memo < ActiveRecord::Base end forum.reset_counters! end - - def sticky=(arg) - write_attribute :sticky, (arg == true || arg.to_s == 'true' ? true : false) - end def sticky? sticky == 1 @@ -90,10 +86,14 @@ class Memo < ActiveRecord::Base end def destroyable_by? user - user && user.logged? && Forum.find(self.forum_id).creator_id == user.id || user.admin? + (user && user.logged? && (Forum.find(self.forum_id).creator_id == user.id) ) || user.admin? #self.author == user || user.admin? end + def deleted_attach_able_by? user + (user && user.logged? && (self.author == user) ) || user.admin? + end + private def add_author_as_watcher diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 5bdde8b9c..66b55fd15 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -33,7 +33,7 @@ <%= raw @memo.content %>
<% if @memo.attachments.any?%> - <% options = {:author => true} %> + <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %> <% end %>
@@ -81,7 +81,7 @@<% if reply.attachments.any?%> - <% options = {:author => true, :deletable => false} %> + <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> <% end %>