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

exceptionHandle
nieguanghui 12 years ago
parent 529a997991
commit 8df3bcf76f

@ -1,63 +1,82 @@
# encoding: utf-8
## This helper be included in applicationHelper
module CoursesHelper
=begin
1. define TeacherRoles, StudentRoles
2. define count function
3. define search by roles
4. define search member function
1. define TeacherRoles, StudentRoles
2. define count function
3. define search by roles
4. define search member function
=end
TeacherRoles = [3, 4, 7, 9]
StudentRoles = [5, 10]
## return people count
# 返回教师数量即roles表中定义的Manager
def teacherCount project
# searchCountByRoles project, TeacherRoles
# or
searchTeacherAndAssistant(project).count
end
# 返回学生数量即roles表中定义的Reporter
def studentCount project
# searchCountByRoles project,StudentRoles
# or
searchStudent(project).count
end
# =====================================================================================
# return people list
def searchTeacherAndAssistant project
searchPeopleByRoles(project, TeacherRoles)
end
def searchStudent project
searchPeopleByRoles(project, StudentRoles)
end
# =====================================================================================
def searchCountByRoles project, roles_id
people = searchPeopleByRoles project, roles_id
people.count
end
def searchPeopleByRoles project, roles_id
people = []
begin
people = 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
end
#useless
def searchPeopleByRole project, role_id
people = []
begin
people = 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
end
TeacherRoles = [3, 4, 7, 9]
StudentRoles = [5, 10]
## return people count
# 返回教师数量即roles表中定义的Manager
def teacherCount project
# searchCountByRoles project, TeacherRoles
# or
searchTeacherAndAssistant(project).count
end
# 返回学生数量即roles表中定义的Reporter
def studentCount project
# searchCountByRoles project,StudentRoles
# or
searchStudent(project).count
end
# =====================================================================================
# return people list
def searchTeacherAndAssistant project
searchPeopleByRoles(project, TeacherRoles)
end
def searchStudent project
searchPeopleByRoles(project, StudentRoles)
end
# =====================================================================================
def searchCountByRoles project, roles_id
people = searchPeopleByRoles project, roles_id
people.count
end
def searchPeopleByRoles project, roles_id
people = []
begin
people = 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
end
#useless
def searchPeopleByRole project, role_id
people = []
begin
people = 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
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

@ -66,19 +66,20 @@ module ProjectsHelper
content = ''.html_safe
case state
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_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
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_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
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_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
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs_enterprise")
@ -107,27 +108,27 @@ module ProjectsHelper
content_tag('div', content, :class => "tabs")
end
def sort_course(state, project_type)
content = ''.html_safe
case state
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_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
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_time), course_path(:project_sort_type => '0', :project_type => project_type)))
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_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
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
# def sort_course(state, project_type)
# content = ''.html_safe
# case state
# 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_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
#
# 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_time), course_path(:project_sort_type => '0', :project_type => project_type)))
# 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_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
# content = content_tag('ul', content)
# content_tag('div', content, :class => "tabs")
# end
#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进行刷新 -->
<%= 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) == "" %>

@ -55,11 +55,7 @@
<div class="add-info">
<div class="main-language" style="margin-left: 30px;margin-top:-10px">
<%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%>
<% unless Course.find_by_extra(@project.identifier).nil? %>
<%= 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 %>
<%= findCourseTime @project %>
</div>
</div>

@ -17,7 +17,7 @@
<%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>
<div class="clear avatar_user">
<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>
</div>
<% end %>

@ -89,7 +89,7 @@
</div>
<div class="grade">
<% 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 %>
</div>
<!-- added by liuping -->

@ -66,23 +66,18 @@
<% html_title(l(:label_user_plural)) -%>
<% else %>
<!-- <div class="contextual">
<%= link_to l(:label_user_new), new_user_path, :class => 'icon icon-add' %>
</div> -->
<div class="project-search-block">
<span><%= l(:label_user_plural)%></span>
<%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %>
<!-- <fieldset>
<legend>
<%= l(:label_filter_plural) %>
</legend> -->
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>
<%= submit_tag l(:label_search), :class => "small", :name => nil %><!--Modified by young-->
<!-- </fieldset> -->
<% end %>
</div>
</div>
@ -91,19 +86,7 @@
<%= 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">
@ -113,15 +96,15 @@
<%= 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"%>
<!-- <%= 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>
<%= image_tag(url_to_avatar(user), :class => 'avatar') %>
<%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
<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>
<!-- <%= content_tag "div", "#{l(:label_user_grade)}:" %><%= user.user_status.grade %> -->
</div>
<div style="margin-top: 20px;margin-left:66px">
@ -129,9 +112,7 @@
<%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
</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">
<% unless user.memberships.empty? %>

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

Loading…
Cancel
Save