From c209bccba071660df05770fae36253d63e6a1fcd Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Thu, 19 Mar 2015 11:15:58 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E6=95=B0=E6=98=BE=E7=A4=BA=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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index bb145f1e4..4572b703b 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -126,7 +126,7 @@
<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :style => "color:#3CA5C6;font-weight:bold" %>)
|
<%= l(:project_module_attachments) %>()
+ <%= link_to "#{@project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count}", project_files_path(@project), :style => "color:#3CA5C6;font-weight:bold" %>)
From 0424fc55db47992311424d7ba7f09dd60bfbfdd5 Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Thu, 19 Mar 2015 11:26:31 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E6=95=B0=E6=98=BE=E7=A4=BA=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 | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 4572b703b..ef9bb56f0 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -126,7 +126,8 @@
<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :style => "color:#3CA5C6;font-weight:bold" %>)
|
<%= l(:project_module_attachments) %>()
+ <% attaments_num = @project.attachments.count+Attachment.where(["`container_type` = 'Version' and `container_id` in (?)",@project.versions.map{ |v| v.id}]).all.count %>
+ <%= link_to "#{attaments_num}", project_files_path(@project), :style => "color:#3CA5C6;font-weight:bold" %>)
@@ -170,8 +171,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<%= link_to l(:label_course_file), project_files_path(@project), :style => "color:#3CA5C6" %>
- <% unless @project.attachments.count == 0 %>
- (<%= @project.attachments.count %>)
+ <% unless attaments_num == 0 %>
+ (<%= attaments_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_files), project_files_path(@project,:flag => true),:style => "font-size:12px;color:#fff; padding:1px 3px 3px 3px;height:16px;margin-top:4px;background:#28be6c;float:right;line-height:20px;" %>
From 2a3a70b7d5359bef0709a2a2effa11c294f7866e Mon Sep 17 00:00:00 2001
From: z9hang
Date: Thu, 19 Mar 2015 14:41:31 +0800
Subject: [PATCH 3/3] =?UTF-8?q?app=E6=8E=A5=E5=8F=A3=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=9B=BD=E9=99=85=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/api/mobile/apis/comments.rb | 5 +++--
app/controllers/forums_controller.rb | 2 +-
app/helpers/api_helper.rb | 4 ++++
app/services/comment_service.rb | 5 ++++-
app/services/courses_service.rb | 14 +++++++-------
config/locales/en.yml | 2 ++
config/locales/zh.yml | 3 +++
7 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb
index 75932d60f..2e84fe5a9 100644
--- a/app/api/mobile/apis/comments.rb
+++ b/app/api/mobile/apis/comments.rb
@@ -2,6 +2,7 @@
module Mobile
module Apis
class Comments < Grape::API
+ include ApplicationHelper
resource :comments do
desc '课程通知评论'
params do
@@ -82,8 +83,8 @@ module Mobile
memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'},
}
cs = CommentService.new
- memo = cs.create_feedback cs_params, current_user
- raise "commit failed #{memo.errors.full_messages}" if memo.new_record?
+ memo,message = cs.create_feedback cs_params, current_user
+ raise message if memo.new_record?
present :status, 0
end
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 2f7092d9a..64157ea42 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -20,7 +20,7 @@ class ForumsController < ApplicationController
#@memo.author_id = User.current.id
#@forum = @memo.forum
cs = CommentService.new
- @memo = cs.create_feedback params,User.current
+ @memo,message = cs.create_feedback params,User.current
respond_to do |format|
if !@memo.new_record?
format.html { redirect_to forum_path(@memo.forum) }
diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb
index c865a500b..afdc306a4 100644
--- a/app/helpers/api_helper.rb
+++ b/app/helpers/api_helper.rb
@@ -60,4 +60,8 @@ module ApiHelper
end
[count,is_teacher]
end
+
+ def get_user_language user
+ (user.language.nil? || user.language == "") ? 'zh':user.language
+ end
end
\ No newline at end of file
diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb
index e74cc902b..f75e14b85 100644
--- a/app/services/comment_service.rb
+++ b/app/services/comment_service.rb
@@ -1,4 +1,6 @@
class CommentService
+ include ApiHelper
+ include Redmine::I18n
#评论
def news_comments params,current_user
@news = News.find(params[:id])
@@ -84,7 +86,8 @@ class CommentService
@memo.forum_id = "1"
@memo.author_id = current_user.id
@memo.save
- @memo
+ message = "#{l(:label_commit_failed,:locale => get_user_language(current_user))}: #{@memo.errors.full_messages}" if @memo.new_record?
+ [@memo,message]
end
#课程留言列表
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 4512344ad..c689d699d 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -346,7 +346,7 @@ class CoursesService
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)
+ raise l(:label_no_courses,:locale => get_user_language(current_user))
end
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
result = []
@@ -355,19 +355,19 @@ class CoursesService
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 => get_user_language(current_user))}
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 => get_user_language(current_user))}
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 => get_user_language(current_user))}
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 => get_user_language(current_user))}
end
#每个作业中的最新留言
messages = []
@@ -382,7 +382,7 @@ class CoursesService
end
latest_bid_message = messages.first
unless latest_bid_message.nil?
- latest_course_dynamics << {:type => 4,: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 => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))}
end
#每个作业中学生最后提交的作业
homeworks = []
@@ -397,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 => get_user_language(current_user))}
end
latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]}
latest_course_dynamic = latest_course_dynamics.first
diff --git a/config/locales/en.yml b/config/locales/en.yml
index e84a26815..33e4da965 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1588,3 +1588,5 @@ en:
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!
+ label_commit_failed: commit failed
+ #api end
\ No newline at end of file
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index dc1937926..5628598cc 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -2032,6 +2032,9 @@ zh:
label_recently_updated_message: 最近更新了留言
label_recently_updated_courseware: 最近更新了课件
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
+ label_commit_failed: 提交失败
+ #api end
+
label_end_time: 截止时间
label_send_email: 确定发送
label_input_email: 请输入邮箱地址