关注取消关注位置漂移

个人主页学号的隐藏
This commit is contained in:
yanxd 2013-12-13 20:01:27 +08:00
parent ee5194e052
commit b703c65033
5 changed files with 53 additions and 17 deletions

View File

@ -14,16 +14,16 @@ module CoursesHelper
# 返回教师数量即roles表中定义的Manager
def teacherCount project
# searchCountByRoles project, TeacherRoles
searchCountByRoles project, TeacherRoles
# or
searchTeacherAndAssistant(project).count
# searchTeacherAndAssistant(project).count
end
# 返回学生数量即roles表中定义的Reporter
def studentCount project
# searchCountByRoles project,StudentRoles
searchCountByRoles project,StudentRoles
# or
searchStudent(project).count
# searchStudent(project).count
end
# =====================================================================================
@ -38,29 +38,29 @@ module CoursesHelper
# =====================================================================================
def searchCountByRoles project, roles_id
people = searchPeopleByRoles project, roles_id
people.count
members = searchPeopleByRoles project, roles_id
members.count
end
def searchPeopleByRoles project, roles_id
people = []
members = []
begin
people = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
members = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}"
end
people
members
end
#useless
def searchPeopleByRole project, role_id
people = []
def searchMembersByRole project, role_id
members = []
begin
people = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
members = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}"
end
people
members
end
def findCourseTime project
@ -78,4 +78,13 @@ module CoursesHelper
end
str
end
def members_to_user_ids members
people = []
members.each { |member|
people << member.user_id
}
people
end
end

View File

@ -214,4 +214,24 @@ module UsersHelper
person_gender = user.user_extensions.gender
img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png'
end
include CoursesHelper
def is_watching?(user)
login_user = User.current# 登录者
courses = user.projects.where('project_type=1')
return true if ((login_user == user) or login_user.admin?)
courses.each do |course|
return true if login_user.member_of?(course)
end
## 下面的代码只判断是否是老师或者助教,上面是成员都可以看到
# people_ids = []
# user.projects.where('project_type=1').each do |project|
# tmp = searchTeacherAndAssistant(project)
# people_ids += (members_to_user_ids(tmp)) unless tmp.nil?
# end
# people_ids.include?(login_user.id) or (login_user == user) or login_user.admin?
false
end
end

View File

@ -1,3 +1,10 @@
=begin
identity字段含义
0
1
2
3
=end
class UserExtensions < ActiveRecord::Base
belongs_to :user
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id

View File

@ -62,9 +62,9 @@
<div class="info-course">
<%= @project.name %>
</div>
<div>
<div style="text-align: center;">
<% unless User.current.member_of? @project %>
<%= watcher_link(@project, User.current) %>
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
<% end %>
</div></td>
</tr>

View File

@ -27,7 +27,7 @@
<table>
<tr>
<td class="info_font" style="width: 238px; color: #15bccf"><%= l(:label_user_home) %></td>
<td style="width: 430px; color: #15bccf""><strong><%= l(:label_user_location) %> : </strong></td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px">
<div class="top-content-search">
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
@ -143,7 +143,7 @@
<%= l(:label_technical_title) %>:</td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"><%= @user.user_extensions.technical_title %></td>
<% end %>
</tr>
<% if @user.user_extensions.identity == 1 %>
<% if( (@user.user_extensions.identity == 1) && (is_watching?(@user) ) )%>
<tr>
<td style="padding-left: 8px" width="70px"><%= l(:label_bidding_user_studentcode)%>:</td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"><%= @user.user_extensions.student_id %></td>
</tr>