This commit is contained in:
dingxu 2015-03-19 16:25:38 +08:00
commit 79588489e2
8 changed files with 28 additions and 14 deletions

View File

@ -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

View File

@ -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) }

View File

@ -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

View File

@ -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
#课程留言列表

View File

@ -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

View File

@ -126,7 +126,8 @@
<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :style => "color:#3CA5C6;font-weight:bold" %></span>
<span>| </span>
<%= l(:project_module_attachments) %><span class="info_foot_num" >
<%= link_to "#{@project.attachments.count}", project_files_path(@project), :style => "color:#3CA5C6;font-weight:bold" %></span>
<% 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" %></span>
</div>
<div class="cl"></div>
</div><!--项目信息 end-->
@ -170,8 +171,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<div class="subNav">
<%= link_to l(:label_course_file), project_files_path(@project), :style => "color:#3CA5C6" %>
<% unless @project.attachments.count == 0 %>
<span class="subnav_num">(<%= @project.attachments.count %>)</span>
<% unless attaments_num == 0 %>
<span class="subnav_num">(<%= attaments_num %>)</span>
<% 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;" %>

View File

@ -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

View File

@ -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: 请输入邮箱地址