diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 731a251f2..669da5502 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -30,6 +30,8 @@ class AccountController < ApplicationController user = UserExtensions.where(:user_id => User.current.id).first if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? redirect_to my_account_path(:tip => 1) + elsif user.identity == 3 && user.occupation.nil? + redirect_to my_account_path(:tip => 1) else redirect_to user_path(User.current) end @@ -357,6 +359,8 @@ class AccountController < ApplicationController user = UserExtensions.where(:user_id => User.current.id).first if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? redirect_to my_account_path(:tip => 1) + elsif user.identity == 3 && user.occupation.nil? + redirect_to my_account_path(:tip => 1) else redirect_back_or_default User.current #redirect_to my_account_url diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 3aefdfd1d..db64e7942 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -145,8 +145,10 @@ class MyController < ApplicationController @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') #@user.login = params[:login] unless @user.user_extensions.nil? - if @user.user_extensions.identity == 2 + # 如果用户是从业者,将单位名称保存至学校id字段 + if @user.user_extensions.identity == 3 # @user.firstname = params[:enterprise_name] + @user.user_extensions.school_id = params[:occupation] end end @@ -157,7 +159,6 @@ class MyController < ApplicationController # @se.occupation = params[:occupation] # end @se.school_id = params[:occupation] - @se.gender = params[:sex] @se.location = params[:province] if params[:province] @se.location_city = params[:city] if params[:city] @@ -180,6 +181,7 @@ class MyController < ApplicationController @user.login = lg end end + # 不管前面是否有异常,如果文件已存在就删除 ensure File.delete(diskfile1) if File.exist?(diskfile1) end diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 2e14f493b..e58beb8d6 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -99,8 +99,13 @@
<% elsif User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %> - - + <% if User.current.user_extensions.school_id.nil? %> + + + <% else %> + + + <% end %>@@ -169,7 +174,7 @@