summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb3
-rw-r--r--lib/redmine/default_data/loader.rb10
-rw-r--r--lib/redmine/helpers/time_report.rb4
-rw-r--r--lib/tasks/migrate_from_mantis.rake14
-rw-r--r--lib/tasks/migrate_from_trac.rake12
5 files changed, 21 insertions, 22 deletions
diff --git a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
index cfee2c5f9..1b366fa5a 100644
--- a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -44,8 +44,7 @@ module Redmine
end
def available_custom_fields
- CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
- :order => 'position')
+ CustomField.where("type = '#{self.class.name}CustomField'").sorted.all
end
# Sets the values of the object's custom fields
diff --git a/lib/redmine/default_data/loader.rb b/lib/redmine/default_data/loader.rb
index a91f6e22c..70629e9d3 100644
--- a/lib/redmine/default_data/loader.rb
+++ b/lib/redmine/default_data/loader.rb
@@ -139,15 +139,15 @@ module Redmine
rejected = IssueStatus.create!(:name => l(:default_issue_status_rejected), :is_closed => true, :is_default => false, :position => 6)
# Workflow
- Tracker.find(:all).each { |t|
- IssueStatus.find(:all).each { |os|
- IssueStatus.find(:all).each { |ns|
+ Tracker.all.each { |t|
+ IssueStatus.all.each { |os|
+ IssueStatus.all.each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => manager.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
}
}
}
- Tracker.find(:all).each { |t|
+ Tracker.all.each { |t|
[new, in_progress, resolved, feedback].each { |os|
[in_progress, resolved, feedback, closed].each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => developer.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
@@ -155,7 +155,7 @@ module Redmine
}
}
- Tracker.find(:all).each { |t|
+ Tracker.all.each { |t|
[new, in_progress, resolved, feedback].each { |os|
[closed].each { |ns|
WorkflowTransition.create!(:tracker_id => t.id, :role_id => reporter.id, :old_status_id => os.id, :new_status_id => ns.id) unless os == ns
diff --git a/lib/redmine/helpers/time_report.rb b/lib/redmine/helpers/time_report.rb
index 80e60529e..2c29f6ac8 100644
--- a/lib/redmine/helpers/time_report.rb
+++ b/lib/redmine/helpers/time_report.rb
@@ -144,14 +144,14 @@ module Redmine
end if @project
# Add list and boolean time entry custom fields
- TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
+ TimeEntryCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
@available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id ORDER BY c.value LIMIT 1)",
:format => cf.field_format,
:label => cf.name}
end
# Add list and boolean time entry activity custom fields
- TimeEntryActivityCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
+ TimeEntryActivityCustomField.all.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
@available_criteria["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Enumeration' AND c.customized_id = #{TimeEntry.table_name}.activity_id ORDER BY c.value LIMIT 1)",
:format => cf.field_format,
:label => cf.name}
diff --git a/lib/tasks/migrate_from_mantis.rake b/lib/tasks/migrate_from_mantis.rake
index 7570e820a..02ce9f472 100644
--- a/lib/tasks/migrate_from_mantis.rake
+++ b/lib/tasks/migrate_from_mantis.rake
@@ -53,7 +53,7 @@ task :migrate_from_mantis => :environment do
TRACKER_BUG = Tracker.find_by_position(1)
TRACKER_FEATURE = Tracker.find_by_position(2)
- roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
+ roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0]
developer_role = roles[1]
DEFAULT_ROLE = roles.last
@@ -241,7 +241,7 @@ task :migrate_from_mantis => :environment do
User.delete_all "login <> 'admin'"
users_map = {}
users_migrated = 0
- MantisUser.find(:all).each do |user|
+ MantisUser.all.each do |user|
u = User.new :firstname => encode(user.firstname),
:lastname => encode(user.lastname),
:mail => user.email,
@@ -263,7 +263,7 @@ task :migrate_from_mantis => :environment do
projects_map = {}
versions_map = {}
categories_map = {}
- MantisProject.find(:all).each do |project|
+ MantisProject.all.each do |project|
p = Project.new :name => encode(project.name),
:description => encode(project.description)
p.identifier = project.identifier
@@ -365,7 +365,7 @@ task :migrate_from_mantis => :environment do
# Bug relationships
print "Migrating bug relations"
- MantisBugRelationship.find(:all).each do |relation|
+ MantisBugRelationship.all.each do |relation|
next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
@@ -379,7 +379,7 @@ task :migrate_from_mantis => :environment do
# News
print "Migrating news"
News.destroy_all
- MantisNews.find(:all, :conditions => 'project_id > 0').each do |news|
+ MantisNews.where('project_id > 0').all.each do |news|
next unless projects_map[news.project_id]
n = News.new :project_id => projects_map[news.project_id],
:title => encode(news.headline[0..59]),
@@ -395,7 +395,7 @@ task :migrate_from_mantis => :environment do
# Custom fields
print "Migrating custom fields"
IssueCustomField.destroy_all
- MantisCustomField.find(:all).each do |field|
+ MantisCustomField.all.each do |field|
f = IssueCustomField.new :name => field.name[0..29],
:field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
:min_length => field.length_min,
@@ -407,7 +407,7 @@ task :migrate_from_mantis => :environment do
print '.'
STDOUT.flush
# Trackers association
- f.trackers = Tracker.find :all
+ f.trackers = Tracker.all
# Projects association
field.projects.each do |project|
diff --git a/lib/tasks/migrate_from_trac.rake b/lib/tasks/migrate_from_trac.rake
index dcdd8f0f0..1c7b7bb38 100644
--- a/lib/tasks/migrate_from_trac.rake
+++ b/lib/tasks/migrate_from_trac.rake
@@ -61,7 +61,7 @@ namespace :redmine do
'patch' =>TRACKER_FEATURE
}
- roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
+ roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0]
developer_role = roles[1]
DEFAULT_ROLE = roles.last
@@ -390,7 +390,7 @@ namespace :redmine do
# Components
print "Migrating components"
issues_category_map = {}
- TracComponent.find(:all).each do |component|
+ TracComponent.all.each do |component|
print '.'
STDOUT.flush
c = IssueCategory.new :project => @target_project,
@@ -404,7 +404,7 @@ namespace :redmine do
# Milestones
print "Migrating milestones"
version_map = {}
- TracMilestone.find(:all).each do |milestone|
+ TracMilestone.all.each do |milestone|
print '.'
STDOUT.flush
# First we try to find the wiki page...
@@ -443,7 +443,7 @@ namespace :redmine do
:field_format => 'string')
next if f.new_record?
- f.trackers = Tracker.find(:all)
+ f.trackers = Tracker.all
f.projects << @target_project
custom_field_map[field.name] = f
end
@@ -454,7 +454,7 @@ namespace :redmine do
r = IssueCustomField.new(:name => 'Resolution',
:field_format => 'list',
:is_filter => true) if r.nil?
- r.trackers = Tracker.find(:all)
+ r.trackers = Tracker.all
r.projects << @target_project
r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
r.save!
@@ -549,7 +549,7 @@ namespace :redmine do
# Wiki
print "Migrating wiki"
if wiki.save
- TracWikiPage.find(:all, :order => 'name, version').each do |page|
+ TracWikiPage.order('name, version').all.each do |page|
# Do not migrate Trac manual wiki pages
next if TRAC_WIKI_PAGES.include?(page.name)
wiki_edit_count += 1