From 0338557a33106fa348e08782df80aa47457fea76 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 27 Nov 2013 19:29:23 +0800 Subject: [PATCH] redirection to login page after creating new user, account validation done, fill in all languages for names also done plus the name error in the backend for noname or half filled profile is also fixed --- app/controllers/application_controller.rb | 1 - app/controllers/basic_infos_controller.rb | 2 +- app/controllers/facebook_controller.rb | 19 +++++++++++++++---- .../_user_for_listing.html.erb | 2 +- .../_user_for_summary.html.erb | 2 +- .../_user_for_thumbnail.html.erb | 2 +- app/views/basic_infos/index.html.erb | 2 +- sftp-config.json | 2 +- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dedb3d0b..bded1cb3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,7 +29,6 @@ class ApplicationController < ActionController::Base end end - def site_restart Resque.enqueue(RestartServer) end diff --git a/app/controllers/basic_infos_controller.rb b/app/controllers/basic_infos_controller.rb index 2d91bfc7..8386e13d 100644 --- a/app/controllers/basic_infos_controller.rb +++ b/app/controllers/basic_infos_controller.rb @@ -28,7 +28,7 @@ class BasicInfosController < ApplicationController def role_update user = User.find(params[:id]) if user.update_attributes(params[:user]) - redirect_to root_path + redirect_to "/users/sign_in" else @roles = Role.where(:disabled => false) render :action => "role_page" diff --git a/app/controllers/facebook_controller.rb b/app/controllers/facebook_controller.rb index 9dc7c581..c2cc4d03 100644 --- a/app/controllers/facebook_controller.rb +++ b/app/controllers/facebook_controller.rb @@ -60,14 +60,25 @@ class FacebookController< ApplicationController if data["success"] user = JSON.parse(data["user"]) u = User.find(current_user.id) - u.first_name = user["first_name"] - u.last_name = user["last_name"] + firstname = {} + lastname = {} + @site_valid_locales.each do |locale| + firstname[locale] = user["first_name"] + lastname[locale] = user["last_name"] + end + 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"] - u.save! - render :json=>{"success"=>true,"user"=>user}.to_json + if u.save + render :json=>{"success"=>true,"user"=>user}.to_json + else + render :json=>{"success"=>false,"message"=>"Email already occupied."}.to_json + end + else render :json=>{"success"=>false,"message"=>data["message"]}.to_json end diff --git a/app/views/admin/users_new_interface/_user_for_listing.html.erb b/app/views/admin/users_new_interface/_user_for_listing.html.erb index 987d1b57..d77bf738 100644 --- a/app/views/admin/users_new_interface/_user_for_listing.html.erb +++ b/app/views/admin/users_new_interface/_user_for_listing.html.erb @@ -16,7 +16,7 @@ <% end %> - <%= link_to user_for_listing.name,admin_users_new_interface_path(user_for_listing) %> + <%= link_to (user_for_listing.name ? user_for_listing.name : user_for_listing.user_id),admin_users_new_interface_path(user_for_listing) %>
-

<%= link_to user_for_summary.name,admin_users_new_interface_path(user_for_summary)%>

+

<%= link_to (user_for_summary.name ? user_for_summary.name : user_for_summary.user_id),admin_users_new_interface_path(user_for_summary)%>

<%= user_for_summary.email%>

<%= image_tag(user_for_thumbnail.avatar) %> -

<%= link_to user_for_thumbnail.name,admin_users_new_interface_path(user_for_thumbnail)%>

+

<%= link_to (user_for_thumbnail.name ? user_for_thumbnail.name : user_for_thumbnail.user_id),admin_users_new_interface_path(user_for_thumbnail)%>

\ No newline at end of file diff --git a/app/views/basic_infos/index.html.erb b/app/views/basic_infos/index.html.erb index 8df10bcc..30af97a5 100644 --- a/app/views/basic_infos/index.html.erb +++ b/app/views/basic_infos/index.html.erb @@ -28,7 +28,7 @@ timeInterval = setInterval(function(){ if( facebookWindow.closed ){ clearInterval(timeInterval); - $(".msg").removeClass('hide').find("h4").text("Importing,please wait..."); + $(".msg").removeClass('hide alert-danger').find("h4").text("Importing,please wait..."); $.ajax({ url : "/facebook/profile_import", data : {"user_id":"<%= @user.id.to_s %>"}, diff --git a/sftp-config.json b/sftp-config.json index f489bec4..0e0efa6c 100644 --- a/sftp-config.json +++ b/sftp-config.json @@ -6,7 +6,7 @@ "type": "sftp", "save_before_upload": true, - "upload_on_save": false, + "upload_on_save": true, "sync_down_on_open": false, "sync_skip_deletes": false, "confirm_downloads": false,