修改评分显示颜色,重构课程列表显示部分代码

exceptionHandle
nieguanghui 12 years ago
parent 529a997991
commit 8df3bcf76f

@ -1,63 +1,82 @@
# encoding: utf-8
## This helper be included in applicationHelper ## This helper be included in applicationHelper
module CoursesHelper module CoursesHelper
=begin =begin
1. define TeacherRoles, StudentRoles 1. define TeacherRoles, StudentRoles
2. define count function 2. define count function
3. define search by roles 3. define search by roles
4. define search member function 4. define search member function
=end =end
TeacherRoles = [3, 4, 7, 9] TeacherRoles = [3, 4, 7, 9]
StudentRoles = [5, 10] StudentRoles = [5, 10]
## return people count ## return people count
# 返回教师数量即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
def studentCount project # 返回学生数量即roles表中定义的Reporter
# searchCountByRoles project,StudentRoles def studentCount project
# or # searchCountByRoles project,StudentRoles
searchStudent(project).count # or
end searchStudent(project).count
end
# =====================================================================================
# return people list # =====================================================================================
def searchTeacherAndAssistant project # return people list
searchPeopleByRoles(project, TeacherRoles) def searchTeacherAndAssistant project
end searchPeopleByRoles(project, TeacherRoles)
end
def searchStudent project
searchPeopleByRoles(project, StudentRoles) def searchStudent project
end searchPeopleByRoles(project, StudentRoles)
# ===================================================================================== end
# =====================================================================================
def searchCountByRoles project, roles_id
people = searchPeopleByRoles project, roles_id def searchCountByRoles project, roles_id
people.count people = searchPeopleByRoles project, roles_id
end people.count
end
def searchPeopleByRoles project, roles_id
people = [] def searchPeopleByRoles project, roles_id
begin people = []
people = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id}) begin
rescue Exception => e people = project.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => roles_id})
logger.error "[CoursesHelper] ===> #{e}" rescue Exception => e
end logger.error "[CoursesHelper] ===> #{e}"
people end
end people
end
#useless
def searchPeopleByRole project, role_id #useless
people = [] def searchPeopleByRole project, role_id
begin people = []
people = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id }) begin
rescue Exception => e people = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => role_id })
logger.error "[CoursesHelper] ===> #{e}" rescue Exception => e
end logger.error "[CoursesHelper] ===> #{e}"
people end
end people
end
def findCourseTime project
#logger.error "=============================#{l(:date)[:formats][:long] } "
date_format = l(:zh_date)[:formats][:default]
@course = Course.find_by_extra(@project.identifier)
str = ""
begin
unless @course.nil?
str = DateTime.parse(@course.setup_time.to_s).strftime("#{date_format}").to_s unless @course.setup_time.blank?
str << '-' unless @course.setup_time.blank?
str << DateTime.parse(@course.endup_time.to_s).strftime("#{date_format}").to_s unless @course.endup_time.blank?
end
rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}"
end
str
end
end end

@ -66,19 +66,20 @@ module ProjectsHelper
content = ''.html_safe content = ''.html_safe
case state case state
when 0 when 0
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1
when 1
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
when 2 when 2
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
end end
content = content_tag('ul', content) content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise") content_tag('div', content, :class => "tabs_enterprise")
@ -107,27 +108,27 @@ module ProjectsHelper
content_tag('div', content, :class => "tabs") content_tag('div', content, :class => "tabs")
end end
def sort_course(state, project_type) # def sort_course(state, project_type)
content = ''.html_safe # content = ''.html_safe
case state # case state
when 0 # when 0
#
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
when 1 # when 1
#
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
when 2 # when 2
content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type)))
content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type)))
end # end
content = content_tag('ul', content) # content = content_tag('ul', content)
content_tag('div', content, :class => "tabs") # content_tag('div', content, :class => "tabs")
end # end
#Added by young #Added by young

@ -43,7 +43,7 @@
<!-- 如果需求到期 并且是该需求的管理员 --> <!-- 如果需求到期 并且是该需求的管理员 -->
<td style="color: red;" align="right" valign="0.1em" width="16%"> <td style="color: #ec6300;" align="right" valign="0.1em" width="16%">
<strong><span id="reward_result_<%=b_project.id%>"> <!-- 调用js进行刷新 --> <strong><span id="reward_result_<%=b_project.id%>"> <!-- 调用js进行刷新 -->
<%= l(:label_system_grade) %>:<%= (b_project.project.project_status.nil? ? 0.0 : b_project.project.project_status.grade) unless (b_project.project.project_status.nil? && b_project.project.nil?) %> <%= l(:label_system_grade) %>:<%= (b_project.project.project_status.nil? ? 0.0 : b_project.project.project_status.grade) unless (b_project.project.project_status.nil? && b_project.project.nil?) %>
<% if get_prize(b_project).nil? or get_prize(b_project) == "" %> <% if get_prize(b_project).nil? or get_prize(b_project) == "" %>

