68 |
68 |
ROLE_MAPPING = {'admin' => manager_role,
|
69 |
69 |
'developer' => developer_role
|
70 |
70 |
}
|
|
71 |
|
|
72 |
PROJECT_CUSTOM_FIELD_VALUES = {}
|
71 |
73 |
|
72 |
74 |
class ::Time
|
73 |
75 |
class << self
|
... | ... | |
657 |
659 |
@@trac_db_schema = schema
|
658 |
660 |
end
|
659 |
661 |
|
|
662 |
def self.set_project_custom_field_value(custom_field, val)
|
|
663 |
PROJECT_CUSTOM_FIELD_VALUES[custom_field.id] = val
|
|
664 |
|
|
665 |
# validate input
|
|
666 |
v = CustomValue.new(:custom_field => custom_field.clone, :value => val, :customized => nil)
|
|
667 |
|
|
668 |
# Return false if value is not valid
|
|
669 |
v.errors.each_full { |msg| puts msg } if !v.valid?
|
|
670 |
v.valid?
|
|
671 |
end
|
|
672 |
|
660 |
673 |
mattr_reader :trac_directory, :trac_adapter, :trac_db_host, :trac_db_port, :trac_db_name, :trac_db_schema, :trac_db_username, :trac_db_password
|
661 |
674 |
|
662 |
675 |
def self.trac_db_path; "#{trac_directory}/db/trac.db" end
|
... | ... | |
668 |
681 |
# create the target project
|
669 |
682 |
project = Project.new :name => identifier.humanize,
|
670 |
683 |
:description => ''
|
|
684 |
project.custom_field_values = PROJECT_CUSTOM_FIELD_VALUES
|
671 |
685 |
project.identifier = identifier
|
672 |
|
puts "Unable to create a project with identifier '#{identifier}'!" unless project.save
|
673 |
|
# enable issues and wiki for the created project
|
674 |
|
project.enabled_module_names = ['issue_tracking', 'wiki']
|
|
686 |
if project.save
|
|
687 |
# enable issues and wiki for the created project
|
|
688 |
project.enabled_module_names = ['issue_tracking', 'wiki']
|
|
689 |
else
|
|
690 |
puts "Unable to create a project with identifier '#{identifier}'!"
|
|
691 |
project.errors.each_full { |msg| puts msg }
|
|
692 |
end
|
675 |
693 |
else
|
676 |
694 |
puts
|
677 |
695 |
puts "This project already exists in your Redmine database."
|
... | ... | |
756 |
774 |
prompt('Trac database password') {|password| TracMigrate.set_trac_db_password password}
|
757 |
775 |
end
|
758 |
776 |
prompt('Trac database encoding', :default => 'UTF-8') {|encoding| TracMigrate.encoding encoding}
|
|
777 |
|
|
778 |
Project.new.custom_field_values.each do |custom_field_value|
|
|
779 |
custom_field = custom_field_value.custom_field
|
|
780 |
|
|
781 |
name = custom_field.name
|
|
782 |
options = {}
|
|
783 |
|
|
784 |
name += '*' if custom_field.is_required
|
|
785 |
options[:default] = custom_field.default_value if custom_field.default_value
|
|
786 |
|
|
787 |
prompt(name, options) do |val|
|
|
788 |
TracMigrate.set_project_custom_field_value custom_field, val
|
|
789 |
end
|
|
790 |
end
|
|
791 |
|
759 |
792 |
prompt('Target project identifier') {|identifier| TracMigrate.target_project_identifier identifier}
|
760 |
793 |
puts
|
761 |
794 |
|