Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move time entry activity names into the seeder files

Christophe Bliardb319f7732dbf
diff --git a/app/seeders/basic_data/activity_seeder.rb b/app/seeders/basic_data/activity_seeder.rb
index 28857719ed7..b7ec60afa99 100644
--- a/app/seeders/basic_data/activity_seeder.rb
+++ b/app/seeders/basic_data/activity_seeder.rb
@@ -29,22 +29,22 @@ module BasicData
class ActivitySeeder < Seeder
def seed_data!
TimeEntryActivity.transaction do
- data.each do |attributes|
- TimeEntryActivity.create(attributes)
+ seed_data.each('time_entry_activities') do |activity_data|
+ TimeEntryActivity.create(
+ name: activity_data['name'],
+ position: activity_data['position'],
+ is_default: true?(activity_data['is_default'])
+ )
end
end
end
def applicable?
- TimeEntryActivity.all.empty?
+ TimeEntryActivity.none?
end
def not_applicable_message
'Skipping activities as there are already some configured'
end
-
- def data
- raise NotImplementedError
- end
end
end
diff --git a/app/seeders/basic_data/status_seeder.rb b/app/seeders/basic_data/status_seeder.rb
index 117b19fa639..7f7069387cf 100644
--- a/app/seeders/basic_data/status_seeder.rb
+++ b/app/seeders/basic_data/status_seeder.rb
@@ -29,33 +29,21 @@ module BasicData
class StatusSeeder < Seeder
def seed_data!
Status.transaction do
- data.each do |attributes|
- reference = attributes.delete(:reference)
- status = Status.create!(attributes)
- seed_data.store_reference(reference, status)
+ Array(seed_data.lookup('statuses')).each do |status_data|
+ status = Status.create!(status_attributes(status_data))
+ seed_data.store_reference(status_data['reference'], status)
end
end
end
- def applicable
- Status.all.any?
- end
-
- def not_applicable_message
- 'Skipping statuses - already exists/configured'
- end
-
- def data
- Array(seed_data.lookup('statuses')).map do |status_data|
- {
- reference: status_data['reference'],
- name: status_data['name'],
- color_id: color_id(status_data['color_name']),
- is_closed: true?(status_data['is_closed']),
- is_default: true?(status_data['is_default']),
- position: status_data['position']
- }
- end
+ def status_attributes(status_data)
+ {
+ name: status_data['name'],
+ color_id: color_id(status_data['color_name']),
+ is_closed: true?(status_data['is_closed']),
+ is_default: true?(status_data['is_default']),
+ position: status_data['position']
+ }
end
protected
diff --git a/app/seeders/standard.yml b/app/seeders/standard.yml
index 3d6ce4e4853..0df8e79e911 100644
--- a/app/seeders/standard.yml
+++ b/app/seeders/standard.yml
@@ -30,88 +30,78 @@ statuses:
- reference: :default_status_new
t_name: New
color_name: cyan-7
- is_closed: false
is_default: true
position: 1
- reference: :default_status_in_specification
t_name: In specification
color_name: blue-2
- is_closed: false
- is_default: false
position: 2
- reference: :default_status_specified
t_name: Specified
color_name: blue-2
- is_closed: false
- is_default: false
position: 3
- reference: :default_status_confirmed
t_name: Confirmed
color_name: violet-2
- is_closed: false
- is_default: false
position: 4
- reference: :default_status_to_be_scheduled
t_name: To be scheduled
color_name: yellow-2
- is_closed: false
- is_default: false
position: 5
- reference: :default_status_scheduled
t_name: Scheduled
color_name: lime-2
- is_closed: false
- is_default: false
position: 6
- reference: :default_status_in_progress
t_name: In progress
color_name: grape-5
- is_closed: false
- is_default: false
position: 7
- reference: :default_status_developed
t_name: Developed
color_name: green-3
- is_closed: false
- is_default: false
position: 8
- reference: :default_status_in_testing
t_name: In testing
color_name: cyan-5
- is_closed: false
- is_default: false
position: 9
- reference: :default_status_tested
t_name: Tested
color_name: teal-6
- is_closed: false
- is_default: false
position: 10
- reference: :default_status_test_failed
t_name: Test failed
color_name: red-5
- is_closed: false
- is_default: false
position: 11
- reference: :default_status_closed
t_name: Closed
color_name: gray-3
is_closed: true
- is_default: false
position: 12
- reference: :default_status_on_hold
t_name: On hold
color_name: orange-3
- is_closed: false
- is_default: false
position: 13
- reference: :default_status_rejected
t_name: Rejected
color_name: red-3
is_closed: true
- is_default: false
position: 14
+time_entry_activities:
+- t_name: Management
+ is_default: true
+ position: 1
+- t_name: Specification
+ position: 2
+- t_name: Development
+ position: 3
+- t_name: Testing
+ position: 4
+- t_name: Support
+ position: 5
+- t_name: Other
+ position: 6
+
welcome:
t_title: "Welcome to OpenProject!"
t_text: |
diff --git a/app/seeders/standard/basic_data/activity_seeder.rb b/app/seeders/standard/basic_data/activity_seeder.rb
deleted file mode 100644
index 07d7d474160..00000000000
--- a/app/seeders/standard/basic_data/activity_seeder.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2023 the OpenProject GmbH
-#
-# 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-2013 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 COPYRIGHT and LICENSE files for more details.
-#++
-module Standard
- module BasicData
- class ActivitySeeder < ::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/basic_data_seeder.rb b/app/seeders/standard/basic_data_seeder.rb
index 680f82f20f8..0ff4e02d743 100644
--- a/app/seeders/standard/basic_data_seeder.rb
+++ b/app/seeders/standard/basic_data_seeder.rb
@@ -32,7 +32,7 @@ module Standard
::BasicData::BuiltinUsersSeeder,
::BasicData::BuiltinRolesSeeder,
::BasicData::RoleSeeder,
- ::Standard::BasicData::ActivitySeeder,
+ ::BasicData::ActivitySeeder,
::BasicData::ColorSeeder,
::BasicData::ColorSchemeSeeder,
::Standard::BasicData::WorkflowSeeder,
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6cbe82db50f..8d4d1fbdc0d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1223,7 +1223,7 @@ en:
short: "%b %d"
# Don't forget the nil at the beginning; there's no such thing as a 0th month
month_names: [ ~, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
- # Used in date_select and datime_select.
+ # Used in date_select and datetime_select.
order:
- :year
- :month
@@ -1270,12 +1270,6 @@ en:
one: "hour"
other: "hours"
- default_activity_development: "Development"
- default_activity_management: "Management"
- default_activity_other: "Other"
- default_activity_specification: "Specification"
- default_activity_support: "Support"
- default_activity_testing: "Testing"
default_color_black: "Black"
default_color_blue: "Blue"
default_color_blue_dark: "Blue (dark)"
diff --git a/modules/bim/app/seeders/bim.yml b/modules/bim/app/seeders/bim.yml
index 05499ac200f..6502c1527b3 100644
--- a/modules/bim/app/seeders/bim.yml
+++ b/modules/bim/app/seeders/bim.yml
@@ -46,6 +46,15 @@ statuses:
is_closed: true
position: 4
+time_entry_activities:
+ - t_name: Management
+ is_default: true
+ position: 1
+ - t_name: Specification
+ position: 2
+ - t_name: Other
+ position: 3
+
global_queries:
- t_name: "Embedded table: Children"
reference: :global_query__children
diff --git a/modules/bim/app/seeders/bim/basic_data/activity_seeder.rb b/modules/bim/app/seeders/bim/basic_data/activity_seeder.rb
deleted file mode 100644
index 6c724c467e9..00000000000
--- a/modules/bim/app/seeders/bim/basic_data/activity_seeder.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2023 the OpenProject GmbH
-#
-# 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-2013 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 COPYRIGHT and LICENSE files for more details.
-#++
-module Bim
- module BasicData
- class ActivitySeeder < ::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/modules/bim/app/seeders/bim/basic_data_seeder.rb b/modules/bim/app/seeders/bim/basic_data_seeder.rb
index e2059e5a840..17ddb171347 100644
--- a/modules/bim/app/seeders/bim/basic_data_seeder.rb
+++ b/modules/bim/app/seeders/bim/basic_data_seeder.rb
@@ -32,7 +32,7 @@ module Bim
::BasicData::BuiltinUsersSeeder,
::BasicData::BuiltinRolesSeeder,
::Bim::BasicData::RoleSeeder,
- ::Bim::BasicData::ActivitySeeder,
+ ::BasicData::ActivitySeeder,
::BasicData::ColorSeeder,
::BasicData::ColorSchemeSeeder,
::Bim::BasicData::WorkflowSeeder,
diff --git a/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb b/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb
index 29e71394a0b..f7a591e2769 100644
--- a/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb
+++ b/modules/bim/spec/seeders/root_seeder_bim_edition_spec.rb
@@ -81,6 +81,14 @@ describe RootSeeder,
it 'creates workflows' do
expect(Workflow.count).to eq(182)
end
+
+ it 'creates statuses' do
+ expect(Status.count).to eq(4)
+ end
+
+ it 'creates time entry activities' do
+ expect(TimeEntryActivity.count).to eq(3)
+ end
end
describe 'demo data' do
diff --git a/spec/seeders/root_seeder_standard_edition_spec.rb b/spec/seeders/root_seeder_standard_edition_spec.rb
index e75cc0abf7d..4fd6ff012f3 100644
--- a/spec/seeders/root_seeder_standard_edition_spec.rb
+++ b/spec/seeders/root_seeder_standard_edition_spec.rb
@@ -81,6 +81,14 @@ describe RootSeeder,
it 'creates workflows' do
expect(Workflow.count).to eq(1172)
end
+
+ it 'creates statuses' do
+ expect(Status.count).to eq(14)
+ end
+
+ it 'creates time entry activities' do
+ expect(TimeEntryActivity.count).to eq(6)
+ end
end
describe 'demo data' do