@ -55,11 +55,7 @@
<div class="add-info"> <div class="add-info">
<div class="main-language" style="margin-left: 30px;margin-top:-10px"> <div class="main-language" style="margin-left: 30px;margin-top:-10px">
<%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%> <%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%>
<% unless Course.find_by_extra(@project.identifier).nil? %> <%= findCourseTime @project %>
<%= DateTime.parse(Course.find_by_extra(@project.identifier).setup_time.to_s).strftime("%Y年%m月%d日").to_s unless Course.find_by_extra(@project.identifier).setup_time.blank? %>
<%= '-' unless Course.find_by_extra(@project.identifier).setup_time.blank? %>
<%= DateTime.parse(Course.find_by_extra(@project.identifier).endup_time.to_s).strftime("%Y年%m月%d日").to_s unless Course.find_by_extra(@project.identifier).endup_time.blank? %>
<% end %>
</div> </div>
</div> </div>

@ -17,7 +17,7 @@
<%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %> <%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>
<div class="clear avatar_user"> <div class="clear avatar_user">
<p> <p>
<%= l(:label_user_for_project_grade) %>: <span style="color:red"><%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %></span> <%= l(:label_user_for_project_grade) %>: <span style="color:#ec6300"><%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %></span>
</p> </p>
</div> </div>
<% end %> <% end %>

@ -89,7 +89,7 @@
</div> </div>
<div class="grade"> <div class="grade">
<% if @project.project_type !=1 %> <% if @project.project_type !=1 %>
<%= content_tag('span', "#{l(:label_project_grade)}: ")%><span style='color:red'><%=@project.project_status ? @project.project_status.grade : 0.0 %></span> <%= content_tag('span', "#{l(:label_project_grade)}: ")%><span style='color:#ec6300'><%=@project.project_status ? @project.project_status.grade : 0.0 %></span>
<% end %> <% end %>
</div> </div>
<!-- added by liuping --> <!-- added by liuping -->

@ -66,23 +66,18 @@
<% html_title(l(:label_user_plural)) -%> <% html_title(l(:label_user_plural)) -%>
<% else %> <% else %>
<!-- <div class="contextual">
<%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %>
</div> -->
<div class="project-search-block"> <div class="project-search-block">
<span><%= l(:label_user_plural)%></span> <span><%= l(:label_user_plural)%></span>
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %> <%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
<!-- <fieldset>
<legend>
<%= l(:label_filter_plural) %>
</legend> -->
<div class="project-search"> <div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %> <%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young--> <%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
<!-- </fieldset> -->
<% end %> <% end %>
</div> </div>
</div> </div>
@ -91,19 +86,7 @@
<%= sort_user(@s_type, @project_type)%> <%= sort_user(@s_type, @project_type)%>
<!-- <div class="pagination" style="border-bottom: 1px solid rgb(223,223,223); width: 95%; margin-left: 2%; margin-top: 0px">
<ul style="margin-right:0px">
<li>
<%= link_to l(:label_sort_by_time), users_path(:user_sort_type => '0') %>
</li>
<li>
<%= link_to l(:label_sort_by_active), users_path(:user_sort_type => '1') %>
</li>
<li>
<%= link_to l(:label_sort_by_influence), users_path(:user_sort_type => '2') %>
</li>
</ul>
</div> -->
<div class="autoscroll"> <div class="autoscroll">
@ -113,15 +96,15 @@
<%= content_tag "p", "#{format_date(user.created_on)} #{l(:label_member_since)}", :class => "float_right member_since" %> <%= content_tag "p", "#{format_date(user.created_on)} #{l(:label_member_since)}", :class => "float_right member_since" %>
<%= image_tag "/images/time_member.png", :class => "img_member_time"%> <%= image_tag "/images/time_member.png", :class => "img_member_time"%>
<!-- <%= get_avatar?(user) ? (link_to image_tag(avatar_image(user), :class => 'avatar'), user_path(user), :class => "avatar") : (link_to image_tag("/images/12_50.png", :class => 'avatar'), user_path(user), :class => "avatar") %> -->
<div> <div>
<%= image_tag(url_to_avatar(user), :class => 'avatar') %> <%= image_tag(url_to_avatar(user), :class => 'avatar') %>
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %> <%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
<div style="position:relative;float:left;margin-top:-2px;margin-left: 160px"> <div style="position:relative;float:left;margin-top:-2px;margin-left: 160px">
<%= l(:label_user_grade) %>: <span style="color:red"><%= user.user_status.grade %></span> <%= l(:label_user_grade) %>: <span style="color:#ec6300"><%= user.user_status.grade %></span>
</div> </div>
<!-- <%= content_tag "div", "#{l(:label_user_grade)}:" %><%= user.user_status.grade %> -->
</div> </div>
<div style="margin-top: 20px;margin-left:66px"> <div style="margin-top: 20px;margin-left:66px">
@ -129,9 +112,7 @@
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %> <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
</div> </div>
<!-- <div style="position:relative;float:left;margin-top:-20px;margin-left: 724px">
<%= l(:label_user_grade) %>: <span style="color:red"><%= user.user_status.grade %></span>
</div> -->
<div class="user-bottom"> <div class="user-bottom">
<% unless user.memberships.empty? %> <% unless user.memberships.empty? %>

@ -14,6 +14,9 @@ zh:
default: "%Y-%m-%d" default: "%Y-%m-%d"
short: "%b%d日" short: "%b%d日"
long: "%Y年%b%d日" long: "%Y年%b%d日"
zh_date:
formats:
default: "%Y年%m月%d日"
day_names: [星期天, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六] day_names: [星期天, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
abbr_day_names: [日, 一, 二, 三, 四, 五, 六] abbr_day_names: [日, 一, 二, 三, 四, 五, 六]

Loading…
Cancel
Save