diff --git a/app/seeders/basic_data/activity_seeder.rb b/app/seeders/basic_data/activity_seeder.rb index 0b50446ecc..97e65c4e4d 100644 --- a/app/seeders/basic_data/activity_seeder.rb +++ b/app/seeders/basic_data/activity_seeder.rb @@ -45,22 +45,7 @@ module BasicData end def data - if OpenProject::Configuration['edition'] == 'bim' - [ - { name: I18n.t(:default_activity_management), position: 1, is_default: true }, - { name: I18n.t(:default_activity_specification), position: 2, is_default: false }, - { name: I18n.t(:default_activity_other), position: 6, is_default: false } - ] - else - [ - { name: I18n.t(:default_activity_management), position: 1, is_default: true }, - { name: I18n.t(:default_activity_specification), position: 2, is_default: false }, - { name: I18n.t(:default_activity_development), position: 3, is_default: false }, - { name: I18n.t(:default_activity_testing), position: 4, is_default: false }, - { name: I18n.t(:default_activity_support), position: 5, is_default: false }, - { name: I18n.t(:default_activity_other), position: 6, is_default: false } - ] - end + raise NotImplementedError end end end diff --git a/app/seeders/basic_data/status_seeder.rb b/app/seeders/basic_data/status_seeder.rb index e3b62bb9ed..0a80b68af1 100644 --- a/app/seeders/basic_data/status_seeder.rb +++ b/app/seeders/basic_data/status_seeder.rb @@ -45,66 +45,7 @@ module BasicData end def data - color_names = [ - 'teal-1', # new - 'indigo-1', # in specification - 'teal-3', # specified - 'red-6', # confirmed - 'yellow-2', # tbs - 'lime-2', # scheduled - 'cyan-3', # in progress - 'cyan-3', # in development - 'teal-6', # developed - 'teal-7', # in testing - 'teal-9', # tested - 'red-9', # test_failed - 'gray-3', # closed - 'orange-3', # on hold - 'red-3', # rejected - ] - - # When selecting for an array of values, implicit order is applied - # so we need to restore values by their name. - colors_by_name = Color.where(name: color_names).index_by(&:name) - colors = color_names.collect { |name| colors_by_name[name].id } - - if OpenProject::Configuration['edition'] == 'bim' - [ - { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true, position: 1 }, - { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false, position: 2 }, - { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false, position: 3 }, - { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false, position: 4 }, - { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false, position: 5 }, - { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false, position: 6 }, - { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false, position: 7 }, - { name: I18n.t(:default_status_in_development), color_id: colors[7], is_closed: false, is_default: false, position: 8 }, - { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false, position: 9 }, - { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false, position: 10 }, - { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false, position: 11 }, - { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false, position: 12 }, - { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false, position: 13 }, - { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false, position: 14 }, - { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false, position: 15 } - ] - else - [ - { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true, position: 1 }, - { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false, position: 2 }, - { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false, position: 3 }, - { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false, position: 4 }, - { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false, position: 5 }, - { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false, position: 6 }, - { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false, position: 7 }, - { name: I18n.t(:default_status_in_development), color_id: colors[7], is_closed: false, is_default: false, position: 8 }, - { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false, position: 9 }, - { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false, position: 10 }, - { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false, position: 11 }, - { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false, position: 12 }, - { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false, position: 13 }, - { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false, position: 14 }, - { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false, position: 15 } - ] - end + raise NotImplementedError end end end diff --git a/app/seeders/basic_data/type_seeder.rb b/app/seeders/basic_data/type_seeder.rb index 5cfcb164e1..0e250cdcfb 100644 --- a/app/seeders/basic_data/type_seeder.rb +++ b/app/seeders/basic_data/type_seeder.rb @@ -73,26 +73,7 @@ module BasicData end def type_table - if OpenProject::Configuration['edition'] == 'bim' - { # position is_default color_id is_in_roadmap is_milestone - task: [1, true, :default_color_blue, true, false, :default_type_task], - milestone: [2, true, :default_color_green_light, false, true, :default_type_milestone], - phase: [3, true, :default_color_blue_dark, false, false, :default_type_phase], - building_model: [4, true, :default_color_blue, true, false, 'seeders.bim.default_type_building_model'], - defect: [5, true, :default_color_red, true, false, 'seeders.bim.default_type_defect'], - approval: [6, true, :default_color_grey_dark, true, false, 'seeders.bim.default_type_approval'] - } - else - { # position is_default color_id is_in_roadmap is_milestone - task: [1, true, :default_color_blue, true, false, :default_type_task], - milestone: [2, true, :default_color_green_light, false, true, :default_type_milestone], - phase: [3, true, :default_color_blue_dark, false, false, :default_type_phase], - feature: [4, true, :default_color_blue, true, false, :default_type_feature], - epic: [5, true, :default_color_orange, true, false, :default_type_epic], - user_story: [6, true, :default_color_grey_dark, true, false, :default_type_user_story], - bug: [7, true, :default_color_red, true, false, :default_type_bug] - } - end + raise NotImplementedError end end end diff --git a/app/seeders/basic_data/workflow_seeder.rb b/app/seeders/basic_data/workflow_seeder.rb index 2f95a00cb4..d34470977f 100644 --- a/app/seeders/basic_data/workflow_seeder.rb +++ b/app/seeders/basic_data/workflow_seeder.rb @@ -70,10 +70,10 @@ module BasicData manager = Role.where(name: I18n.t(:default_role_project_admin)).first puts ' ↳ Types' - TypeSeeder.new.seed! + type_seeder_class.new.seed! puts ' ↳ Statuses' - StatusSeeder.new.seed! + status_seeder_class.new.seed! # Workflow - Each type has its own workflow workflows.each { |type_id, statuses_for_type| @@ -92,45 +92,15 @@ module BasicData end def workflows - types = Type.all - types = types.map { |t| { t.name => t.id } }.reduce({}, :merge) + raise NotImplementedError + end - new = Status.find_by(name: I18n.t(:default_status_new)) - in_specification = Status.find_by(name: I18n.t(:default_status_in_specification)) - specified = Status.find_by(name: I18n.t(:default_status_specified)) - confirmed = Status.find_by(name: I18n.t(:default_status_confirmed)) - to_be_scheduled = Status.find_by(name: I18n.t(:default_status_to_be_scheduled)) - scheduled = Status.find_by(name: I18n.t(:default_status_scheduled)) - in_progress = Status.find_by(name: I18n.t(:default_status_in_progress)) - in_development = Status.find_by(name: I18n.t(:default_status_in_development)) - developed = Status.find_by(name: I18n.t(:default_status_developed)) - in_testing = Status.find_by(name: I18n.t(:default_status_in_testing)) - tested = Status.find_by(name: I18n.t(:default_status_tested)) - test_failed = Status.find_by(name: I18n.t(:default_status_test_failed)) - closed = Status.find_by(name: I18n.t(:default_status_closed)) - on_hold = Status.find_by(name: I18n.t(:default_status_on_hold)) - rejected = Status.find_by(name: I18n.t(:default_status_rejected)) + def type_seeder_class + raise NotImplementedError + end - if OpenProject::Configuration['edition'] == 'bim' - { - types[I18n.t(:default_type_task)] => [new, in_progress, on_hold, rejected, closed], - types[I18n.t(:default_type_milestone)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], - types[I18n.t(:default_type_phase)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], - types[I18n.t('seeders.bim.default_type_building_model')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - types[I18n.t('seeders.bim.default_type_defect')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - types[I18n.t('seeders.bim.default_type_approval')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - } - else - { - types[I18n.t(:default_type_task)] => [new, in_progress, on_hold, rejected, closed], - types[I18n.t(:default_type_milestone)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], - types[I18n.t(:default_type_phase)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], - types[I18n.t(:default_type_feature)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - types[I18n.t(:default_type_epic)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - types[I18n.t(:default_type_user_story)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], - types[I18n.t(:default_type_bug)] => [new, confirmed, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed] - } - end + def status_seeder_class + raise NotImplementedError end end end diff --git a/app/seeders/basic_data_seeder.rb b/app/seeders/basic_data_seeder.rb index 25e6b92397..b817989e99 100644 --- a/app/seeders/basic_data_seeder.rb +++ b/app/seeders/basic_data_seeder.rb @@ -28,16 +28,7 @@ #++ class BasicDataSeeder < CompositeSeeder def data_seeder_classes - [ - BasicData::BuiltinRolesSeeder, - BasicData::RoleSeeder, - BasicData::ActivitySeeder, - BasicData::ColorSeeder, - BasicData::ColorSchemeSeeder, - BasicData::WorkflowSeeder, - BasicData::PrioritySeeder, - BasicData::SettingSeeder - ] + raise NotImplementedError end def namespace diff --git a/app/seeders/bim_seeder/basic_data/bim_activity_seeder.rb b/app/seeders/bim_seeder/basic_data/bim_activity_seeder.rb new file mode 100644 index 0000000000..8bd1f08ad0 --- /dev/null +++ b/app/seeders/bim_seeder/basic_data/bim_activity_seeder.rb @@ -0,0 +1,41 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module BimSeeder + module BasicData + class BimActivitySeeder < ::BasicData::ActivitySeeder + def data + [ + { name: I18n.t(:default_activity_management), position: 1, is_default: true }, + { name: I18n.t(:default_activity_specification), position: 2, is_default: false }, + { name: I18n.t(:default_activity_other), position: 3, is_default: false } + ] + end + end + end +end diff --git a/app/seeders/bim_seeder/basic_data/bim_status_seeder.rb b/app/seeders/bim_seeder/basic_data/bim_status_seeder.rb new file mode 100644 index 0000000000..d50d2d87aa --- /dev/null +++ b/app/seeders/bim_seeder/basic_data/bim_status_seeder.rb @@ -0,0 +1,96 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module BimSeeder + module BasicData + class BimStatusSeeder < ::BasicData::StatusSeeder + def data + color_names = [ + 'teal-1', # new + 'indigo-1', # in specification + 'teal-3', # specified + 'red-6', # confirmed + 'yellow-2', # tbs + 'lime-2', # scheduled + 'cyan-3', # in progress + 'cyan-3', # in development + 'teal-6', # developed + 'teal-7', # in testing + 'teal-9', # tested + 'red-9', # test_failed + 'gray-3', # closed + 'orange-3', # on hold + 'red-3', # rejected + ] + + # When selecting for an array of values, implicit order is applied + # so we need to restore values by their name. + colors_by_name = Color.where(name: color_names).index_by(&:name) + colors = color_names.collect { |name| colors_by_name[name].id } + + if OpenProject::Configuration['edition'] == 'bim' + [ + { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true, position: 1 }, + { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false, position: 2 }, + { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false, position: 3 }, + { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false, position: 4 }, + { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false, position: 5 }, + { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false, position: 6 }, + { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false, position: 7 }, + { name: I18n.t(:default_status_in_development), color_id: colors[7], is_closed: false, is_default: false, position: 8 }, + { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false, position: 9 }, + { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false, position: 10 }, + { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false, position: 11 }, + { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false, position: 12 }, + { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false, position: 13 }, + { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false, position: 14 }, + { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false, position: 15 } + ] + else + [ + { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true, position: 1 }, + { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false, position: 2 }, + { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false, position: 3 }, + { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false, position: 4 }, + { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false, position: 5 }, + { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false, position: 6 }, + { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false, position: 7 }, + { name: I18n.t(:default_status_in_development), color_id: colors[7], is_closed: false, is_default: false, position: 8 }, + { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false, position: 9 }, + { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false, position: 10 }, + { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false, position: 11 }, + { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false, position: 12 }, + { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false, position: 13 }, + { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false, position: 14 }, + { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false, position: 15 } + ] + end + end + end + end +end diff --git a/app/seeders/bim_seeder/basic_data/bim_type_seeder.rb b/app/seeders/bim_seeder/basic_data/bim_type_seeder.rb new file mode 100644 index 0000000000..b9f89bb79c --- /dev/null +++ b/app/seeders/bim_seeder/basic_data/bim_type_seeder.rb @@ -0,0 +1,44 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module BimSeeder + module BasicData + class BimTypeSeeder < ::BasicData::TypeSeeder + def type_table + { # position is_default color_id is_in_roadmap is_milestone + task: [1, true, :default_color_blue, true, false, :default_type_task], + milestone: [2, true, :default_color_green_light, false, true, :default_type_milestone], + phase: [3, true, :default_color_blue_dark, false, false, :default_type_phase], + building_model: [4, true, :default_color_blue, true, false, 'seeders.bim.default_type_building_model'], + defect: [5, true, :default_color_red, true, false, 'seeders.bim.default_type_defect'], + approval: [6, true, :default_color_grey_dark, true, false, 'seeders.bim.default_type_approval'] + } + end + end + end +end diff --git a/app/seeders/bim_seeder/basic_data/bim_workflow_seeder.rb b/app/seeders/bim_seeder/basic_data/bim_workflow_seeder.rb new file mode 100644 index 0000000000..4664304b1d --- /dev/null +++ b/app/seeders/bim_seeder/basic_data/bim_workflow_seeder.rb @@ -0,0 +1,71 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module BimSeeder + module BasicData + class BimWorkflowSeeder < ::BasicData::WorkflowSeeder + def workflows + types = Type.all + types = types.map { |t| { t.name => t.id } }.reduce({}, :merge) + + new = Status.find_by(name: I18n.t(:default_status_new)) + in_specification = Status.find_by(name: I18n.t(:default_status_in_specification)) + specified = Status.find_by(name: I18n.t(:default_status_specified)) + confirmed = Status.find_by(name: I18n.t(:default_status_confirmed)) + to_be_scheduled = Status.find_by(name: I18n.t(:default_status_to_be_scheduled)) + scheduled = Status.find_by(name: I18n.t(:default_status_scheduled)) + in_progress = Status.find_by(name: I18n.t(:default_status_in_progress)) + in_development = Status.find_by(name: I18n.t(:default_status_in_development)) + developed = Status.find_by(name: I18n.t(:default_status_developed)) + in_testing = Status.find_by(name: I18n.t(:default_status_in_testing)) + tested = Status.find_by(name: I18n.t(:default_status_tested)) + test_failed = Status.find_by(name: I18n.t(:default_status_test_failed)) + closed = Status.find_by(name: I18n.t(:default_status_closed)) + on_hold = Status.find_by(name: I18n.t(:default_status_on_hold)) + rejected = Status.find_by(name: I18n.t(:default_status_rejected)) + + { + types[I18n.t(:default_type_task)] => [new, in_progress, on_hold, rejected, closed], + types[I18n.t(:default_type_milestone)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], + types[I18n.t(:default_type_phase)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], + types[I18n.t('seeders.bim.default_type_building_model')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + types[I18n.t('seeders.bim.default_type_defect')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + types[I18n.t('seeders.bim.default_type_approval')] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + } + end + + def type_seeder_class + ::BimSeeder::BasicData::BimTypeSeeder + end + + def status_seeder_class + ::BimSeeder::BasicData::BimStatusSeeder + end + end + end +end diff --git a/app/seeders/bim_seeder/bim_basic_data_seeder.rb b/app/seeders/bim_seeder/bim_basic_data_seeder.rb new file mode 100644 index 0000000000..dc7354b29d --- /dev/null +++ b/app/seeders/bim_seeder/bim_basic_data_seeder.rb @@ -0,0 +1,44 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module BimSeeder + class BimBasicDataSeeder < ::BasicDataSeeder + def data_seeder_classes + [ + ::BasicData::BuiltinRolesSeeder, + ::BasicData::RoleSeeder, + ::BimSeeder::BasicData::BimActivitySeeder, + ::BasicData::ColorSeeder, + ::BasicData::ColorSchemeSeeder, + ::BimSeeder::BasicData::BimWorkflowSeeder, + ::BasicData::PrioritySeeder, + ::BasicData::SettingSeeder + ] + end + end +end diff --git a/app/seeders/demo_data/project_seeder.rb b/app/seeders/demo_data/project_seeder.rb index cab00785ef..92e7a22f40 100644 --- a/app/seeders/demo_data/project_seeder.rb +++ b/app/seeders/demo_data/project_seeder.rb @@ -30,11 +30,7 @@ module DemoData # Careful: The seeding recreates the seeded project before it runs, so any changes # on the seeded project will be lost. def seed_data! - seed_projects = ["scrum-project", "demo-project"] - - if OpenProject::Configuration['edition'] == 'bim' - seed_projects = ["demo-project"] - end + seed_projects = translate_with_base_url("seeders.#{OpenProject::Configuration['edition']}.demo_data.projects").keys seed_projects.each do |key| puts " ↳ Creating #{key} project..." diff --git a/app/seeders/root_seeder.rb b/app/seeders/root_seeder.rb index 1e8cb176d3..8afe24de85 100644 --- a/app/seeders/root_seeder.rb +++ b/app/seeders/root_seeder.rb @@ -53,7 +53,11 @@ class RootSeeder < Seeder ActiveRecord::Base.transaction do # Basic data needs be seeded before anything else. puts '*** Seeding basic data' - BasicDataSeeder.new.seed! + if OpenProject::Configuration['edition'] == 'bim' + BimSeeder::BimBasicDataSeeder.new.seed! + else + StandardSeeder::StandardBasicDataSeeder.new.seed! + end puts '*** Seeding admin user' AdminUserSeeder.new.seed! diff --git a/app/seeders/standard_seeder/basic_data/standard_activity_seeder.rb b/app/seeders/standard_seeder/basic_data/standard_activity_seeder.rb new file mode 100644 index 0000000000..ad937ccaf8 --- /dev/null +++ b/app/seeders/standard_seeder/basic_data/standard_activity_seeder.rb @@ -0,0 +1,44 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module StandardSeeder + module BasicData + class StandardActivitySeeder < ::BasicData::ActivitySeeder + def data + [ + { name: I18n.t(:default_activity_management), position: 1, is_default: true }, + { name: I18n.t(:default_activity_specification), position: 2, is_default: false }, + { name: I18n.t(:default_activity_development), position: 3, is_default: false }, + { name: I18n.t(:default_activity_testing), position: 4, is_default: false }, + { name: I18n.t(:default_activity_support), position: 5, is_default: false }, + { name: I18n.t(:default_activity_other), position: 6, is_default: false } + ] + end + end + end +end diff --git a/app/seeders/standard_seeder/basic_data/standard_status_seeder.rb b/app/seeders/standard_seeder/basic_data/standard_status_seeder.rb new file mode 100644 index 0000000000..0452358d60 --- /dev/null +++ b/app/seeders/standard_seeder/basic_data/standard_status_seeder.rb @@ -0,0 +1,76 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module StandardSeeder + module BasicData + class StandardStatusSeeder < ::BasicData::StatusSeeder + def data + color_names = [ + 'teal-1', # new + 'indigo-1', # in specification + 'teal-3', # specified + 'red-6', # confirmed + 'yellow-2', # tbs + 'lime-2', # scheduled + 'cyan-3', # in progress + 'cyan-3', # in development + 'teal-6', # developed + 'teal-7', # in testing + 'teal-9', # tested + 'red-9', # test_failed + 'gray-3', # closed + 'orange-3', # on hold + 'red-3', # rejected + ] + + # When selecting for an array of values, implicit order is applied + # so we need to restore values by their name. + colors_by_name = Color.where(name: color_names).index_by(&:name) + colors = color_names.collect { |name| colors_by_name[name].id } + + [ + { name: I18n.t(:default_status_new), color_id: colors[0], is_closed: false, is_default: true, position: 1 }, + { name: I18n.t(:default_status_in_specification), color_id: colors[1], is_closed: false, is_default: false, position: 2 }, + { name: I18n.t(:default_status_specified), color_id: colors[2], is_closed: false, is_default: false, position: 3 }, + { name: I18n.t(:default_status_confirmed), color_id: colors[3], is_closed: false, is_default: false, position: 4 }, + { name: I18n.t(:default_status_to_be_scheduled), color_id: colors[4], is_closed: false, is_default: false, position: 5 }, + { name: I18n.t(:default_status_scheduled), color_id: colors[5], is_closed: false, is_default: false, position: 6 }, + { name: I18n.t(:default_status_in_progress), color_id: colors[6], is_closed: false, is_default: false, position: 7 }, + { name: I18n.t(:default_status_in_development), color_id: colors[7], is_closed: false, is_default: false, position: 8 }, + { name: I18n.t(:default_status_developed), color_id: colors[8], is_closed: false, is_default: false, position: 9 }, + { name: I18n.t(:default_status_in_testing), color_id: colors[9], is_closed: false, is_default: false, position: 10 }, + { name: I18n.t(:default_status_tested), color_id: colors[10], is_closed: false, is_default: false, position: 11 }, + { name: I18n.t(:default_status_test_failed), color_id: colors[11], is_closed: false, is_default: false, position: 12 }, + { name: I18n.t(:default_status_closed), color_id: colors[12], is_closed: true, is_default: false, position: 13 }, + { name: I18n.t(:default_status_on_hold), color_id: colors[13], is_closed: false, is_default: false, position: 14 }, + { name: I18n.t(:default_status_rejected), color_id: colors[14], is_closed: true, is_default: false, position: 15 } + ] + end + end + end +end diff --git a/app/seeders/standard_seeder/basic_data/standard_type_seeder.rb b/app/seeders/standard_seeder/basic_data/standard_type_seeder.rb new file mode 100644 index 0000000000..1d92769c94 --- /dev/null +++ b/app/seeders/standard_seeder/basic_data/standard_type_seeder.rb @@ -0,0 +1,45 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module StandardSeeder + module BasicData + class StandardTypeSeeder < ::BasicData::TypeSeeder + def type_table + { # position is_default color_id is_in_roadmap is_milestone + task: [1, true, :default_color_blue, true, false, :default_type_task], + milestone: [2, true, :default_color_green_light, false, true, :default_type_milestone], + phase: [3, true, :default_color_blue_dark, false, false, :default_type_phase], + feature: [4, true, :default_color_blue, true, false, :default_type_feature], + epic: [5, true, :default_color_orange, true, false, :default_type_epic], + user_story: [6, true, :default_color_grey_dark, true, false, :default_type_user_story], + bug: [7, true, :default_color_red, true, false, :default_type_bug] + } + end + end + end +end diff --git a/app/seeders/standard_seeder/basic_data/standard_workflow_seeder.rb b/app/seeders/standard_seeder/basic_data/standard_workflow_seeder.rb new file mode 100644 index 0000000000..556bb16e44 --- /dev/null +++ b/app/seeders/standard_seeder/basic_data/standard_workflow_seeder.rb @@ -0,0 +1,72 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module StandardSeeder + module BasicData + class StandardWorkflowSeeder < ::BasicData::WorkflowSeeder + def workflows + types = Type.all + types = types.map { |t| { t.name => t.id } }.reduce({}, :merge) + + new = Status.find_by(name: I18n.t(:default_status_new)) + in_specification = Status.find_by(name: I18n.t(:default_status_in_specification)) + specified = Status.find_by(name: I18n.t(:default_status_specified)) + confirmed = Status.find_by(name: I18n.t(:default_status_confirmed)) + to_be_scheduled = Status.find_by(name: I18n.t(:default_status_to_be_scheduled)) + scheduled = Status.find_by(name: I18n.t(:default_status_scheduled)) + in_progress = Status.find_by(name: I18n.t(:default_status_in_progress)) + in_development = Status.find_by(name: I18n.t(:default_status_in_development)) + developed = Status.find_by(name: I18n.t(:default_status_developed)) + in_testing = Status.find_by(name: I18n.t(:default_status_in_testing)) + tested = Status.find_by(name: I18n.t(:default_status_tested)) + test_failed = Status.find_by(name: I18n.t(:default_status_test_failed)) + closed = Status.find_by(name: I18n.t(:default_status_closed)) + on_hold = Status.find_by(name: I18n.t(:default_status_on_hold)) + rejected = Status.find_by(name: I18n.t(:default_status_rejected)) + + { + types[I18n.t(:default_type_task)] => [new, in_progress, on_hold, rejected, closed], + types[I18n.t(:default_type_milestone)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], + types[I18n.t(:default_type_phase)] => [new, to_be_scheduled, scheduled, in_progress, on_hold, rejected, closed], + types[I18n.t(:default_type_feature)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + types[I18n.t(:default_type_epic)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + types[I18n.t(:default_type_user_story)] => [new, in_specification, specified, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed], + types[I18n.t(:default_type_bug)] => [new, confirmed, in_development, developed, in_testing, tested, test_failed, on_hold, rejected, closed] + } + end + + def type_seeder_class + ::StandardSeeder::BasicData::StandardTypeSeeder + end + + def status_seeder_class + ::StandardSeeder::BasicData::StandardStatusSeeder + end + end + end +end diff --git a/app/seeders/standard_seeder/standard_basic_data_seeder.rb b/app/seeders/standard_seeder/standard_basic_data_seeder.rb new file mode 100644 index 0000000000..b40e9bae9a --- /dev/null +++ b/app/seeders/standard_seeder/standard_basic_data_seeder.rb @@ -0,0 +1,44 @@ +#-- encoding: UTF-8 +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2017 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See docs/COPYRIGHT.rdoc for more details. +#++ +module StandardSeeder + class StandardBasicDataSeeder < ::BasicDataSeeder + def data_seeder_classes + [ + ::BasicData::BuiltinRolesSeeder, + ::BasicData::RoleSeeder, + ::StandardSeeder::BasicData::StandardActivitySeeder, + ::BasicData::ColorSeeder, + ::BasicData::ColorSchemeSeeder, + ::StandardSeeder::BasicData::StandardWorkflowSeeder, + ::BasicData::PrioritySeeder, + ::BasicData::SettingSeeder + ] + end + end +end diff --git a/modules/backlogs/app/seeders/type_seeder.rb b/modules/backlogs/app/seeders/type_seeder.rb index 23009f1258..8e3a08fb34 100644 --- a/modules/backlogs/app/seeders/type_seeder.rb +++ b/modules/backlogs/app/seeders/type_seeder.rb @@ -1,23 +1,25 @@ -module BasicData - module Backlogs - module TypeSeeder - def coded_visibility_table - super.merge backlogs_visibility_table - end +module StandardSeeder + module BasicData + module Backlogs + module TypeSeeder + def coded_visibility_table + super.merge backlogs_visibility_table + end - ## - # Relies on type names in the core TypeSeeder being (in this order) - # task, milestone, phase, feature, epic, user_story, bug - # and 0 to 2 being mapped to - # hidden, default, visible - def backlogs_visibility_table - { - story_points: [0, 0, 0, 1, 2, 2, 1], - remaining_time: [1, 0, 0, 1, 1, 1, 1] - } + ## + # Relies on type names in the core TypeSeeder being (in this order) + # task, milestone, phase, feature, epic, user_story, bug + # and 0 to 2 being mapped to + # hidden, default, visible + def backlogs_visibility_table + { + story_points: [0, 0, 0, 1, 2, 2, 1], + remaining_time: [1, 0, 0, 1, 1, 1, 1] + } + end end - end - BasicData::TypeSeeder.prepend BasicData::Backlogs::TypeSeeder + StandardSeeder::BasicData::StandardTypeSeeder.prepend StandardSeeder::BasicData::Backlogs::TypeSeeder + end end end