parent
00bd5ec0ab
commit
4e5b9afef5
@ -0,0 +1,37 @@ |
||||
#-- 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. |
||||
#++ |
||||
|
||||
class Queries::Projects::Filters::ActiveFilter < Queries::Projects::Filters::ProjectFilter |
||||
include Queries::Filters::Shared::BooleanFilter |
||||
|
||||
def self.key |
||||
:active |
||||
end |
||||
end |
@ -1,9 +1,25 @@ |
||||
class AddProjectStatusReporting < ActiveRecord::Migration[6.0] |
||||
def change |
||||
create_table :project_statuses do |table| |
||||
table.references :project, foreign_key: true, index: { unique: true } |
||||
table.text :description |
||||
table.references :project, null: false, foreign_key: true, index: { unique: true } |
||||
table.text :explanation |
||||
table.integer :code |
||||
table.timestamps |
||||
end |
||||
|
||||
reversible do |change| |
||||
change.up do |
||||
project_status_for_existing_projects |
||||
end |
||||
end |
||||
end |
||||
|
||||
def project_status_for_existing_projects |
||||
insert_sql = <<-SQL |
||||
INSERT into project_statuses |
||||
SELECT id AS project_id, #{Project::Status.codes['on_track']} as code FROM projects |
||||
SQL |
||||
|
||||
insert Arel.sql(insert_sql) |
||||
end |
||||
end |
||||
|
@ -0,0 +1,48 @@ |
||||
class SimplifyProjectActiveAndTimestamp < ActiveRecord::Migration[6.0] |
||||
STATUS_ACTIVE = 1 |
||||
STATUS_ARCHIVED = 9 |
||||
|
||||
class Project < ActiveRecord::Base; end |
||||
|
||||
def change |
||||
change_project_columns |
||||
|
||||
reversible do |change| |
||||
change.up do |
||||
fill_active_column |
||||
end |
||||
change.down do |
||||
recreate_status_column_and_information |
||||
end |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def change_project_columns |
||||
change_table :projects do |table| |
||||
table.rename :created_on, :created_at |
||||
table.rename :updated_on, :updated_at |
||||
table.rename :is_public, :public |
||||
end |
||||
end |
||||
|
||||
def fill_active_column |
||||
add_column :projects, :active, :boolean, default: true, index: true, null: false |
||||
|
||||
Project.reset_column_information |
||||
Project.where(status: STATUS_ARCHIVED).update_all(active: false) |
||||
|
||||
remove_column :projects, :status |
||||
end |
||||
|
||||
def recreate_status_column_and_information |
||||
add_column :projects, :status, :integer, default: STATUS_ACTIVE, null: false |
||||
|
||||
Project.reset_column_information |
||||
Project.where(active: true).update_all(status: STATUS_ACTIVE) |
||||
Project.where(active: false).update_all(status: STATUS_ARCHIVED) |
||||
|
||||
remove_column :projects, :active |
||||
end |
||||
end |
@ -0,0 +1,35 @@ |
||||
# 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. |
||||
#++ |
||||
|
||||
FactoryBot.define do |
||||
factory :project_status, class: Project::Status do |
||||
project |
||||
sequence(:explanation) { |n| "Status explanation #{n}" } |
||||
end |
||||
end |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue