fix new ui member account privilege

This commit is contained in:
Spen 2013-10-18 19:02:14 +08:00 committed by saurabhbhatia
parent e453efeb6b
commit 14d2b0cc76
11 changed files with 103 additions and 15 deletions

View File

@ -181,6 +181,16 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
def edit_passwd def edit_passwd
# @disable_all_field = false # @disable_all_field = false
@user = User.find(params[:users_new_interface_id]) @user = User.find(params[:users_new_interface_id])
if current_user.id == @user.id
redirect_to :action => :index
end
end
def edit_privilege
@user = User.find(params[:users_new_interface_id])
if current_user.id == @user.id
redirect_to :action => :index
end
end end
def update def update
@ -203,6 +213,20 @@ class Admin::UsersNewInterfaceController < OrbitMemberController
render :action => :edit_passwd, :notice => flash.now[:error] render :action => :edit_passwd, :notice => flash.now[:error]
end end
elsif params[:edit_type] == 'edit_privilege'
@checkuser = User.where(:user_id => params[:user][:user_id]).first
if @user.admin && current_user.id == @user.id
flash.now[:error] = t("users.admin_change_password")
end
if !flash.now[:error] && @user.update_attributes(params[:user])
redirect_to :action => :show
else
render :action => :edit_privilege, :notice => flash.now[:error]
end
else else
@user.update_attributes(params[:user]) @user.update_attributes(params[:user])

View File

@ -39,16 +39,5 @@
</div> </div>
</div> </div>
<!-- Chec Admin -->
<div class="control-group">
<label class="control-label muted" for="">Administrator</label>
<div class="controls">
<label class="checkbox inline">
<%= f.check_box :admin %>
<%= t("admin") %>
</label>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,32 @@
<%#= devise_error_messages! %>
<%= flash_messages %>
<div class="attributes">
<div class="attributes-header clearfix">
<h4><%=t("users.setting_privilege")%></h4>
</div>
<div class="attributes-body">
<!-- Account -->
<div class="control-group">
<label class="control-label muted" for="account">
<%= f.label t("users.user_id"),:class=>"control-label" %>
</label>
<div class="controls add-input">
<%= @user.user_id %>
</div>
</div>
<!-- Chec Admin -->
<div class="control-group">
<label class="control-label muted" for="">Administrator</label>
<div class="controls">
<label class="checkbox inline">
<%= f.check_box :admin %>
<%= t("admin") %>
</label>
</div>
</div>
</div>
</div>

View File

@ -20,7 +20,7 @@
<div class="quick-edit"> <div class="quick-edit">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<%= content_tag(:li, link_to(t(:edit),edit_admin_users_new_interface_path(user_for_listing))) if is_admin? %> <%= content_tag(:li, link_to(t(:edit),edit_admin_users_new_interface_path(user_for_listing))) if is_admin? %>
<%= content_tag(:li, link_to(t(:Permissions),'#')) if is_admin? %> <%= content_tag(:li, link_to(t("users.setting_privilege"),admin_users_new_interface_edit_privilege_path(user_for_listing))) if is_admin? and current_user.id != user_for_listing.id %>
<%= content_tag(:li, link_to(t(:delete),admin_users_new_interface_path(user_for_listing, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"text-error", :remote => true)) if is_admin? %> <%= content_tag(:li, link_to(t(:delete),admin_users_new_interface_path(user_for_listing, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"text-error", :remote => true)) if is_admin? %>
</ul> </ul>
</div> </div>

View File

@ -12,7 +12,7 @@
<p class="<%= @user_sex%>"></p> <p class="<%= @user_sex%>"></p>
<div class="action"> <div class="action">
<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_summary),:class=>"edit" ) if is_admin?%> <%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_summary),:class=>"edit" ) if is_admin?%>
<%= link_to(content_tag(:i, nil, :class => 'icon-key'),'#',:class=>"key" ) if is_admin?%> <%= link_to(content_tag(:i, nil, :class => 'icon-key'),admin_users_new_interface_edit_privilege_path(user_for_summary),:class=>"key" ) if is_admin? and current_user.id != user_for_summary.id %>
<%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_summary, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %> <%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_summary, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %>
</div> </div>
<%= image_tag(user_for_summary.avatar) %> <%= image_tag(user_for_summary.avatar) %>

View File

