From f1c2e29bf1449e1dd56d74f925b1d6543262d1c9 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 29 Nov 2013 16:20:23 +0800 Subject: [PATCH] form validations and ajax check plus user approval done --- .gitignore | 1 + .../images/availability-check-loader.gif | Bin 0 -> 1644 bytes app/assets/stylesheets/sign_up.css | 40 +++++- .../admin/users_new_interface_controller.rb | 14 ++ app/controllers/basic_infos_controller.rb | 16 +++ app/controllers/facebook_controller.rb | 4 +- app/models/user/user.rb | 4 +- .../_not_approved_listing.html.erb | 29 +++++ .../users_new_interface/_side_bar.html.erb | 2 +- .../registration_approval.html.erb | 31 +++++ app/views/basic_infos/index.html.erb | 2 +- app/views/devise/registrations/new.html.erb | 120 ++++++++++++++++-- config/routes.rb | 5 + 13 files changed, 245 insertions(+), 23 deletions(-) create mode 100644 app/assets/images/availability-check-loader.gif create mode 100644 app/views/admin/users_new_interface/_not_approved_listing.html.erb create mode 100644 app/views/admin/users_new_interface/registration_approval.html.erb diff --git a/.gitignore b/.gitignore index 023345b6..82809a67 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ uploads/**/* *.supported mongoid.yml *. +sftp-config.json diff --git a/app/assets/images/availability-check-loader.gif b/app/assets/images/availability-check-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..49b6d85326305cebc519dd8eb1a8fbe108b6f282 GIT binary patch literal 1644 zcmbW%ZA?>V6bJCf+xxWl#rF2T7Vd3(OIL0SDyd2qmMx^-i?iiL%f_59xXDBWW3W@F z9U-%7VN5EhC@1<6Kf|A^YItz~<*mOJ)U?WuH>Z7&P&*jZMdRaITF6Qs?cIFWp{c<#%& zApreXzKGeo*+)cHV@r1k;t|ZZyu({}=)lMVm=~wIyMn=3cSF1)$I*fxyS0^h3Kpu! zq^~vGYsXMg7CzFU1Y}bQ-X$MHYpV$^dQ47ds!2TsdC9?(sH%rJf@!&+CJzvZ5S6#Ms(okvlxx11a=I+S=`_*P&o!FiMvw!w~IWEDra zKBHZ3>PQhzSQUjq0ys42FoBdZWLXi`>;aS@=p>6X9uM$>6*wh^bDh`F%e&o@w1s(J zMXr~el```mBbJkad7-VoNU+jlj_Q64Wq3FfIJn!(c^2Sj!BSfmf&Z~D6kgj|2fIB> zJmig4lN-Yvck5tJvAEa#VVI$fb!LhY4huZT*45F_+Q?v%n3`h2G#EoE(IFFdmZe2o zF+iLWFY_3Ej&*C9l0?cb)Fz(mR0l-8EQ=oxtKub)epg>mpwDMy;qkoGWCnum>#%yi zt2^iedN^D>_9;fy!J#47!bPojbsK=^vcGZSpr1nv7d>e>8v6P7bTyRgFpyS`Ah5zh z6oUJl#B`RJWXVum9tromV~kT~?26H7rmcWtC{C6UHpP1GoQAk$1<))HO-7T( zTo!~M^TQIxbgBpy=wij7RV+$4(}v2mjTZFccQD!UEU zZ4!>6m_5bFoWxLdzl~-sMjAZl$mc&lyY(f*|?|eVL80ZVmEO+_Q<|*89X&t6L{QR5aJMutN_Dt3OytaEoq#dJ$ z=kDM79eM-A0|=uiRsx4Hl1g*YtldR$F-T&FojsMJcsK&}Yn^u9YLp-mBlLS2w+$MN zjTqJr116&x#MY4)w5vus@e??s>4!4G0Nk9PuY-nObzW<7xq_85et;xGxVJVp-M6)8 zz0Rnv_oh;~B?_TcM4J<|7`9wqx=FEAu`uLnW!9xVaS^x^98 zovT0e4Hh6e^;+S)(2lt)@I0JMz+cNcz6K4=UwE@QV0#cn`)YHKclSK;lqhoKsm3gn zruBy9bZrKOA7>8?71Ff$ zqL2^-D}w=~glg-;u`5>sNh@g6p}fFreemje6|Gj0#J3kN=Kq3_c>W6T=G<-lul@zk Ce59oS literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/sign_up.css b/app/assets/stylesheets/sign_up.css index e681da25..d51deb25 100644 --- a/app/assets/stylesheets/sign_up.css +++ b/app/assets/stylesheets/sign_up.css @@ -1,10 +1,12 @@ .sign-up{ margin: 150px auto 0; position: relative; - text-align: center; - width: 500px; + /*text-align: center;*/ + width: 600px; +} +.sign-up.facebook-form{ + text-align: center; } - .sign-up .form{ background-color: #FFFFFF; box-shadow: 0 10px 20px #CBCBCB; @@ -52,10 +54,36 @@ margin-right: 10px; } +.sign-up .notify{ + font-size: 15px; +} + +.notify.alert{ + padding: 5px 10px 5px 3px; +} + +.notify .icon-ok{ + color: green; + margin-right: 3px; + margin-left: 3px; +} + +.notify .icon-remove{ + color: red; + margin-right: 3px; + margin-left: 3px; +} + .sign-up input[type=checkbox]{ margin-top: 0; } +.sign-up .error{ + border-color: #E9322D; + box-shadow: 0 0 6px #F8B987; + color: #B94A48; +} + .line{ border-bottom: 1px solid #EDEDED; } @@ -64,3 +92,9 @@ text-align: left; } +.loader{ + width:100px; + margin-left: 3px; +} + + diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb index 77045ed3..c492083f 100644 --- a/app/controllers/admin/users_new_interface_controller.rb +++ b/app/controllers/admin/users_new_interface_controller.rb @@ -7,6 +7,18 @@ class Admin::UsersNewInterfaceController < OrbitMemberController open_for_user :only => [:setting_account, :edit_user_data, :update] open_for_visitor :only => [:index, :show] + def registration_approval + page_num = params[:page] || 1 + @users = User.approval_pending.page(page_num).per(12).desc("_id") + end + + def approve_registration + user = User.find(params[:users_new_interface_id]) + user.approved = true + user.save + redirect_to admin_users_new_interface_registration_approval_path + end + def index get_tags get_sub_roles @@ -385,6 +397,8 @@ class Admin::UsersNewInterfaceController < OrbitMemberController end @users = User.not_guest_user end + + protected def get_tags diff --git a/app/controllers/basic_infos_controller.rb b/app/controllers/basic_infos_controller.rb index 8386e13d..bda825e9 100644 --- a/app/controllers/basic_infos_controller.rb +++ b/app/controllers/basic_infos_controller.rb @@ -35,4 +35,20 @@ class BasicInfosController < ApplicationController end end + def check_availability + response = {} + case params[:type] + when "user_id" + response["success"] = User.where(:user_id => params[:value]).count > 0 ? false : true + when "user_email" + response["success"] = User.where(:email => params[:value]).count > 0? false : true + end + render :json => response.to_json + end + + + + + + end \ No newline at end of file diff --git a/app/controllers/facebook_controller.rb b/app/controllers/facebook_controller.rb index c2cc4d03..4662301c 100644 --- a/app/controllers/facebook_controller.rb +++ b/app/controllers/facebook_controller.rb @@ -69,14 +69,12 @@ class FacebookController< ApplicationController u.first_name_translations = firstname u.last_name_translations = lastname u.office_tel = user["phone"] - u.email = user["email"] - # u.email = "xyz@zyx.com" u.sex = user["gender"] || "unknown" u.remote_avatar_url = user["picture"] if user["picture"] if u.save render :json=>{"success"=>true,"user"=>user}.to_json else - render :json=>{"success"=>false,"message"=>"Email already occupied."}.to_json + render :json=>{"success"=>false,"message"=>"There was an error imporing data."}.to_json end else diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 815ff355..ee5b08db 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -17,6 +17,7 @@ class User field :last_name, localize: true field :email field :sex, :default => 'unknown' + field :approved, type: Boolean, :default => false field :office_tel field :cache_dept,type: Hash field :status_record,type: Hash @@ -56,7 +57,8 @@ class User before_save :assign_default_position, :if => :assign_default_position? before_save :rebuild_status_record scope :remote_account, where(:nccu_id.ne => nil) - scope :not_guest_user, all_of(:name.ne => "guest") + scope :not_guest_user, all_of(:name.ne => "guest").and(:approved => true) + scope :approval_pending, where(:approved => false) validates :user_id, :presence => { :message => I18n.t("users.user_id_not_null") } , diff --git a/app/views/admin/users_new_interface/_not_approved_listing.html.erb b/app/views/admin/users_new_interface/_not_approved_listing.html.erb new file mode 100644 index 00000000..2a53aceb --- /dev/null +++ b/app/views/admin/users_new_interface/_not_approved_listing.html.erb @@ -0,0 +1,29 @@ + <% + if not_approved_listing.sex == 'male' + @user_sex = 'gender-man' + elsif not_approved_listing.sex == 'female' + @user_sex = 'gender-woman' + else + @user_sex = 'gender-none' + end + %> + + + + <% not_approved_listing.roles.each do |rf| %> + <% @roledata = Role.find(rf.id) %> + <%= @roledata.title %> + <% end %> + + + <%= link_to (not_approved_listing.name && not_approved_listing.name != not_approved_listing.email ? not_approved_listing.name : not_approved_listing.user_id),admin_users_new_interface_path(not_approved_listing) %> +
+ +
+ + <%= not_approved_listing.email %> + \ No newline at end of file diff --git a/app/views/admin/users_new_interface/_side_bar.html.erb b/app/views/admin/users_new_interface/_side_bar.html.erb index fbeedd3c..115d064b 100644 --- a/app/views/admin/users_new_interface/_side_bar.html.erb +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -29,7 +29,7 @@ <%= content_tag :li, link_to((content_tag(:span, t(:all_member))), admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %> <%= content_tag :li, link_to((content_tag(:span, t(:add_member))), new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_authorization))), '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> - <%= content_tag :li, link_to((content_tag(:span, t(:member_registration))), '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((content_tag(:span, t(:member_registration))), admin_users_new_interface_registration_approval_path), :class => active_for_action('users_new_interface', 'registration_approval') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_role))),admin_roles_path ), :class => active_for_action('roles', 'index') if (is_admin? rescue nil) %> <%= content_tag :li, link_to((content_tag(:span, t(:member_info))), edit_admin_info_path(Info.first.id.to_s)), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) and Info.first %> <% end -%> diff --git a/app/views/admin/users_new_interface/registration_approval.html.erb b/app/views/admin/users_new_interface/registration_approval.html.erb new file mode 100644 index 00000000..f7d087b6 --- /dev/null +++ b/app/views/admin/users_new_interface/registration_approval.html.erb @@ -0,0 +1,31 @@ +<% content_for :side_bar do %> + <%= render :partial => 'admin/users_new_interface/side_bar' %> +<% end %> + +<%= render :partial => "js_and_css"%> + +
+ + + + + + + + + + + <% if !@users.blank? %> + <%= render :partial => "not_approved_listing",:collection=> @users %> + <% else %> + + <% end %> + +
RolesNameEmail
Hooray! No pending registration approvals left.
+
+
+ +
+ diff --git a/app/views/basic_infos/index.html.erb b/app/views/basic_infos/index.html.erb index 30af97a5..698fd41f 100644 --- a/app/views/basic_infos/index.html.erb +++ b/app/views/basic_infos/index.html.erb @@ -1,6 +1,6 @@ <%= stylesheet_link_tag "sign_up" %>
-
\ No newline at end of file + + + + + diff --git a/config/routes.rb b/config/routes.rb index 0c7e99d3..05aabae7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ Orbit::Application.routes.draw do get 'basic_infos' => "basic_infos#index" get 'basic_infos/form' => "basic_infos#form_page" get 'basic_infos/role_page' => "basic_infos#role_page" + get 'basic_infos/check_availability' => "basic_infos#check_availability" post 'basic_infos/role_update' => "basic_infos#role_update" match 'basic_infos/basic_info_update' => "basic_infos#basic_info_update" # routes for admin @@ -220,6 +221,8 @@ Orbit::Application.routes.draw do end resources :users + match "users_new_interface/registration_approval" => "users_new_interface#registration_approval" + resources :users_new_interface do member do get 'temp_edit' @@ -234,6 +237,8 @@ Orbit::Application.routes.draw do match "edit_user_data" => "users_new_interface#edit_user_data" ,:as => :edit_user_data match "setting_account" => "users_new_interface#setting_account" ,:as => :setting_account match "edit_privilege" => "users_new_interface#edit_privilege" ,:as => :edit_privilege + match "approve_registration" => "users_new_interface#approve_registration", :as => :approve_registration + end resources :member_selects do