From 659a87ef606736927c9c02acc345ae0e46f89384 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 9 Mar 2015 09:11:57 +0800 Subject: [PATCH 01/68] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8C=96=E6=A0=87=E7=AD=BE=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_my_joinedcourse.html.erb | 4 ++-- config/locales/en.yml | 2 ++ config/locales/zh.yml | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/users/_my_joinedcourse.html.erb b/app/views/users/_my_joinedcourse.html.erb index 373ed9234..e616004e6 100644 --- a/app/views/users/_my_joinedcourse.html.erb +++ b/app/views/users/_my_joinedcourse.html.erb @@ -16,8 +16,8 @@ diff --git a/config/locales/en.yml b/config/locales/en.yml index 857259392..bebfb5605 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1876,3 +1876,5 @@ en: label_submit_comments: Submit_comments label_course_empty_select: You have not selected course! label_enterprise_page_made: enterprise_page + + label_add_tag: Add Tag diff --git a/config/locales/zh.yml b/config/locales/zh.yml index c6e303b00..8bcb8284b 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2580,3 +2580,5 @@ zh: label_part_enterprise_tips: 您可能对系统的其它项目感兴趣! label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目! label_enterprises: 组织 + + label_add_tag: 添加标签 From 8c44d2575070b7eba6c1e289c46652bc5cd47d99 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 9 Mar 2015 10:27:32 +0800 Subject: [PATCH 02/68] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=90=9C=E7=B4=A2=E4=B8=AD=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/tags/_show_attachments.html.erb | 33 +++++++++++++++++------ config/locales/zh.yml | 7 +++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app/views/tags/_show_attachments.html.erb b/app/views/tags/_show_attachments.html.erb index 509acc0ba..a76211fc6 100644 --- a/app/views/tags/_show_attachments.html.erb +++ b/app/views/tags/_show_attachments.html.erb @@ -9,18 +9,35 @@
- <%= l(:label_attachment) %>:  <%= file.filename %> + + <%= l(:label_attachment) %>: +    + <%= file.filename %> + - <%= link_to_attachment file, {:download => true, :text => image_tag("/images/button/dl.png", width: "70px", alt: l(:button_download), :class => 'download_icon')}%> + <%= link_to_attachment file, {:download => true, :text => image_tag("/images/button/dl.png", width: "70px", alt: l(:button_download), :class => 'download_icon')}%>
- <%= l(:field_description) %>:  <%= file.description %> -
<%= l('attachment.category')%><%=result_come_from file%>
+ + <%= l(:field_description) %> + : +    + <%= file.description %> +
+ <%= l('label_attachment_category')%> + <%=result_come_from file%> +
- <%= l('attachment.download_num')%><%= file.downloads%>| - <%= l('attachment.size')%><%= number_to_human_size(file.filesize) %>| - <%= l('attachment.sharer')%><%= link_to file.author, user_path(file.author), target: "_blank" unless file.author.blank? %>| - <%= l('attachment.upload_time')%><%= format_time(file.created_on) %> + <%= l('label_attachment_download_num')%> + <%= file.downloads%>| + <%= l('label_attachment_size')%> + <%= number_to_human_size(file.filesize) %>| + <%= l('label_attachment_sharer')%> + + <%= link_to file.author, user_path(file.author), target: "_blank" unless file.author.blank? %> + | + <%= l('label_attachment_upload_time')%> + <%= format_time(file.created_on) %>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 8bcb8284b..2b4e41755 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2582,3 +2582,10 @@ zh: label_enterprises: 组织 label_add_tag: 添加标签 + label_tags_opensource: 开源项目 + label_attachment_category: 所属分类 + label_attachment_download_num: 下载 + label_attachment_size: 大小 + label_attachment_sharer: 共享者 + label_attachment_upload_time: 上传时间 + From d96b87cf42701f5bd2961b34c35c8f1d588f3b7c Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Mar 2015 15:23:24 +0800 Subject: [PATCH 03/68] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course_dynamic.rb | 10 ++- app/services/courses_service.rb | 83 +++++++++++++++++++---- config/locales/en.yml | 7 ++ config/locales/zh.yml | 7 ++ 4 files changed, 92 insertions(+), 15 deletions(-) diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb index 5e22e3df7..aa8aadbb6 100644 --- a/app/api/mobile/entities/course_dynamic.rb +++ b/app/api/mobile/entities/course_dynamic.rb @@ -1,9 +1,15 @@ module Mobile module Entities class CourseDynamic < Grape::Entity + include Redmine::I18n def self.course_dynamic_expose(field) expose field do |c,opt| - c[field] if (c.is_a?(Hash) && c.key?(field)) + if field == :update_time + (format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) + else + c[field] if (c.is_a?(Hash) && c.key?(field)) + end + end end course_dynamic_expose :type @@ -11,6 +17,8 @@ module Mobile course_dynamic_expose :course_name course_dynamic_expose :course_id course_dynamic_expose :course_img_url + course_dynamic_expose :message + course_dynamic_expose :update_time end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 46b59ef08..17c96a2fb 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -344,25 +344,80 @@ class CoursesService else membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user)) end + if membership.nil? || membership.count == 0 + raise l(:label_no_courses,:locale => current_user.language.nil? ? 'zh':current_user.language) + end membership.sort! {|older, newer| newer.created_on <=> older.created_on } result = [] membership.each do |mp| course = mp.course - unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course))) - count,is_teacher = get_course_anonymous_evaluation current_user,course - if is_teacher - student_commit_number = count - else - need_anonymous_comments_count = count + #unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course))) + # count,is_teacher = get_course_anonymous_evaluation current_user,course + # if is_teacher + # student_commit_number = count + # else + # need_anonymous_comments_count = count + # end + # news_count = course.news.count + # message_count = course.journals_for_messages.count + # + # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count} + # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count} + # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number} + # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count} + # #{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count} + #end + latest_course_dynamics = [] + latest_news = course.news.order("created_on desc").first + unless latest_news.nil? + latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + latest_message = course.journals_for_messages.order("created_on desc").first + unless latest_message.nil? + latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + latest_attachment = course.attachments.order("created_on desc").first + unless latest_attachment.nil? + latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + latest_bid = course.homeworks.order('updated_on DESC').first + unless latest_bid.nil? + latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + #每个作业中的最新留言 + messages = [] + course.homeworks.each do |bid| + jour = bid.journals_for_messages.order("created_on desc").first + unless jour.nil? + messages << jour end - news_count = course.news.count - message_count = course.journals_for_messages.count - - result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count} - result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count} - result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number} - result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count} - #{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count} + end + unless messages.count == 0 + messages.sort!{|order,newer| newer.created_on <=> order.created_on} + end + latest_bid_message = messages.first + unless latest_bid_message.nil? + latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + #每个作业中学生最后提交的作业 + homeworks = [] + course.homeworks.each do |bid| + homework_attach = bid.homeworks.order('updated_at DESC').first + unless homework_attach.nil? + homeworks << homework_attach + end + end + unless homeworks.count == 0 + homeworks.sort!{|order,newer| newer.updated_at <=> order.updated_at} + end + latest_homework_attach = homeworks.first + unless latest_homework_attach.nil? + latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} + end + latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]} + latest_course_dynamic = latest_course_dynamics.first + unless latest_course_dynamic.nil? + result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => latest_course_dynamic[:type],:update_time => latest_course_dynamic[:time],:message => latest_course_dynamic[:message],:count => nil} end end result diff --git a/config/locales/en.yml b/config/locales/en.yml index 857259392..8149850cb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1876,3 +1876,10 @@ en: label_submit_comments: Submit_comments label_course_empty_select: You have not selected course! label_enterprise_page_made: enterprise_page + + #api + label_recently_updated_notification: Recently updated notification + label_recently_updated_homework: Recently updated the homework + label_recently_updated_message: Recently updated the message + label_recently_updated_courseware: Recently updated the courseware + label_no_courses: You do not participate in any course, please search the curriculum, course, or create a course! diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 1faa9227d..9310c0f04 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2569,3 +2569,10 @@ zh: label_part_enterprise_tips: 您可能对系统的其它项目感兴趣! label_enterprise_nil: 该模块为最新上线模块,目前还没有创建企业项目! label_enterprises: 组织 + + #api + label_recently_updated_notification: 最近更新了通知 + label_recently_updated_homework: 最近更新了作业 + label_recently_updated_message: 最近更新了留言 + label_recently_updated_courseware: 最近更新了课件 + label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧! From 83cc1b41f35307f57f280138b63b859e0282ac3f Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Mar 2015 15:27:01 +0800 Subject: [PATCH 04/68] =?UTF-8?q?=E4=BF=AE=E6=AD=A3api=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 4808c84c0..8f7f0342f 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -41,7 +41,7 @@ module Mobile mount Apis::Comments #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end From 81b58e5c871ffaf76509aee013d7a4e62ea8ffc5 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 9 Mar 2015 15:32:55 +0800 Subject: [PATCH 05/68] =?UTF-8?q?=E4=BF=AE=E6=94=B9base=5Fproject=E4=B8=AD?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_projects.html.erb | 8 ++++---- config/locales/zh.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 8bf84d90c..ee38a89c3 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -39,8 +39,7 @@ var name = $.trim($("#name").val()); if(name.length == 0) { - $("#project_name_span").text("<%= l(:label_search_conditions_not_null) %> - "); + $("#project_name_span").text("<%= l(:label_search_conditions_not_null) %>"); $("#project_name_span").css('color','#ff0000'); $("#project_name_span").focus(); return false; @@ -103,9 +102,10 @@
-
diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 2b4e41755..263fa7439 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -696,8 +696,8 @@ zh: label_limit_time: 截止日期 label_commit_homework: 提交作业 label_course_homework: 对应课程 - label_course_doing: 进行中的课程 - label_course_done: 已结束的课程 + label_course_doing: 进行中 + label_course_done: 已结束 label_homework_response: 作业咨询 label_bidding_homework: 提交作业 label_add_homework: 添加作业 From 26adc13ca24cd7d1c690768c0f5ae17e472a92b9 Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Mar 2015 15:45:09 +0800 Subject: [PATCH 06/68] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 17c96a2fb..dd49b6bd8 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -1,3 +1,4 @@ +#coding=utf-8 class CoursesService include ApplicationHelper include CoursesHelper @@ -351,38 +352,22 @@ class CoursesService result = [] membership.each do |mp| course = mp.course - #unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course))) - # count,is_teacher = get_course_anonymous_evaluation current_user,course - # if is_teacher - # student_commit_number = count - # else - # need_anonymous_comments_count = count - # end - # news_count = course.news.count - # message_count = course.journals_for_messages.count - # - # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count} - # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count} - # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number} - # result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count} - # #{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count} - #end latest_course_dynamics = [] latest_news = course.news.order("created_on desc").first unless latest_news.nil? - latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 1,:time => latest_news.created_on,:message => '最近更新了通知' }#l(:label_recently_updated_notification,:locale => current_user.language.nil? ? 'zh':current_user.language)} end latest_message = course.journals_for_messages.order("created_on desc").first unless latest_message.nil? - latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 2,:time => latest_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} end latest_attachment = course.attachments.order("created_on desc").first unless latest_attachment.nil? - latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message => '最近更新了课件'}#l(:label_recently_updated_courseware,:locale => current_user.language.nil? ? 'zh':current_user.language)} end latest_bid = course.homeworks.order('updated_on DESC').first unless latest_bid.nil? - latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 4,:time => latest_bid.updated_on,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} end #每个作业中的最新留言 messages = [] @@ -397,7 +382,7 @@ class CoursesService end latest_bid_message = messages.first unless latest_bid_message.nil? - latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 2,:time => latest_bid_message.created_on,:message => '最近更新了留言'}#l(:label_recently_updated_message,:locale => current_user.language.nil? ? 'zh':current_user.language)} end #每个作业中学生最后提交的作业 homeworks = [] @@ -412,7 +397,7 @@ class CoursesService end latest_homework_attach = homeworks.first unless latest_homework_attach.nil? - latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} + latest_course_dynamics << {:type => 4,:time => latest_homework_attach.updated_at,:message => '最近更新了作业'}#l(:label_recently_updated_homework,:locale => current_user.language.nil? ? 'zh':current_user.language)} end latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]} latest_course_dynamic = latest_course_dynamics.first From 6ca853edc79ec10e888b2151f084894acdc2baeb Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Mar 2015 17:28:17 +0800 Subject: [PATCH 07/68] =?UTF-8?q?1=E3=80=81=E8=AF=BE=E7=A8=8B=E9=A6=96?= =?UTF-8?q?=E9=A1=B52=E3=80=81=E7=94=A8=E6=88=B7=E9=A6=96=E9=A1=B53?= =?UTF-8?q?=E3=80=81=E8=AF=BE=E7=A8=8B=E7=95=99=E8=A8=80=E9=A1=B54?= =?UTF-8?q?=E3=80=81=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A=E9=A1=B55?= =?UTF-8?q?=E3=80=81=E7=94=A8=E6=88=B7=E7=9A=84=E7=95=99=E8=A8=80=E9=A1=B5?= =?UTF-8?q?6=E3=80=81=E4=B8=BA=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BD=9C=E5=93=81=E9=A1=B5=E4=BC=A0=E9=80=92?= =?UTF-8?q?apptoken=E5=8F=82=E6=95=B0=E6=97=B6=E8=87=AA=E5=8A=A8=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 16 ++++++++++++++++ app/controllers/courses_controller.rb | 1 + app/controllers/homework_attach_controller.rb | 2 +- app/controllers/users_controller.rb | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 06e5dac30..1c26ec07e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -177,6 +177,22 @@ class ApplicationController < ActionController::Base end end + def logged_user_by_apptoken + #从手机端传来apptoken则将当前登陆用户变为对应的用户 + if params[:apptoken] + token = ApiKey.where(access_token: params[:apptoken]).first + if token && !token.expired? + @current_user = User.find(token.user_id) + end + unless @current_user.nil? + self.logged_user = @current_user + if @current_user + @current_user.update_column(:last_login_on, Time.now) + end + end + end + end + # Logs out current user def logout_user if User.current.logged? diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8fae547c4..9b66c047f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -17,6 +17,7 @@ class CoursesController < ApplicationController menu_item l(:label_sort_by_influence), :only => :index before_filter :can_show_course, :except => [] + before_filter :logged_user_by_apptoken,:only => [:show,:new_homework,:feedback] before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_private_courses] before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create] diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2c943e778..ba7e92467 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -6,7 +6,7 @@ class HomeworkAttachController < ApplicationController ############################### before_filter :can_show_course,except: [] #判断当前角色权限时需先找到当前操作的project - before_filter :find_course_by_bid_id, :only => [:new] + before_filter :logged_user_by_apptoken,:find_course_by_bid_id, :only => [:new] before_filter :find_bid_and_course,:only => [:get_not_batch_homework,:get_batch_homeworks,:get_homeworks,:get_homework_jours, :get_student_batch_homework, :get_my_homework] before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users, :praise_homework] #判断当前角色是否有操作权限 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 48c08e2fc..e6171bf81 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -19,6 +19,7 @@ class UsersController < ApplicationController layout :setting_layout #Added by young before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback] + before_filter :logged_user_by_apptoken, :only => [:show,:user_newfeedback] menu_item :activity menu_item :user_information, :only => :info menu_item :user_course, :only => :user_courses From 052afefa5eed3ee86d4a1300b7402cfd50db0c0e Mon Sep 17 00:00:00 2001 From: z9hang Date: Mon, 9 Mar 2015 17:32:38 +0800 Subject: [PATCH 08/68] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=8C=89=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=80=92=E5=BA=8F=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index dd49b6bd8..c0d3d2f83 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -405,6 +405,7 @@ class CoursesService result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => latest_course_dynamic[:type],:update_time => latest_course_dynamic[:time],:message => latest_course_dynamic[:message],:count => nil} end end + result.sort!{|order,newer| newer[:update_time] <=> order[:update_time]} result end From 115eb38a02fd02160e2b217d8cfbbbd4ee38ce02 Mon Sep 17 00:00:00 2001 From: whimlex Date: Tue, 10 Mar 2015 09:45:36 +0800 Subject: [PATCH 09/68] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B5=84=E6=96=99=E6=A8=A1=E5=9D=97=EF=BC=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E8=AF=BE=E7=A8=8B=E6=A0=8F=E3=80=81=E7=95=99?= =?UTF-8?q?=E8=A8=80=E6=A0=8F=E3=80=81=E9=A1=B9=E7=9B=AE=E6=A0=8F=E5=92=8C?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=A8=A1=E5=9D=97=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=EF=BC=9B=E5=AF=B9=E4=B8=80=E4=BA=9B=E5=AD=98=E5=82=A8=E5=9C=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A1=A8=E4=B8=AD=E7=9A=84=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E7=9A=84=E4=B8=AD=E6=96=87=E5=B1=9E=E6=80=A7=EF=BC=8C=E6=AF=94?= =?UTF-8?q?=E5=A6=82=E5=AD=A6=E6=9C=9F=EF=BC=8C=E8=81=8C=E7=A7=B0=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8helper=E5=92=8Cmodel=E4=B8=AD=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=B0=81=E8=A3=85=EF=BC=9B=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A8=A1=E5=9D=97=EF=BC=8C=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E5=90=84=E6=A8=A1=E5=9D=97=E5=86=85=E9=83=A8=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E7=9A=84=E5=9B=BD=E9=99=85=E5=8C=96=EF=BC=9B=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E6=A8=A1=E5=9D=97=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E6=95=B4=E7=90=86=E5=92=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E9=87=8D=E5=A4=8D=E5=8A=9F=E8=83=BD=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 24 +- app/helpers/welcome_helper.rb | 2 +- app/models/user_extensions.rb | 26 +- app/views/courses/index.html.erb | 2 +- app/views/courses/search.html.erb | 2 +- app/views/files/_attachement_list.html.erb | 2 +- app/views/forums/create_feedback.js.erb | 2 +- .../homework_attach/_add_jour_reply.html.erb | 4 +- app/views/homework_attach/_jour.html.erb | 2 +- .../_journal_reply_items.html.erb | 4 +- app/views/homework_attach/_review.html.erb | 2 +- app/views/homework_attach/_showjour.html.erb | 2 +- .../layouts/_base_homework_attach.html.erb | 2 +- app/views/layouts/base_courses.html.erb | 6 +- app/views/layouts/base_forums.html.erb | 2 +- app/views/layouts/base_homework.html.erb | 2 +- app/views/layouts/base_memos.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/memos/new.html.erb | 4 +- app/views/my/account.html.erb | 4 +- app/views/projects/Copy of show.html.erb | 4 +- app/views/projects/_new_respond.html.erb | 4 +- app/views/stores/_search_bar.html.erb | 4 +- .../users/_activity_new_score_index.html.erb | 16 +- app/views/users/_course_form.html.erb | 2 +- .../users/_course_list_have_entity.html.erb | 4 +- .../_course_list_have_entity_ex.html.erb | 4 +- .../users/_influence_new_score_index.html.erb | 12 +- .../users/_project_new_score_index.html.erb | 4 +- .../users/_topic_new_score_index.html.erb | 12 +- app/views/users/show.html.erb | 51 ++- app/views/users/user_projects.html.erb | 2 +- app/views/welcome/_search_bar.html.erb | 4 +- app/views/welcome/contest.html.erb | 19 +- app/views/welcome/course.html.erb | 16 +- app/views/words/_feedback.html.erb | 2 +- app/views/words/_journal_reply_items.html.erb | 4 +- app/views/words/_message.html.erb | 2 +- app/views/words/_new_respond.html.erb | 4 +- config/locales/commons/en.yml | 103 +++++- config/locales/commons/zh.yml | 114 +++++- config/locales/contacts/en.yml | 15 + config/locales/courses/en.yml | 58 +++ config/locales/courses/zh.yml | 56 +++ config/locales/en.yml | 344 +++--------------- config/locales/forums/en.yml | 3 + config/locales/forums/zh.yml | 6 + config/locales/mailers/en.yml | 15 + config/locales/my/en.yml | 33 +- config/locales/my/zh.yml | 10 +- config/locales/navigatiors/en.yml | 77 ++++ config/locales/navigatiors/zh.yml | 11 +- config/locales/projects/en.yml | 56 +++ config/locales/projects/zh.yml | 46 ++- config/locales/users/en.yml | 202 +++++++++- config/locales/users/zh.yml | 198 +++++++--- config/locales/zh.yml | 245 +++++-------- 57 files changed, 1243 insertions(+), 617 deletions(-) create mode 100644 config/locales/forums/en.yml create mode 100644 config/locales/forums/zh.yml diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 22eb9bfae..db547061f 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -351,10 +351,28 @@ module CoursesHelper str end - # added by nwb + # added by meng + # 课程time+term简写(2014.春/2014.秋)国际化输出 def get_course_term course - str = ( course.try(:time).to_s << '.' << course.try(:term).to_s ) - str[0..-4] + strterm = course.try(:term).to_s + if !(User.current.language == 'zh') + strterm == '春季学期' ? strterm = 'spring term' : strterm = 'autumn term' + str = ( course.try(:time).to_s << '.' << strterm ) + str[0..-6] + else + str = ( course.try(:time).to_s << '.' << strterm ) + str[0..-4] + end + end + + # added by meng + # 课程term(春季学期/秋季学期)国际化输出 + def get_course_term_locales course + str = course.try(:term).to_s + if !(User.current.language == 'zh') + str == '春季学期' ? str = ' ' + 'spring term' : str = ' ' + 'autumn term' + end + return str end def members_to_user_ids members diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index eba3c0b3c..f6e205e82 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -341,7 +341,7 @@ module WelcomeHelper end str rescue Exception => e - str << content_tag("span", l(:field_user_active_unknow)) + str << content_tag("span", l('user.active.unknow')) end def show_event_reply event diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index b21f0ad36..92690d1db 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -33,16 +33,32 @@ class UserExtensions < ActiveRecord::Base return self.brief_introduction end -# added by bai +# added by meng def show_identity if self.identity == 0 - user_identity = '教师' + if User.current.language == 'zh' + user_identity = '教师' + else + user_identity = 'Teacher' + end elsif self.identity == 1 - user_identity = '学生' + if User.current.language == 'zh' + user_identity = '学生' + else + user_identity = 'Student' + end elsif self.identity == 2 - user_identity = '企业' + if User.current.language == 'zh' + user_identity = '企业' + else + user_identity = 'Enterprise' + end elsif self.identity == 3 - user_identity = '开发者' + if User.current.language == 'zh' + user_identity = '开发者' + else + user_identity = 'Developer' + end else user_identity = '' end diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index e7a4a29db..e8a917a2b 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -12,7 +12,7 @@ - 高校课程实践社区 + <%= l(:label_courses_community)%> diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb index 661feb3c9..98b056487 100644 --- a/app/views/courses/search.html.erb +++ b/app/views/courses/search.html.erb @@ -7,7 +7,7 @@ - 高校课程实践社区 + <%= l(:label_courses_community)%> diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index 85739f7c3..001519a28 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -37,7 +37,7 @@ :description_placeholder => l(:label_optional_description) } %> -