diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 6b516633e..0eb9cf3a5 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -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 diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 9f9d0f35d..9f4513f1b 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -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 diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index 774b22a3f..ad36c0534 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -43,7 +43,7 @@ - + <%= 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) == "" %> diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index 5584172d4..c3a1b9d78 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -55,11 +55,7 @@
<%= 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 %>
diff --git a/app/views/projects/_member_list.html.erb b/app/views/projects/_member_list.html.erb index 120c49963..ed2f6c11e 100644 --- a/app/views/projects/_member_list.html.erb +++ b/app/views/projects/_member_list.html.erb @@ -17,7 +17,7 @@ <%= content_tag "div", content_tag("p", member.roles.sort.collect(&:to_s).join(', ')), :class => "clear avatar_name" %>

- <%= l(:label_user_for_project_grade) %>: <%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %> + <%= l(:label_user_for_project_grade) %>: <%= UserGrade.find_by_user_id_and_project_id(member[:user_id], @project.id).grade %>

<% end %> diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index 474b97859..cd7c76030 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -89,7 +89,7 @@
<% if @project.project_type !=1 %> - <%= content_tag('span', "#{l(:label_project_grade)}: ")%><%=@project.project_status ? @project.project_status.grade : 0.0 %> + <%= content_tag('span', "#{l(:label_project_grade)}: ")%><%=@project.project_status ? @project.project_status.grade : 0.0 %> <% end %>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 0e8b94008..733d1b172 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -66,23 +66,18 @@ <% html_title(l(:label_user_plural)) -%> <% else %> - +
<%= l(:label_user_plural)%> <%= form_tag(:controller => 'users', :action => 'search', :method => :get) do %> - +
@@ -91,19 +86,7 @@ <%= sort_user(@s_type, @project_type)%> - +
@@ -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"%> - +
<%= image_tag(url_to_avatar(user), :class => 'avatar') %> <%= content_tag "span", link_to_user(user), :class => "nomargin avatar_name" %>
- <%= l(:label_user_grade) %>: <%= user.user_status.grade %> + <%= l(:label_user_grade) %>: <%= user.user_status.grade %>
- +
@@ -129,9 +112,7 @@ <%= l(:label_has_watchers,:count=>User.watched_by(user.id).count) %>
- +
<% unless user.memberships.empty? %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 94e83385b..bdd823ccb 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -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: [日, 一, 二, 三, 四, 五, 六]