Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
sw 2014-05-22 20:01:34 +08:00
commit 0ec7d6b4e7
9 changed files with 41 additions and 83 deletions

View File

@ -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?

View File

@ -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

View File

@ -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|

View File

@ -126,17 +126,19 @@ module BidsHelper
@users.count
end
# 查看学号
def im_watching_student_id? bid
people = []
people << bid.author
case bid.reward_type # 天煞的bid分了三用途里面各种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

View File

@ -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

View File

@ -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

View File

@ -51,7 +51,7 @@
</tr>
<tr>
<td colspan="1" valign="top" style="width: 300px">&nbsp;
<strong>发布人:&nbsp; <%= link_to homework.user, user_path(homework.user)%></strong>
<strong>发布人:&nbsp; <%= link_to (display_id ? homework.user.realname : homework.user ), user_path(homework.user)%></strong>
</td>
<td>
<strong>作业评分:</strong>

View File

@ -33,6 +33,8 @@
</div>
<h3 style="padding-left: 10px;"><%= l(:label_my_account) %></h3>
<%= error_messages_for 'user' %>
<%= error_messages_for 'se' %>
<fieldset class="box" style="margin:10px;">
<fieldset class="collapsible collapsed" style="width:800px;margin-left: 10px;">

View File

@ -41,7 +41,7 @@
<% @course = Course.find_by_extra(membership.project.identifier) %>
<% unless (@course.nil? || @course.teacher.nil? || @course.teacher.name.nil?) %>
<span class="font-lighter" style="float: left"><%= l(:label_main_teacher) %>
: <%= link_to(@course.teacher.name, user_path(@course.teacher)) %></span>
: <%= link_to(@course.teacher.realname, user_path(@course.teacher)) %></span>
<span style="float: right; padding-left: 8px"><%= l(:label_course_term) %>
: <%= @course.time %><%= @course.term %></span>
<% end %>