summaryrefslogtreecommitdiffstats
path: root/app/models/wiki_page.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-09 16:54:46 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-12-09 16:54:46 +0000
commit5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f (patch)
treeeb64711c0150fafb698da9d92eb0d6735a5461cf /app/models/wiki_page.rb
parent2b6e332318a3e0a9489d20280010bb2d00206d95 (diff)
downloadredmine-5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f.tar.gz
redmine-5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f.zip
AttachmentsController now handles attachments deletion.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2116 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r--app/models/wiki_page.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 2416fab74..0d96cc047 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -21,7 +21,7 @@ require 'enumerator'
class WikiPage < ActiveRecord::Base
belongs_to :wiki
has_one :content, :class_name => 'WikiContent', :foreign_key => 'page_id', :dependent => :destroy
- has_many :attachments, :as => :container, :dependent => :destroy
+ acts_as_attachable :delete_permission => :delete_wiki_pages_attachments
acts_as_tree :order => 'title'
acts_as_event :title => Proc.new {|o| "#{l(:label_wiki)}: #{o.title}"},
@@ -111,6 +111,10 @@ class WikiPage < ActiveRecord::Base
def editable_by?(usr)
!protected? || usr.allowed_to?(:protect_wiki_pages, wiki.project)
end
+
+ def attachments_deletable?(usr=User.current)
+ editable_by?(usr) && super(usr)
+ end
def parent_title
@parent_title || (self.parent && self.parent.pretty_title)