admin status change
This commit is contained in:
1 parent
e360baadde
commit
4b4cdbfd31
7 files changed
+17
-3
No files matched your search
@@ -43,7 +43,10 @@ class Panel::UsersController < ApplicationController
|
||||
@user.remove_avatar! if params[:file]
|
||||
@user.avatar = params[:file] if params[:file]
|
||||
|
||||
if @user.update_attributes(params[:user])
|
||||
if @user.id.to_s.eql?(session['warden.user.user.key'][1].to_s) && @user.admin != params[:user][:admin].to_i.to_b
|
||||
flash.now[:error] = t('panel.cant_revoke_self_admin')
|
||||
end
|
||||
if !flash[:error] && @user.update_attributes(params[:user])
|
||||
flash[:notice] = t('panel.update_success_user')
|
||||
redirect_to :action => :index
|
||||
else
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ class User
|
||||
|
||||
embeds_many :user_roles
|
||||
embeds_many :user_infos
|
||||
before_update :clean_active_roles
|
||||
before_save :clean_active_roles
|
||||
|
||||
# Update or create the user_role records
|
||||
def user_roles=(*attrs)
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
<%= f.label :email %>
|
||||
<%= f.text_field :email %>
|
||||
</p>
|
||||
<p>
|
||||
<%= t('panel.admin') %>
|
||||
<%= f.check_box :admin %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<% if @user_info_models %>
|
||||
@@ -32,7 +36,6 @@
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
<%= hidden_field_tag :active_roles, (@user.active_roles.size > 0 rescue nil ) %>
|
||||
<% if @user_role_models %>
|
||||
<fieldset id="roles" <%= raw(' style="display: none;"') unless (@user.active_roles.size > 0 rescue nil) %>>
|
||||
<legend><%= t('panel.roles') %></legend>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
</ul>
|
||||
<% end -%>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<h1><%= t('panel.user_panel') %></h1>
|
||||
|
||||
<%= form_for @user, :url => panel_user_path(@user), :html => { :multipart => true } do |f| %>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<th><%= t('panel.roles') %></th>
|
||||
<th><%= t('panel.name') %></th>
|
||||
<th><%= t('panel.email') %></th>
|
||||
<th><%= t('panel.admin') %></th>
|
||||
<th><%= t('panel.action') %></th>
|
||||
</tr>
|
||||
|
||||
@@ -21,6 +22,7 @@
|
||||
<td><%= user.get_roles %></td>
|
||||
<td><%= user[:name] %></td>
|
||||
<td><%= user.email %></td>
|
||||
<td><%= user.admin ? t(:yes_) : t(:no_) %></td>
|
||||
<td>
|
||||
<%= link_to t(:show), panel_user_path(user) %> |
|
||||
<%= link_to t(:edit), edit_panel_user_path(user) %> |
|
||||
|
||||
Reference in new issue
Block a user