download access

This commit is contained in:
yanxd 2013-12-12 09:14:10 +08:00
parent 0416902cde
commit 5cae2010c1
2 changed files with 9 additions and 9 deletions

View File

@ -34,9 +34,9 @@ class Memo < ActiveRecord::Base
"forum_id", "forum_id",
"last_memo_id", "last_memo_id",
"lock", "lock",
"sticky",
"parent_id", "parent_id",
"replies_count", "replies_count"
"sticky"
after_create :add_author_as_watcher, :reset_counters! after_create :add_author_as_watcher, :reset_counters!
# after_update :update_memos_forum # after_update :update_memos_forum
@ -68,10 +68,6 @@ class Memo < ActiveRecord::Base
forum.reset_counters! forum.reset_counters!
end end
def sticky=(arg)
write_attribute :sticky, (arg == true || arg.to_s == 'true' ? true : false)
end
def sticky? def sticky?
sticky == 1 sticky == 1
end end
@ -90,10 +86,14 @@ class Memo < ActiveRecord::Base
end end
def destroyable_by? user 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? #self.author == user || user.admin?
end end
def deleted_attach_able_by? user
(user && user.logged? && (self.author == user) ) || user.admin?
end
private private
def add_author_as_watcher def add_author_as_watcher

View File

@ -33,7 +33,7 @@
<%= raw @memo.content %> <%= raw @memo.content %>
<p> <p>
<% if @memo.attachments.any?%> <% 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} %> <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
<% end %> <% end %>
</p> </p>
@ -81,7 +81,7 @@
<!-- <div class="wiki">< %=h reply.content.html_safe %></div> --> <!-- <div class="wiki">< %=h reply.content.html_safe %></div> -->
<p> <p>
<% if reply.attachments.any?%> <% 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} %> <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %>
<% end %> <% end %>
</p> </p>