diff --git a/ReadMe.txt b/ReadMe.txt index f891d6b75..e7444a6c5 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,3 +1,12 @@ +patch: +用户姓名的部分,根据issues#655。 +为了修改方便 +alias: +方法 之前显示 调整之后 +name firstname+lastname login +nickname xxx login +realname xxx firstname+lastname +================================================================================ app/models/setting.rb :165 # fixed domain url in development. tantantan's bug if Rails.env.development? diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index c469c72ee..0723cf169 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -50,95 +50,34 @@ class MyController < ApplicationController def account @user = User.current @pref = @user.pref - - - - # if @user.user_extensions.nil? - # se = UserExtebsions.new - # se.user_id = @user.id - # se.occupation = params[:occupation] - # se.save - # else - # # = @user.user_extensions - # end - # @occupation = UserExtensions.occupation - # @occupation.save - if request.post? @user.safe_attributes = params[:user] @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') unless @user.user_extensions.nil? if @user.user_extensions.identity == 2 - @user.firstname = params[:enterprise_name] + @user.firstname = params[:enterprise_name] end end - - - # # UserExtensions.create(:user_id => @user.id, :occupation => params[:occupation]) - # else - # ue = @user.user_extensions - # ue.occupation = params[:occupation] - # ue.save - # end - - # added by bai - if @user.user_extensions.nil? - se = UserExtensions.new - se.user_id = @user.id - if params[:occupation] - se.school_id = params[:occupation] - end - - se.gender = params[:gender] - - if params[:province] && params[:city] - se.location = params[:province] - se.location_city = params[:city] - end - if params[:identity] - se.identity = params[:identity].to_i - end - if params[:technical_title] - se.technical_title = params[:technical_title] - end - if params[:no] - se.student_id = params[:no] - end - se.save - else - se = @user.user_extensions - if params[:occupation] - se.school_id = params[:occupation] - end - - se.gender = params[:gender] - - if params[:province] && params[:city] - se.location = params[:province] - se.location_city = params[:city] - end - - if params[:identity] - se.identity= params[:identity].to_i - end - if params[:technical_title] - se.technical_title = params[:technical_title] - end - if params[:no] - se.student_id = params[:no] - end - se.save - end - # end - - if @user.save + + @se = @user.user_extensions ||= UserExtensions.new + @se.school_id = params[:occupation] if params[:occupation] + @se.gender = params[:gender] + @se.location = params[:province] if params[:province] + @se.location_city = params[:city] if params[:city] + @se.identity = params[:identity].to_i if params[:identity] + @se.technical_title = params[:technical_title] if params[:technical_title] + @se.student_id = params[:no] if params[:no] + + if @user.save && @se.save @user.pref.save @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : []) set_language_if_valid @user.language flash[:notice] = l(:notice_account_updated) redirect_to user_path(@user) return + else + @user end end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5d270401a..82a94614f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -800,7 +800,7 @@ class ProjectsController < ApplicationController end def appied_project_members (project, members) - users = AppliedProject.where(:project_id => project.id). + users = AppliedProject.where(:project_id => project.id) memberlist = [] users.each do |user| members.each do |member| diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index 38b32e692..76203fdd7 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -126,17 +126,19 @@ module BidsHelper @users.count end + # 鏌ョ湅瀛﹀彿 def im_watching_student_id? bid people = [] people << bid.author case bid.reward_type # 澶╃厼鐨刡id鍒嗕簡涓夌敤閫旓紝閲岄潰鍚勭hasmany杩樹笉瀹氳兘鐢紒 - when 1 - when 2 + when Bid::Enterprise + when Bid::Contest bid.join_in_contests.each do |jic| people << jic.user end - when 3 - people += bid.courses.first.users.to_a + when Bid::Homework + # people += bid.courses.first.users.to_a + people += searchTeacherAndAssistant(bid.courses.first).to_a else raise 'bids_helper: unknow bid type' # 鍑轰簡閿欑湅杩欓噷锛佷笉鐭ラ亾鐨勬姏寮傚父锛岀渷鐨勬壘涓嶅埌鍑洪敊鐨勫湴鏂癸紒 end diff --git a/app/models/user.rb b/app/models/user.rb index c96e38595..e54658274 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -359,7 +359,7 @@ class User < Principal end # Return user's full name for display - def name(formatter = nil) + def realname(formatter = nil) f = self.class.name_formatter(formatter) if formatter eval('"' + f[:string] + '"') @@ -368,6 +368,10 @@ class User < Principal end end + def name(formatter = nil) + login + end + def active? self.status == STATUS_ACTIVE end diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index 7b35b16b4..b21f0ad36 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -7,6 +7,8 @@ 3 寮鍙戣 =end class UserExtensions < ActiveRecord::Base + validate :school, presence: true + belongs_to :user belongs_to :school, :class_name => 'School', :foreign_key => :school_id attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index c9a8af0a4..f7db8a375 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -51,7 +51,7 @@