mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-26 09:42:46 +08:00
Merge pull request #1706 from mlorb/ml-sci-3350
Change ownership of inventory items, when a user leaves a team [SCI-3350]
This commit is contained in:
commit
9f0983de77
5 changed files with 16 additions and 2 deletions
|
@ -30,4 +30,10 @@ class RepositoryRow < ApplicationRecord
|
|||
def self.name_like(query)
|
||||
where('repository_rows.name ILIKE ?', "%#{query}%")
|
||||
end
|
||||
|
||||
def self.change_owner(team, user, new_owner)
|
||||
joins(:repository)
|
||||
.where('repositories.team_id = ? and repository_rows.created_by_id = ?', team, user)
|
||||
.update_all(created_by_id: new_owner.id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,6 +77,10 @@ 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.
|
||||
RepositoryRow.change_owner(team, user, new_owner)
|
||||
|
||||
super()
|
||||
end
|
||||
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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}."
|
||||
|
||||
|
|
Loading…
Reference in a new issue