Updating code to fix issues related to #5

This commit is contained in:
Daniel Munn 2012-06-18 23:12:34 +01:00
parent bad46400c7
commit d6ee91342a
2 changed files with 15 additions and 6 deletions

View File

@ -53,13 +53,20 @@ class DmsfFile < ActiveRecord::Base
:datetime => Proc.new {|o| o.updated_at },
:author => Proc.new {|o| o.last_revision.user }
#TODO: place into better place
@@storage_path = Setting.plugin_redmine_dmsf["dmsf_storage_directory"].strip
def self.storage_path
storage_dir = Setting.plugin_redmine_dmsf["dmsf_storage_directory"].strip
if !File.exists?(storage_dir)
Dir.mkdir(storage_dir)
if !File.exists?(@@storage_path)
Dir.mkdir(@@storage_path)
end
storage_dir
@@storage_path
end
# Lets introduce a write for storage path, that way we can also
# better interact from test-cases etc
def self.storage_path=(obj)
@@storage_path = obj
end
def self.project_root_files(project)
@ -384,4 +391,4 @@ class DmsfFile < ActiveRecord::Base
[results, results_count]
end
end
end

View File

@ -193,8 +193,10 @@ module RedmineDmsf
# Process incoming MKCOL request
#
# Create a DmsfFolder at location requested, only if parent is a folder (or root)
# - 2012-06-18: Ensure item is only functional if project is enabled for dmsf
def make_collection
if (request.body.read.to_s == '')
raise NotFound if project.nil? || project.id.nil? || project.module_enabled?('dmsf').nil?
raise Forbidden unless User.current.admin? || User.current.allowed_to?(:folder_manipulation, project)
return MethodNotAllowed if exist? #If we already exist, why waste the time trying to save?
parent_folder = nil