partner customer manager: add some check

issues25489
p31729568 5 years ago
parent d32ac609bf
commit 006380037c

@ -26,6 +26,7 @@ class PartnersController < ApplicationController
if params[:manager_group_id].present? if params[:manager_group_id].present?
# 重命名 # 重命名
@manager_group = current_partner.partner_manager_groups.find(params[:manager_group_id]) @manager_group = current_partner.partner_manager_groups.find(params[:manager_group_id])
return render_error('不能修改管理者权限组名称') if @manager_group.admin?
@manager_group.update!(name: name) @manager_group.update!(name: name)
else else
# 新建 # 新建
@ -35,6 +36,7 @@ class PartnersController < ApplicationController
def remove_manager_group def remove_manager_group
manager_group = current_partner.partner_manager_groups.find(params[:manager_group_id]) manager_group = current_partner.partner_manager_groups.find(params[:manager_group_id])
return render_error('不能删除管理者权限组') if manager_group.admin?
manager_group.destroy! manager_group.destroy!
render_delete_success render_delete_success
@ -57,6 +59,8 @@ class PartnersController < ApplicationController
def remove_partner_manager def remove_partner_manager
partner_manager = current_partner.partner_managers.find(params[:manager_id]) partner_manager = current_partner.partner_managers.find(params[:manager_id])
return render_error('不能删除自己') if partner_manager.user_id == current_user.id && partner_manager.partner_manager_group.admin?
partner_manager.destroy! partner_manager.destroy!
render_delete_success render_delete_success

@ -4,11 +4,13 @@
<% manager_group.partner_managers.each do |manager| %> <% manager_group.partner_managers.each do |manager| %>
<div class="partner-manager-item partner-manager-item-<%= manager.id %>"> <div class="partner-manager-item partner-manager-item-<%= manager.id %>">
<%= delete_link 'x', <% if !manager_group.admin? || manager.user_id != current_user.id %>
remove_partner_manager_partner_path(current_partner, manager_id: manager.id, element: ".partner-manager-item-#{manager.id}"), <%= delete_link 'x',
data: { toggle: 'tooltip', title: '删除' }, remove_partner_manager_partner_path(current_partner, manager_id: manager.id, element: ".partner-manager-item-#{manager.id}"),
class: 'remove-partner-manager-action' do %> data: { toggle: 'tooltip', title: '删除' },
<i class="fa fa-times-circle"></i> class: 'remove-partner-manager-action' do %>
<i class="fa fa-times-circle"></i>
<% end %>
<% end %> <% end %>
<%= link_to "/users/#{manager.user.login}", data: { toggle: 'tooltip', title: '查看个人主页' }, <%= link_to "/users/#{manager.user.login}", data: { toggle: 'tooltip', title: '查看个人主页' },

Loading…
Cancel
Save