同步用户

dev_home
cxt 5 years ago
parent 97b542ea00
commit eba2051a4e

@ -50,6 +50,13 @@ class Admins::LaboratoriesController < Admins::BaseController
@subjects = paginate(subjects.includes(:user))
end
def synchronize_user
school = current_laboratory.school
users = User.joins(:user_extension).where(user_extensions: {school_id: school.id})
users.update_all(laboratory_id: current_laboratory.id)
end
private
def current_laboratory

@ -34,7 +34,8 @@
<% if school.present? && laboratory.id != 1 %>
<%= javascript_void_link '添加管理员', class: 'action', data: { laboratory_id: laboratory.id, toggle: 'modal', target: '.admin-add-laboratory-user-modal' } %>
<% end %>
<%= link_to '同步用户', synchronize_user_admins_laboratory_path(laboratory), remote: true, data: { confirm: '确认同步该单位下的所有用户到云上实验室吗?' }, class: 'action' %>
<% end %>
<div class="d-inline">
<%= javascript_void_link('更多', class: 'action dropdown-toggle', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) %>

@ -1050,6 +1050,7 @@ Rails.application.routes.draw do
member do
get :shixuns_for_select
get :subjects_for_select
get :synchronize_user
end
resource :laboratory_setting, only: [:show, :update]

Loading…
Cancel
Save