can add member

This commit is contained in:
Matthew K. Fu JuYuan 2012-10-15 13:54:29 +08:00
parent b5571dbc43
commit 7901de7b31
11 changed files with 86 additions and 6 deletions

View File

@ -75,16 +75,24 @@ class Admin::UsersNewInterfaceController < ApplicationController
def new
@user = User.new
@form_index = 0
get_info_and_roles
end
def create
puts params.to_yaml
@user = User.new(params[:user])
attribute_valuesp_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
attribute_values = params[:user].delete(attribute_valuesp_key)
# binding.pry
@user = User.new(params["user"])
attribute_values.to_hash.each{|key,value|
@user.attribute_values.build(value)
}
if @user.save
flash[:notice] = t('admin.create_success_user')
redirect_to :action => :index
else
@form_index = 0
render :action => :new
end
end

View File

@ -2,7 +2,7 @@ class AttributeField
include Mongoid::Document
include Mongoid::Timestamps
include AttributeFieldHelper
include ::AttributeFieldsHelper
field :key
field :markup

View File

@ -10,7 +10,7 @@ class User
field :admin, :type => Boolean, :default => true
field :active_role
field :nccu_ldap_uid
field :email
# field :cache_dept
# has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
field :cache_dept,type: Hash
@ -37,6 +37,8 @@ class User
before_save :check_status_record
scope :remote_account, where(:nccu_id.ne => nil)
validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
def set_sub_role(sub_role_id,status_id)
self.sub_roles << SubRole.find(sub_role_id)

View File

@ -16,4 +16,4 @@
</div>
<%= render :partial=>"infos"%>
<%= render :partial=>"roles"%>

View File

@ -0,0 +1,12 @@
<div class="map-block back">
<h4><span><%= role.title %></span></h4>
<div class="form-horizontal">
<% role.attribute_fields.each do |af|%>
<%= af.block_helper(@user,@form_index)%>
<% @form_index = @form_index +1 %>
<% end %>
</div>
</div>

View File

@ -0,0 +1 @@
<%=render :partial=>"role",:collection=>Role.all%>

View File

@ -0,0 +1,26 @@
<%#= devise_error_messages! %>
<div class="map-block back">
<h4><span><%=t('admin.user_new_interface.sys_basic_form')%></span></h4>
<form class="form-horizontal">
<div class="control-group">
<%= f.label t('admin.user_new_interface.email'),:class=>"control-label" %><br />
<div class="controls">
<%= f.email_field :email %>
</div>
</div>
<div class="control-group">
<%= f.label t('admin.user_new_interface.password'),:class=>"control-label" %>
<div class="controls">
<%= f.password_field :password %>
</div>
</div>
<div class="control-group">
<%= f.label t('admin.user_new_interface.password_confirmation'),:class=>"control-label" %>
<div class="controls">
<div class="controls">
<%= f.password_field :password_confirmation %>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,26 @@
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<%= stylesheet_link_tag "isotope" %>
<% end -%>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
<%= javascript_include_tag "inc/modal-preview" %>
<%= javascript_include_tag "lib/contenteditable" %>
<% end -%>
<%= content_tag :div,:class=>"user-role site-map" do%>
<%= form_for @user, :url => admin_users_new_interface_index_path, :html => { :multipart => true },:method => :post do |f| %>
<%= f.error_messages %>
<%= render :partial => 'user_basic', :locals => {:f => f}%>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="button_bar">
<%#= link_back %>
<%#= link_to t('update'), "#", :onclick=>"$('#edit_user_#{@user.id}').submit()" %>
<%= f.submit%>
</div>
<% end -%>
<% end -%>

View File

@ -34,8 +34,7 @@
<p class="user-mail">
<%= @user.email %>
</p>
<%= link_to "<i class='icon-pencil'></i>TempEdit".html_safe,temp_edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%>
<button class="btn btn-small"><i class="icon-pencil"></i> <%= t("admin.edit")%></button>
<%= link_to "<i class='icon-pencil'></i>#{t('admin.edit')}".html_safe,edit_admin_users_new_interface_path(@user),:class=>"btn btn-small"%>
</div>
<div class="user-roles my_scroll">
<div class="scrollbar">

View File

@ -30,6 +30,7 @@ zh_tw:
signed_up: '您已經成功的登錄,確認信件已送至您的 Email 信箱。'
updated: '您已經成功的更新帳號資訊。'
destroyed: '再會!您的帳號已被取消。有緣再會。'
email_not_unique: '已被註冊'
unlocks:
send_instructions: '您將在幾分鐘後收到一封電子郵件,內有將帳號解除鎖定的步驟說明。'
unlocked: '您的帳號已被解鎖,現在您已成功登入。'

View File

@ -311,6 +311,11 @@ zh_tw:
upload_design: 上傳設計
url: URL
user: 用戶
user_new_interface:
sys_basic_form: 系統基本資料表
password: 密碼
password_confirmation: 確認密碼
email: 使用者帳號信箱
user_role:
auth:
all_member: 所有會員