From 6bfbb83df530182fe81be7a85d4da3e00163e4d8 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Wed, 19 Jul 2023 11:07:17 +0400 Subject: [PATCH 1/3] Error at inviting user to SciNote --- app/assets/config/manifest.js | 1 + app/controllers/users/invitations_controller.rb | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 2bf5ab10c..662c37892 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,3 +2,4 @@ //= link application.js //= link application.css //= link_tree ../builds/ +//= link scinote/enterprise/organization_management/application.js diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index 232869234..2f0bf3d26 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -150,8 +150,7 @@ module Users .distinct teams = teams.where_attributes_like('teams.name', params[:query]) if params[:query].present? - teams.select { |team| can_invite_team_users?(team) } - + teams = teams.select { |team| can_invite_team_users?(team) && current_user_team_role(team)&.owner? } render json: teams.map { |t| { value: t.id, label: escape_input(t.name) } }.to_json end @@ -162,6 +161,14 @@ module Users devise_parameter_sanitizer.permit(:accept_invitation, keys: [:full_name]) end + def current_user_team_assignment(team) + team.user_assignments.find { |ua| ua.user == current_user } + end + + def current_user_team_role(team) + current_user_team_assignment(team)&.user_role + end + def check_captcha if Rails.configuration.x.enable_recaptcha unless verify_recaptcha From ea67f543f2c084356cf2e658c15ea4c6c722a19f Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Thu, 20 Jul 2023 12:27:56 +0400 Subject: [PATCH 2/3] removed unnecessary code --- app/assets/config/manifest.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 662c37892..2bf5ab10c 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,4 +2,3 @@ //= link application.js //= link application.css //= link_tree ../builds/ -//= link scinote/enterprise/organization_management/application.js From 4645489527998aa017e958ae96fa924b53e64719 Mon Sep 17 00:00:00 2001 From: Giga Chubinidze Date: Thu, 20 Jul 2023 12:46:31 +0400 Subject: [PATCH 3/3] fixed teams for dropdown --- app/controllers/users/invitations_controller.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index 2f0bf3d26..e320a141e 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -150,7 +150,7 @@ module Users .distinct teams = teams.where_attributes_like('teams.name', params[:query]) if params[:query].present? - teams = teams.select { |team| can_invite_team_users?(team) && current_user_team_role(team)&.owner? } + teams = teams.select { |team| can_invite_team_users?(team) } render json: teams.map { |t| { value: t.id, label: escape_input(t.name) } }.to_json end @@ -161,14 +161,6 @@ module Users devise_parameter_sanitizer.permit(:accept_invitation, keys: [:full_name]) end - def current_user_team_assignment(team) - team.user_assignments.find { |ua| ua.user == current_user } - end - - def current_user_team_role(team) - current_user_team_assignment(team)&.user_role - end - def check_captcha if Rails.configuration.x.enable_recaptcha unless verify_recaptcha