Skip to content

Commit

Permalink
Associate managers group to StagingWorkflow
Browse files Browse the repository at this point in the history
Every staging workflow now have a group of managers that can work on
them.
  • Loading branch information
Moises Deniz Aleman committed Nov 19, 2018
1 parent 4fc35e0 commit 853386d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api/app/models/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Groups have an arbitrary number of roles and users assigned to them.
#
class Group < ApplicationRecord
has_one :staging_workflow, class_name: 'Staging::Workflow', foreign_key: :managers_group_id, dependent: :nullify
has_many :groups_users, inverse_of: :group, dependent: :destroy
has_many :users, -> { distinct }, through: :groups_users
has_many :group_maintainers, inverse_of: :group, dependent: :destroy
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/models/staging/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def self.table_name_prefix
include CanRenderModel

belongs_to :project, inverse_of: :staging
belongs_to :managers, class_name: 'Group'

has_many :staging_projects, class_name: 'Staging::StagingProject', inverse_of: :staging_workflow, dependent: :nullify,
foreign_key: 'staging_workflow_id' do
def without_staged_requests
Expand All @@ -25,6 +27,8 @@ def ready_to_stage

has_many :staged_requests, class_name: 'BsRequest', through: :staging_projects

validates :managers, presence: true

after_create :create_staging_projects

def unassigned_requests
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddStagingManagersGroup < ActiveRecord::Migration[5.2]
def change
change_table :staging_workflows do |t|
t.references :managers_group, index: true, type: :integer
end
end
end
7 changes: 5 additions & 2 deletions src/api/db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,10 @@ CREATE TABLE `staging_workflows` (
`project_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`managers_group_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_staging_workflows_on_project_id` (`project_id`)
UNIQUE KEY `index_staging_workflows_on_project_id` (`project_id`),
KEY `index_staging_workflows_on_managers_group_id` (`managers_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `static_permissions` (
Expand Down Expand Up @@ -1423,6 +1425,7 @@ INSERT INTO `schema_migrations` (version) VALUES
('20180924135535'),
('20181008150453'),
('20181016103905'),
('20181025152009');
('20181025152009'),
('20181113095753');


0 comments on commit 853386d

Please sign in to comment.