From 9c75b701f4b601888ac49ad22f0b460a32fbab7e Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 22 May 2014 18:59:09 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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| From 62f9ed052bc739018a96d3f1dcccb9b50cd14368 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 22 May 2014 19:58:13 +0800 Subject: [PATCH 2/2] issues#655 --- ReadMe.txt | 9 +++ app/controllers/my_controller.rb | 89 ++++---------------------- app/helpers/bids_helper.rb | 10 +-- app/models/user.rb | 6 +- app/models/user_extensions.rb | 2 + app/views/bids/_homework_list.html.erb | 2 +- app/views/my/account.html.erb | 2 + app/views/users/_course_form.html.erb | 2 +- 8 files changed, 40 insertions(+), 82 deletions(-) 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/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 8017ed5f8..0fe9e7320 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 1381df74a..e414d9b08 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -39,7 +39,7 @@   - 鍙戝竷浜:  <%= link_to homework.user, user_path(homework.user)%> + 鍙戝竷浜:  <%= link_to (display_id ? homework.user.realname : homework.user ), user_path(homework.user)%> 浣滀笟璇勫垎锛 diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index f9b4e9ac3..0418697c3 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -33,6 +33,8 @@

<%= l(:label_my_account) %>

+<%= error_messages_for 'user' %> +<%= error_messages_for 'se' %>