From 0eacb91bed555254c3b987081ccb92d67fdaaf9d Mon Sep 17 00:00:00 2001 From: artoscinote <85488244+artoscinote@users.noreply.github.com> Date: Wed, 10 Nov 2021 09:52:37 +0100 Subject: [PATCH] Renamed 'group_user_role', fixed public project migration [SCI-6234] (#3642) * Renamed 'group_user_role', fixed public project migration [SCI-6234] * Moved public project update inside loop [SCI-6234] --- app/controllers/projects_controller.rb | 2 +- .../user_assignments/group_assignment_job.rb | 4 +-- app/models/project.rb | 8 ++--- .../modals/_edit_project_contents.html.erb | 4 +-- .../index/modals/_new_project.html.erb | 2 +- ...dd_default_public_user_role_to_projects.rb | 7 +++++ ...0210222123823_migrate_to_new_user_roles.rb | 2 ++ ...7095718_add_group_user_role_to_projects.rb | 5 ---- db/structure.sql | 29 +++++++++---------- 9 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 db/migrate/20210222123822_add_default_public_user_role_to_projects.rb delete mode 100644 db/migrate/20210627095718_add_group_user_role_to_projects.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c37a02dfa..7f70e2dac 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -335,7 +335,7 @@ class ProjectsController < ApplicationController .permit( :name, :team_id, :visibility, :archived, :project_folder_id, - :group_user_role_id + :default_public_user_role_id ) end diff --git a/app/jobs/user_assignments/group_assignment_job.rb b/app/jobs/user_assignments/group_assignment_job.rb index 6b6aa613c..2e4cd8587 100644 --- a/app/jobs/user_assignments/group_assignment_job.rb +++ b/app/jobs/user_assignments/group_assignment_job.rb @@ -13,7 +13,7 @@ module UserAssignments UserAssignment.create!( user: user, assignable: project, - user_role: project.group_user_role, + user_role: project.default_public_user_role, assigned_by: @assigned_by, assigned: :automatically ) @@ -21,7 +21,7 @@ module UserAssignments UserAssignments::PropagateAssignmentJob.perform_later( project, user, - project.group_user_role, + project.default_public_user_role, @assigned_by ) end diff --git a/app/models/project.rb b/app/models/project.rb index 3b514ce70..d3fa4c9a0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -37,8 +37,8 @@ class Project < ApplicationRecord foreign_key: 'restored_by_id', class_name: 'User', optional: true - belongs_to :group_user_role, - foreign_key: 'group_user_role_id', + belongs_to :default_public_user_role, + foreign_key: 'default_public_user_role_id', class_name: 'UserRole', optional: true belongs_to :team, inverse_of: :projects, touch: true @@ -327,11 +327,11 @@ class Project < ApplicationRecord end def bulk_assignment? - visible? && group_user_role.present? + visible? && default_public_user_role.present? end def selected_user_role_validation - errors.add(:group_user_role_id, :inclusion) unless group_user_role.in?(UserRole.all) + errors.add(:default_public_user_role_id, :inclusion) unless default_public_user_role.in?(UserRole.all) end def sync_project_assignments diff --git a/app/views/projects/index/modals/_edit_project_contents.html.erb b/app/views/projects/index/modals/_edit_project_contents.html.erb index f184e73be..31c140ecd 100644 --- a/app/views/projects/index/modals/_edit_project_contents.html.erb +++ b/app/views/projects/index/modals/_edit_project_contents.html.erb @@ -25,8 +25,8 @@
- <%= f.select :group_user_role_id, - options_for_select(user_roles_collection, selected: f.object.group_user_role_id), + <%= f.select :default_public_user_role_id, + options_for_select(user_roles_collection, selected: f.object.default_public_user_role_id), { label: t('user_assignment.select_default_user_role') }, class: 'form-control selectpicker'%>
diff --git a/app/views/projects/index/modals/_new_project.html.erb b/app/views/projects/index/modals/_new_project.html.erb index fee45a4c4..81fcf3bfc 100644 --- a/app/views/projects/index/modals/_new_project.html.erb +++ b/app/views/projects/index/modals/_new_project.html.erb @@ -25,7 +25,7 @@