app接口部分信息国际化
This commit is contained in:
parent
5a1492964a
commit
2a3a70b7d5
|
@ -2,6 +2,7 @@
|
||||||
module Mobile
|
module Mobile
|
||||||
module Apis
|
module Apis
|
||||||
class Comments < Grape::API
|
class Comments < Grape::API
|
||||||
|
include ApplicationHelper
|
||||||
resource :comments do
|
resource :comments do
|
||||||
desc '课程通知评论'
|
desc '课程通知评论'
|
||||||
params do
|
params do
|
||||||
|
@ -82,8 +83,8 @@ module Mobile
|
||||||
memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'},
|
memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'},
|
||||||
}
|
}
|
||||||
cs = CommentService.new
|
cs = CommentService.new
|
||||||
memo = cs.create_feedback cs_params, current_user
|
memo,message = cs.create_feedback cs_params, current_user
|
||||||
raise "commit failed #{memo.errors.full_messages}" if memo.new_record?
|
raise message if memo.new_record?
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ForumsController < ApplicationController
|
||||||
#@memo.author_id = User.current.id
|
#@memo.author_id = User.current.id
|
||||||
#@forum = @memo.forum
|
#@forum = @memo.forum
|
||||||
cs = CommentService.new
|
cs = CommentService.new
|
||||||
@memo = cs.create_feedback params,User.current
|
@memo,message = cs.create_feedback params,User.current
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if !@memo.new_record?
|
if !@memo.new_record?
|
||||||
format.html { redirect_to forum_path(@memo.forum) }
|
format.html { redirect_to forum_path(@memo.forum) }
|
||||||
|
|
|
@ -60,4 +60,8 @@ module ApiHelper
|
||||||
end
|
end
|
||||||
[count,is_teacher]
|
[count,is_teacher]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_user_language user
|
||||||
|
(user.language.nil? || user.language == "") ? 'zh':user.language
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
class CommentService
|
class CommentService
|
||||||
|
include ApiHelper
|
||||||
|
include Redmine::I18n
|
||||||
#评论
|
#评论
|
||||||
def news_comments params,current_user
|
def news_comments params,current_user
|
||||||
@news = News.find(params[:id])
|
@news = News.find(params[:id])
|
||||||
|
@ -84,7 +86,8 @@ class CommentService
|
||||||
@memo.forum_id = "1"
|
@memo.forum_id = "1"
|
||||||
@memo.author_id = current_user.id
|
@memo.author_id = current_user.id
|
||||||
@memo.save
|
@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
|
end
|
||||||
|
|
||||||
#课程留言列表
|
#课程留言列表
|
||||||
|
|
|
@ -346,7 +346,7 @@ class CoursesService
|
||||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
|
membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
|
||||||
end
|
end
|
||||||
if membership.nil? || membership.count == 0
|
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
|
end
|
||||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||||
result = []
|
result = []
|
||||||
|
@ -355,19 +355,19 @@ class CoursesService
|
||||||
latest_course_dynamics = []
|
latest_course_dynamics = []
|
||||||
latest_news = course.news.order("created_on desc").first
|
latest_news = course.news.order("created_on desc").first
|
||||||
unless latest_news.nil?
|
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
|
end
|
||||||
latest_message = course.journals_for_messages.order("created_on desc").first
|
latest_message = course.journals_for_messages.order("created_on desc").first
|
||||||
unless latest_message.nil?
|
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
|
end
|
||||||
latest_attachment = course.attachments.order("created_on desc").first
|
latest_attachment = course.attachments.order("created_on desc").first
|
||||||
unless latest_attachment.nil?
|
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
|
end
|
||||||
latest_bid = course.homeworks.order('updated_on DESC').first
|
latest_bid = course.homeworks.order('updated_on DESC').first
|
||||||
unless latest_bid.nil?
|
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
|
end
|
||||||
#每个作业中的最新留言
|
#每个作业中的最新留言
|
||||||
messages = []
|
messages = []
|
||||||
|
@ -382,7 +382,7 @@ class CoursesService
|
||||||
end
|
end
|
||||||
latest_bid_message = messages.first
|
latest_bid_message = messages.first
|
||||||
unless latest_bid_message.nil?
|
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
|
end
|
||||||
#每个作业中学生最后提交的作业
|
#每个作业中学生最后提交的作业
|
||||||
homeworks = []
|
homeworks = []
|
||||||
|
@ -397,7 +397,7 @@ class CoursesService
|
||||||
end
|
end
|
||||||
latest_homework_attach = homeworks.first
|
latest_homework_attach = homeworks.first
|
||||||
unless latest_homework_attach.nil?
|
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
|
end
|
||||||
latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]}
|
latest_course_dynamics.sort!{|order,newer| newer[:time] <=> order[:time]}
|
||||||
latest_course_dynamic = latest_course_dynamics.first
|
latest_course_dynamic = latest_course_dynamics.first
|
||||||
|
|
|
@ -1588,3 +1588,5 @@ en:
|
||||||
label_recently_updated_message: Recently updated the message
|
label_recently_updated_message: Recently updated the message
|
||||||
label_recently_updated_courseware: Recently updated the courseware
|
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_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
|
|
@ -2032,6 +2032,9 @@ zh:
|
||||||
label_recently_updated_message: 最近更新了留言
|
label_recently_updated_message: 最近更新了留言
|
||||||
label_recently_updated_courseware: 最近更新了课件
|
label_recently_updated_courseware: 最近更新了课件
|
||||||
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
|
label_no_courses: 您没有参与任何课程,请搜索课程、加入课程,或者创建课程吧!
|
||||||
|
label_commit_failed: 提交失败
|
||||||
|
#api end
|
||||||
|
|
||||||
label_end_time: 截止时间
|
label_end_time: 截止时间
|
||||||
label_send_email: 确定发送
|
label_send_email: 确定发送
|
||||||
label_input_email: 请输入邮箱地址
|
label_input_email: 请输入邮箱地址
|
||||||
|
|
Loading…
Reference in New Issue