Change ownership of inventory items, when a user leaves a team

This commit is contained in:
Mojca Lorber 2019-04-26 10:47:08 +02:00
parent 09d1946b19
commit eac90109f7
4 changed files with 15 additions and 2 deletions

View file

@ -77,6 +77,15 @@ class UserTeam < ApplicationRecord
protocol.save
end
# Make new owner author of all inventory items that were added
# by departing user and belong to this team.
repository_rows =
RepositoryRow.joins(:repository)
.where('repositories.team_id = ? and repository_rows.created_by_id = ?', team, user)
repository_rows.find_each do |repository_row|
repository_row.update(created_by: new_owner)
end
super()
end

View file

@ -15,6 +15,7 @@
<li><%= t("users.settings.user_teams.destroy_uo_alert_line_1") %></li>
<li><%= t("users.settings.user_teams.destroy_uo_alert_line_2").html_safe %></li>
<li><%= t("users.settings.user_teams.destroy_uo_alert_line_3") %></li>
<li><%= t("users.settings.user_teams.destroy_uo_alert_line_4") %></li>
</ul>
</div>
<% end %>

View file

@ -13,6 +13,7 @@
<li><%= t("users.settings.user_teams.leave_uo_alert_line_1") %></li>
<li><%= t("users.settings.user_teams.leave_uo_alert_line_2").html_safe %></li>
<li><%= t("users.settings.user_teams.leave_uo_alert_line_3")%></li>
<li><%= t("users.settings.user_teams.leave_uo_alert_line_4")%></li>
</ul>
</div>
<% end %>

View file

@ -1497,14 +1497,16 @@ en:
leave_uo_alert_heading: "Leaving team has following consequences:"
leave_uo_alert_line_1: "you will lose access to all content belonging to the team (including projects, tasks, protocols and activities);"
leave_uo_alert_line_2: "all projects in the team where you were the sole <b>Owner</b> will receive a new owner from the team administrators;"
leave_uo_alert_line_3: "all repository protocols in the team belonging to you will be reassigned onto a new owner from team administrators."
leave_uo_alert_line_3: "all repository protocols in the team belonging to you will be reassigned onto a new owner from team administrators;"
leave_uo_alert_line_4: "all inventory items in the team added by you will be reassigned onto a new owner from team administrators."
leave_uo_confirm: "Leave"
destroy_uo_heading: "Remove user %{user} from team %{team}"
destroy_uo_message: "Are you sure you wish to remove user %{user} from team %{team}?"
destroy_uo_alert_heading: "Removing user from team has following consequences:"
destroy_uo_alert_line_1: "user will lose access to all content belonging to the team (including projects, tasks, protocols and activities);"
destroy_uo_alert_line_2: "all projects in the team where user was the sole <b>Owner</b> will be reassigned onto you as a new owner;"
destroy_uo_alert_line_3: "all repository protocols in the team belonging to user will be reassigned onto you."
destroy_uo_alert_line_3: "all repository protocols in the team belonging to user will be reassigned onto you;"
destroy_uo_alert_line_4: "all inventory items in the team added by user will be reassigned onto you."
destroy_uo_confirm: "Remove"
leave_flash: "Successfuly left team %{team}."