@ -12,7 +12,7 @@
<div class="action"> <div class="action">
<%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_thumbnail),:class=>"edit" ) if is_admin?%> <%= link_to(content_tag(:i, nil, :class => 'icon-edit'),edit_admin_users_new_interface_path(user_for_thumbnail),:class=>"edit" ) if is_admin?%>
<%= link_to(content_tag(:i, nil, :class => 'icon-key'),'#',:class=>"key" ) if is_admin?%> <%= link_to(content_tag(:i, nil, :class => 'icon-key'),admin_users_new_interface_edit_privilege_path(user_for_thumbnail),:class=>"key" ) if is_admin? and current_user.id != user_for_thumbnail.id %>
<%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_thumbnail, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %> <%= link_to(content_tag(:i, nil, :class => 'icon-trash'), admin_users_new_interface_path(user_for_thumbnail, :at=>params[:at]), :confirm => t(:sure?), :method => :delete, :class=>"trash", :remote => true) if is_admin? %>
</div> </div>

View File

@ -0,0 +1,39 @@
<% content_for :side_bar do %>
<%= render :partial => 'admin/users_new_interface/side_bar' %>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "lib/wrap-nav.css" %>
<%= stylesheet_link_tag "lib/pageslide.css" %>
<%= stylesheet_link_tag "lib/main-forms.css" %>
<%= stylesheet_link_tag "lib/fileupload.css" %>
<%= stylesheet_link_tag "lib/togglebox.css" %>
<% end -%>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "lib/jquery.tmpl.min.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload.js" %>
<%= javascript_include_tag "lib/member/role-forms.js" %>
<%= javascript_include_tag "lib/member/textarea-lang-btn.js" %>
<% end -%>
<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true , :class=>"form-horizontal main-forms"} do |f| %>
<fieldset>
<div id="basic-area" class="input-area">
<%= f.error_messages %>
<%= render :partial => 'user_basic_privilege', :locals => {:f => f}%>
</div>
<div class="form-actions">
<%= link_back('btn') %>
<%= hidden_field_tag 'edit_type', 'edit_privilege' %>
<%= link_to t(:update_), "#", :class=>"btn btn-primary returnDecide", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
</div>
</fieldset>
<% end -%>

View File

@ -21,6 +21,7 @@
<div class="btn-group"> <div class="btn-group">
<%= link_to("<i class='icon-edit'></i> #{t(:edit)}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-mini" ) if is_admin?%> <%= link_to("<i class='icon-edit'></i> #{t(:edit)}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-mini" ) if is_admin?%>
<%= link_to("<i class='icons-cycle'></i> #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin?%> <%= link_to("<i class='icons-cycle'></i> #{t("users.change_passwd")}".html_safe,admin_users_new_interface_edit_passwd_path(@user),:class=>"btn btn-mini" ) if is_admin?%>
<%= link_to("<i class='icons-lock-open'></i> #{t("users.setting_privilege")}".html_safe,admin_users_new_interface_edit_privilege_path(@user),:class=>"btn btn-mini" ) if is_admin? and current_user.id != @user.id %>
</div> </div>
</div> </div>

View File

@ -487,7 +487,8 @@ en:
users: users:
admin_change_password: You cannot change your own password here! admin_change_password: You cannot change your own password here!
avatar: Profile Picture avatar: Profile Picture
change_passwd: Change password change_passwd: Password
setting_privilege: Privilege
email: Email email: Email
first_name: First Name first_name: First Name
last_name: Last Name last_name: Last Name

View File

@ -489,6 +489,7 @@ zh_tw:
admin_change_password: 您不能在此處修改自己的密碼! admin_change_password: 您不能在此處修改自己的密碼!
avatar: 大頭貼照 avatar: 大頭貼照
change_passwd: 變更密碼 change_passwd: 變更密碼
setting_privilege: 權限設定
email: 電子郵件 email: 電子郵件
first_name: 名字 first_name: 名字
male: 男性 male: 男性

View File

@ -221,6 +221,7 @@ Orbit::Application.routes.draw do
post 'update_order_list' post 'update_order_list'
end end
match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd match "edit_passwd" => "users_new_interface#edit_passwd" ,:as => :edit_passwd
match "edit_privilege" => "users_new_interface#edit_privilege" ,:as => :edit_privilege
end end
resources :member_selects do resources :member_selects do