Old 'TODO' either solved or removed
This commit is contained in:
parent
3351ab44a6
commit
31463cdba2
@ -59,21 +59,17 @@ class DmsfFilesController < ApplicationController
|
||||
end
|
||||
|
||||
@revision = @file.last_revision
|
||||
# TODO: line bellow is to handle old installations with errors in data handling
|
||||
@revision.name = @file.name
|
||||
|
||||
@revision_pages = Paginator.new @file.revisions.visible.count, params['per_page'] ? params['per_page'].to_i : 25, params['page']
|
||||
|
||||
render :layout => !request.xhr?
|
||||
end
|
||||
|
||||
#TODO: don't create revision if nothing change
|
||||
def create_revision
|
||||
if params[:dmsf_file_revision]
|
||||
if @file.locked_for_user?
|
||||
flash[:error] = l(:error_file_is_locked)
|
||||
else
|
||||
#TODO: validate folder_id
|
||||
@revision = DmsfFileRevision.new(params[:dmsf_file_revision])
|
||||
|
||||
@revision.file = @file
|
||||
|
||||
@ -79,8 +79,6 @@ class DmsfUploadController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
#TODO: flash notice when files saved and unlocked
|
||||
#TODO: separate control for approval
|
||||
def commit_files
|
||||
commited_files = params[:commited_files]
|
||||
if commited_files && commited_files.is_a?(Hash)
|
||||
|
||||
@ -227,7 +227,6 @@ class DmsfFile < ActiveRecord::Base
|
||||
|
||||
if file.save && self.last_revision
|
||||
new_revision = self.last_revision.clone
|
||||
|
||||
new_revision.file = file
|
||||
new_revision.folder = folder
|
||||
new_revision.project = folder ? folder.project : project
|
||||
|
||||
@ -33,21 +33,21 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
acts_as_customizable
|
||||
|
||||
acts_as_event :title => Proc.new {|o| "#{l(:label_dmsf_updated)}: #{o.file.dmsf_path_str}"},
|
||||
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o.file}},
|
||||
:datetime => Proc.new {|o| o.updated_at },
|
||||
:description => Proc.new {|o| o.comment },
|
||||
:author => Proc.new {|o| o.user }
|
||||
:url => Proc.new {|o| {:controller => 'dmsf_files', :action => 'show', :id => o.file}},
|
||||
:datetime => Proc.new {|o| o.updated_at },
|
||||
:description => Proc.new {|o| o.comment },
|
||||
:author => Proc.new {|o| o.user }
|
||||
|
||||
acts_as_activity_provider :type => 'dmsf_files',
|
||||
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
|
||||
:author_key => "#{DmsfFileRevision.table_name}.user_id",
|
||||
:permission => :view_dmsf_files,
|
||||
:find_options => {:select => "#{DmsfFileRevision.table_name}.*",
|
||||
:joins =>
|
||||
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
|
||||
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id",
|
||||
:conditions => ["#{DmsfFile.table_name}.deleted = :false", {:false => false}]
|
||||
}
|
||||
:timestamp => "#{DmsfFileRevision.table_name}.updated_at",
|
||||
:author_key => "#{DmsfFileRevision.table_name}.user_id",
|
||||
:permission => :view_dmsf_files,
|
||||
:find_options => {:select => "#{DmsfFileRevision.table_name}.*",
|
||||
:joins =>
|
||||
"INNER JOIN #{DmsfFile.table_name} ON #{DmsfFileRevision.table_name}.dmsf_file_id = #{DmsfFile.table_name}.id " +
|
||||
"INNER JOIN #{Project.table_name} ON #{DmsfFile.table_name}.project_id = #{Project.table_name}.id",
|
||||
:conditions => ["#{DmsfFile.table_name}.deleted = :false", {:false => false}]
|
||||
}
|
||||
|
||||
validates :title, :name, :presence => true
|
||||
validates_format_of :name, :with => DmsfFolder.invalid_characters,
|
||||
@ -57,7 +57,6 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
filename[0, (filename.length - File.extname(filename).length)]
|
||||
end
|
||||
|
||||
# TODO: check if better to move to dmsf_upload class
|
||||
def self.filename_to_title(filename)
|
||||
remove_extension(filename).gsub(/_+/, ' ');
|
||||
end
|
||||
@ -131,7 +130,6 @@ class DmsfFileRevision < ActiveRecord::Base
|
||||
content_type.to_s
|
||||
end
|
||||
|
||||
# TODO: use standard clone method
|
||||
def clone
|
||||
new_revision = DmsfFileRevision.new
|
||||
new_revision.file = self.file
|
||||
|
||||
@ -32,7 +32,7 @@ class DmsfWorkflow < ActiveRecord::Base
|
||||
def participiants
|
||||
users = Array.new
|
||||
self.dmsf_workflow_steps.each do |step|
|
||||
users << step.user
|
||||
users << step.user unless users.include? step.user
|
||||
end
|
||||
users
|
||||
end
|
||||
|
||||
@ -43,6 +43,18 @@ class DmsfWorkflowTest < RedmineDmsf::Test::UnitTest
|
||||
|
||||
def test_truth
|
||||
assert_kind_of DmsfWorkflow, @wf1
|
||||
assert_kind_of DmsfWorkflow, @wf2
|
||||
assert_kind_of DmsfWorkflowStep, @wfs1
|
||||
assert_kind_of DmsfWorkflowStep, @wfs2
|
||||
assert_kind_of DmsfWorkflowStep, @wfs3
|
||||
assert_kind_of DmsfWorkflowStep, @wfs4
|
||||
assert_kind_of DmsfWorkflowStep, @wfs5
|
||||
assert_kind_of DmsfWorkflowStepAssignment, @wfsa1
|
||||
assert_kind_of DmsfWorkflowStepAction, @wfsac1
|
||||
assert_kind_of DmsfFileRevision, @revision1
|
||||
assert_kind_of DmsfFileRevision, @revision2
|
||||
assert_kind_of Project, @project
|
||||
assert_kind_of Project, @project5
|
||||
end
|
||||
|
||||
def test_create
|
||||
@ -182,21 +194,17 @@ class DmsfWorkflowTest < RedmineDmsf::Test::UnitTest
|
||||
end
|
||||
|
||||
def test_try_finish
|
||||
#def try_finish(dmsf_file_revision_id, action, user_id)
|
||||
# TODO: There is a strange error: 'ActiveRecord::RecordNotFound: Couldn't find Project with id=0'
|
||||
# while saving the revision
|
||||
# @revision1.set_workflow @wf1.id, 'start'
|
||||
# @wf1.try_finish @revision1.id, @wfsac1, User.current.id
|
||||
# @revision1.reload
|
||||
# assert_equal @revision1.workflow, DmsfWorkflow::STATE_APPROVED
|
||||
# @revision2.set_workflow @wf1.id, 'start'
|
||||
# @wf1.try_finish @revision2.id, @wfsac1, User.current.id
|
||||
# assert_equal @revision2.workflow, DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
||||
assert true
|
||||
@revision1.set_workflow @wf1.id, 'start'
|
||||
@wf1.try_finish @revision1, @wfsac1, User.current.id
|
||||
@revision1.reload
|
||||
assert_equal @revision1.workflow, DmsfWorkflow::STATE_APPROVED
|
||||
@revision2.set_workflow @wf1.id, 'start'
|
||||
@wf1.try_finish @revision2, @wfsac1, User.current.id
|
||||
assert_equal @revision2.workflow, DmsfWorkflow::STATE_WAITING_FOR_APPROVAL
|
||||
end
|
||||
|
||||
def test_participiants
|
||||
# TODO:
|
||||
assert true
|
||||
participiants = @wf1.participiants
|
||||
assert_equal participiants.count, 2
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user