parent
ee5194e052
commit
b703c65033
|
@ -14,16 +14,16 @@ module CoursesHelper
|
||||||
|
|
||||||
# 返回教师数量,即roles表中定义的Manager
|
# 返回教师数量,即roles表中定义的Manager
|
||||||
def teacherCount project
|
def teacherCount project
|
||||||
# searchCountByRoles project, TeacherRoles
|
searchCountByRoles project, TeacherRoles
|
||||||
# or
|
# or
|
||||||
searchTeacherAndAssistant(project).count
|
# searchTeacherAndAssistant(project).count
|
||||||
end
|
end
|
||||||
|
|
||||||
# 返回学生数量,即roles表中定义的Reporter
|
# 返回学生数量,即roles表中定义的Reporter
|
||||||
def studentCount project
|
def studentCount project
|
||||||
# searchCountByRoles project,StudentRoles
|
searchCountByRoles project,StudentRoles
|
||||||
# or
|
# or
|
||||||
searchStudent(project).count
|
# searchStudent(project).count
|
||||||
end
|
end
|
||||||
|
|
||||||
# =====================================================================================
|
# =====================================================================================
|
||||||
|
@ -38,29 +38,29 @@ module CoursesHelper
|
||||||
# =====================================================================================
|
# =====================================================================================
|
||||||
|
|
||||||
def searchCountByRoles project, roles_id
|
def searchCountByRoles project, roles_id
|
||||||
people = searchPeopleByRoles project, roles_id
|
members = searchPeopleByRoles project, roles_id
|
||||||
people.count
|
members.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def searchPeopleByRoles project, roles_id
|
def searchPeopleByRoles project, roles_id
|
||||||
people = []
|
members = []
|
||||||
begin
|
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
|
rescue Exception => e
|
||||||
logger.error "[CoursesHelper] ===> #{e}"
|
logger.error "[CoursesHelper] ===> #{e}"
|
||||||
end
|
end
|
||||||
people
|
members
|
||||||
end
|
end
|
||||||
|
|
||||||
#useless
|
#useless
|
||||||
def searchPeopleByRole project, role_id
|
def searchMembersByRole project, role_id
|
||||||
people = []
|
members = []
|
||||||
begin
|
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
|
rescue Exception => e
|
||||||
logger.error "[CoursesHelper] ===> #{e}"
|
logger.error "[CoursesHelper] ===> #{e}"
|
||||||
end
|
end
|
||||||
people
|
members
|
||||||
end
|
end
|
||||||
|
|
||||||
def findCourseTime project
|
def findCourseTime project
|
||||||
|
@ -78,4 +78,13 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
str
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def members_to_user_ids members
|
||||||
|
people = []
|
||||||
|
members.each { |member|
|
||||||
|
people << member.user_id
|
||||||
|
}
|
||||||
|
people
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -214,4 +214,24 @@ module UsersHelper
|
||||||
person_gender = user.user_extensions.gender
|
person_gender = user.user_extensions.gender
|
||||||
img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png'
|
img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png'
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
=begin
|
||||||
|
identity字段含义
|
||||||
|
0 教师教授
|
||||||
|
1 学生
|
||||||
|
2 企业
|
||||||
|
3 开发者
|
||||||
|
=end
|
||||||
class UserExtensions < ActiveRecord::Base
|
class UserExtensions < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id
|
attr_accessible :user_id,:birthday,:brief_introduction,:gender,:location,:occupation,:work_experience,:zip_code,:identity, :technical_title,:student_id
|
||||||
|
|
|
@ -62,9 +62,9 @@
|
||||||
<div class="info-course">
|
<div class="info-course">
|
||||||
<%= @project.name %>
|
<%= @project.name %>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div style="text-align: center;">
|
||||||
<% unless User.current.member_of? @project %>
|
<% unless User.current.member_of? @project %>
|
||||||
<%= watcher_link(@project, User.current) %>
|
<span class="icon-fav icon"></span><%= watcher_link(@project, User.current) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div></td>
|
</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="info_font" style="width: 238px; color: #15bccf"><%= l(:label_user_home) %></td>
|
<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">
|
<td rowspan="2" width="250px">
|
||||||
<div class="top-content-search">
|
<div class="top-content-search">
|
||||||
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
|
<%= 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>
|
<%= l(:label_technical_title) %>:</td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"><%= @user.user_extensions.technical_title %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% if @user.user_extensions.identity == 1 %>
|
<% if( (@user.user_extensions.identity == 1) && (is_watching?(@user) ) )%>
|
||||||
<tr>
|
<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>
|
<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>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue