mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-30 08:54:31 +08:00
Set correct permission for repository on team role change [SCI-7341] (#4540)
This commit is contained in:
parent
64975effc6
commit
fab625d819
3 changed files with 18 additions and 5 deletions
|
@ -12,6 +12,8 @@ module UserAssignments
|
|||
assign_users_to_experiment(object)
|
||||
when MyModule
|
||||
assign_users_to_my_module(object)
|
||||
when Repository
|
||||
assign_users_to_repository(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -32,6 +34,13 @@ module UserAssignments
|
|||
end
|
||||
end
|
||||
|
||||
def assign_users_to_repository(repository)
|
||||
team = repository.team
|
||||
team.user_assignments.find_each do |user_assignment|
|
||||
create_or_update_user_assignment(user_assignment, repository)
|
||||
end
|
||||
end
|
||||
|
||||
def create_or_update_user_assignment(parent_user_assignment, object)
|
||||
user_role = parent_user_assignment.user_role
|
||||
user = parent_user_assignment.user
|
||||
|
|
|
@ -23,7 +23,7 @@ module UserAssignments
|
|||
.where(automatic_user_assignments: { user: @user, team: @team })
|
||||
.find_each do |repository|
|
||||
repository.automatic_user_assignments
|
||||
.select { |assignment| assignment.user_id == @user.id && assignment.team_id == @team.id }
|
||||
.select { |assignment| assignment[:user_id] == @user.id && assignment[:team_id] == @team.id }
|
||||
.each { |assignment| assignment.update!(user_role: @user_role) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
<div class="quick-start-buttons">
|
||||
<div class="new-task btn btn-secondary"><i class="fas fa-plus"></i><%= t("dashboard.quick_start.new_task") %></div>
|
||||
<%= link_to protocols_path, {class: "new-protocol btn btn-secondary"} do %>
|
||||
<i class="fas fa-edit"></i><%= t("dashboard.quick_start.new_protocol") %>
|
||||
<% if can_create_protocols_in_repository?(current_team) %>
|
||||
<%= link_to protocols_path, {class: "new-protocol btn btn-secondary"} do %>
|
||||
<i class="fas fa-edit"></i><%= t("dashboard.quick_start.new_protocol") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to new_report_path, {class: "new-report btn btn-secondary"} do %>
|
||||
<i class="fas fa-clipboard-check"></i><%= t("dashboard.quick_start.new_report") %>
|
||||
<% if can_create_reports?(current_team) %>
|
||||
<%= link_to new_report_path, {class: "new-report btn btn-secondary"} do %>
|
||||
<i class="fas fa-clipboard-check"></i><%= t("dashboard.quick_start.new_report") %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render "create_task_modal" %>
|
||||
|
|
Loading…
Add table
Reference in a new issue