Merge branch 'develop' into rep_quality

dev_shcool
huang 9 years ago
commit 190ef75200

@ -51,7 +51,7 @@ gem 'elasticsearch-rails'
### profile
# gem 'oneapm_rpm'
gem 'oneapm_rpm'
group :development do
gem 'grape-swagger'

@ -6,10 +6,17 @@ module Mobile
resources :blog_comments do
desc "get special topic"
get ':id' do
post ':id' do
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
blog = BlogComment.find params[:id]
present :data, blog, with: Mobile::Entities::BlogComment,user: user
present :data, blog, with: Mobile::Entities::BlogComment,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -200,8 +200,13 @@ module Mobile
# course = Course.find(params[:id])
cs = CoursesService.new
course = cs.show_course(params,current_user)
present :data, course, with: Mobile::Entities::Course,user: current_user
{ status: 0}
if course[:course][:is_delete] == 1
{status:-1, message: '该班级不存在或已被删除啦' }
else
present :data, course, with: Mobile::Entities::Course,user: current_user
present :status, 0
end
end
end
@ -212,7 +217,7 @@ module Mobile
get "homeworks/:id" do
cs = CoursesService.new
homeworks = cs.homework_list params,current_user
present :data, homeworks, with: Mobile::Entities::Homework
present :data, homeworks, with: Mobile::Entities::Homework,user: current_user
present :status, 0
end
@ -259,7 +264,7 @@ module Mobile
post ":course_id/attachments" do
cs = CoursesService.new
count = cs.course_attachments params
present :data, count, with: Mobile::Entities::Attachment
present :data, count, with: Mobile::Entities::Attachment,user: current_user
present :status, 0
end
@ -392,8 +397,8 @@ module Mobile
authenticate!
course = Course.find(params[:course_id])
exercises = course.exercises.where("exercise_status <> 1").order("created_at desc")
present :data,exercises,with:Mobile::Entities::Exercise
exercises = course.exercises.where("exercise_status <> 1").reorder("created_at desc")
present :data,exercises,with:Mobile::Entities::Exercise,user: current_user
present :status,0
end

@ -7,11 +7,17 @@ module Mobile
include IssuesHelper
desc "get special issuse"
get ':id' do
post ':id' do
authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
issue = Issue.find params[:id]
present :data, issue, with: Mobile::Entities::Issue,user: user
present :data, issue, with: Mobile::Entities::Issue,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -6,11 +6,18 @@ module Mobile
resources :journal_for_messages do
desc "get special journal"
get ':id' do
post ':id' do
authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours,user: user
present :data, jour, with: Mobile::Entities::Jours,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -6,11 +6,17 @@ module Mobile
resources :messages do
desc "get special topic"
get ':id' do
post ':id' do
authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
message = Message.find params[:id]
present :data, message, with: Mobile::Entities::Message,user: user
present :data, message, with: Mobile::Entities::Message,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -6,11 +6,17 @@ module Mobile
resources :newss do
desc "get special news"
get ':id' do
post ':id' do
authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
news = News.find params[:id]
present :data, news, with: Mobile::Entities::News,user: user
present :data, news, with: Mobile::Entities::News,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -85,12 +85,26 @@ module Mobile
requires :token, type: String
requires :course_ids, type: Array[Integer]
requires :send_id, type: Integer
requires :send_type, type: Integer
end
post 'send' do
authenticate!
rs = ResourcesService.new
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
ori = nil
flag = false
save_message = nil
case params[:send_type]
when 1
ori, flag, save_message = rs.send_resource_to_course(current_user,params)
when 2
ori, flag, save_message = rs.send_homework_to_course(current_user,params)
when 3
ori, flag, save_message = rs.send_exercise_to_course(current_user,params)
end
if flag
present :status, 0
else

@ -6,11 +6,17 @@ module Mobile
resources :whomeworks do
desc "get one homework"
get ':id' do
post ':id' do
authenticate!
user = current_user
#0一级回复的更多 1 二级回复的更多
type = params[:type] || 0
page = params[:page] || 0
homework = HomeworkCommon.find params[:id]
present :data, homework, with: Mobile::Entities::Whomework,user: user
present :data, homework, with: Mobile::Entities::Whomework,user: user,type: type,page: page
present :type, type
present :page, page
present :status, 0
end
end

@ -25,10 +25,12 @@ module Mobile
elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
all_comments = []
ac.nil? || ac.act.nil? ? 0 : get_all_children(all_comments, ac.act).count
elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end
when :subject
if ac.act_type == "HomeworkCommon"
ac.act.name unless ac.nil? || ac.act.nil?

@ -3,6 +3,7 @@ module Mobile
class Attachment < Grape::Entity
include Redmine::I18n
include ActionView::Helpers::NumberHelper
include ApplicationHelper
def self.attachment_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
@ -22,6 +23,7 @@ module Mobile
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename
f.course.nil? ? "" : f.course.name
end
end
end
@ -36,6 +38,12 @@ module Mobile
attachment_expose :file_dir
attachment_expose :attafile_size
attachment_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end
end
end

@ -25,7 +25,9 @@ module Mobile
when :act_id
u.id
when :comment_count
u.children.count
# u.children.count
all_comments = []
get_all_children(all_comments, u).count
end
end
end
@ -51,7 +53,18 @@ module Mobile
blog_comment_expose :praise_count
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
c.children.reverse
##自己的父回复为空 才有子回复
if !opt[:children]
if c.parent.nil? && opt[:type] == 0
opt[:children] = true
all_comments = []
tStart = opt[:page]*5
tEnd = (opt[:page]+1)*5 - 1
all_comments = get_all_children(all_comments, c)[tStart..tEnd]
all_comments
end
end
end
end
expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options|
@ -61,6 +74,63 @@ module Mobile
has_praise = obj.empty? ? false : true
has_praise
end
expose :parents_count, if: lambda { |instance, options| options[:user] } do |instance, options|
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, instance)
parents_reply.count
end
expose :parents_reply_bottom, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的底楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:bottom]
if opt[:type] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt[:bottom] = true
parents_reply[0..0]
end
else
[]
end
end
end
expose :parents_reply_top, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment)
#取二级回复的顶楼层
parents_reply = []
parents_reply = get_reply_parents_no_root(parents_reply, c)
if parents_reply.count > 0 && !opt[:top]
if opt[:type] == 1
opt[:bottom] = true
tStart = (opt[:page]-1)*5+2
tEnd = (opt[:page])*5+2 - 1
if tEnd >= parents_reply.count - 1
tEnd = parents_reply.count - 2
end
if tStart <= parents_reply.count - 2
parents_reply = parents_reply.reverse[tStart..tEnd]
parents_reply.reverse
else
[]
end
else
opt[:top] = true
parents_reply = parents_reply.reverse[0..1]
parents_reply.reverse
end
else
[]
end
end
end
end
end
end

@ -27,6 +27,14 @@ module Mobile
expose :exercise_name
expose :exercise_description
exercise_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end
end
end

@ -98,6 +98,14 @@ module Mobile
homework_expose :coursename #所属班级名
expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options|
if instance[:current_user_is_teacher].nil?
current_user = options[:user]
current_user_is_teacher = false
current_user_is_teacher = is_course_teacher(current_user,instance.course)
current_user_is_teacher
end
end
end
end
end

@ -23,7 +23,9 @@ module Mobile
when :issue_status
IssueStatus.find(issue.status_id).name
when :journals_count
issue.journals.where("notes is not null and notes != ''").count
# issue.journals.where("notes is not null and notes != ''").count
all_comments = []
get_all_children(all_comments, f).count
when :project_name
issue.project.name
when :praise_count

@ -18,7 +18,9 @@ module Mobile
when :lasted_comment
time_from_now f.created_on
when :reply_count
f.children.count
# f.children.count
all_comments = []
get_all_children(all_comments, f).count
when :praise_count
get_activity_praise_num(f)
when :act_type

@ -30,6 +30,9 @@ module Mobile
'Message'
when :act_id
u.id
when :replies_count
all_comments = []
get_all_children(all_comments, u).count
end
end
end

@ -24,6 +24,9 @@ module Mobile
'News'
when :act_id
f.id
when :comments_count
all_comments = []
get_all_children(all_comments, f).count
end
end
elsif f.is_a?(Hash) && !f.key?(field)

@ -507,7 +507,8 @@ class ApplicationController < ActionController::Base
# render_404
# end
def self.model_object(model)
def self.
model_object(model)
self.model_object = model
end

@ -144,7 +144,7 @@ class BlogCommentsController < ApplicationController
if params[:parent_id]
@blogComment.content = params[:blog_comment][:content]
parent = BlogComment.find params[:parent_id]
@blogComment.reply_id = params[:reply_id]
@blogComment.reply_id = params[:id]
parent.children << @blogComment
else
@quote = params[:quote][:quote] || ""

@ -161,6 +161,7 @@ class BoardsController < ApplicationController
if @project
render :action => 'show', :layout => 'base_projects'
elsif @course
@left_nav_type = 2
@params=params
render :action => 'show', :layout => 'base_courses'
end
@ -185,6 +186,7 @@ class BoardsController < ApplicationController
@board = @project.boards.build
@board.safe_attributes = params[:board]
if @project.project_type == 1
@left_nav_type = 2
render :layout => 'base_courses'
end
end
@ -206,6 +208,7 @@ class BoardsController < ApplicationController
def edit
if @project.project_type == 1
@left_nav_type = 2
render :layout => 'base_courses'
end
end

@ -19,8 +19,8 @@ class CommentsController < ApplicationController
default_search_scope :news
include ApplicationHelper
model_object News
before_filter :find_model_object
before_filter :find_project_from_association
before_filter :find_model_object, :except => [:reply, :quote]
before_filter :find_project_from_association, :except => [:reply, :quote]
before_filter :authorize
def create
@ -73,7 +73,46 @@ class CommentsController < ApplicationController
def destroy
@news.comments.find(params[:comment_id]).destroy
redirect_to news_url(@news)
if params[:user_activity_id]
@user_activity_id = params[:user_activity_id]
respond_to do |format|
format.js
return
end
else
redirect_to news_url(@news)
end
end
def quote
@comment = Comment.find(params[:id])
respond_to do | format|
format.js
end
end
def reply
comment = Comment.find(params[:id])
@news = News.find comment.commented_id
new_comment = @news.comments.build(:author_id => User.current.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id)
@user_activity_id = params[:user_activity_id]
if new_comment.save
update_course_activity(@news.class,@news.id)
update_user_activity(@news.class,@news.id)
update_org_activity(@news.class,@news.id)
if @user_activity_id
respond_to do |format|
format.js
return
end
else
respond_to do |format|
format.html {
redirect_to news_path(@news)
}
end
end
end
end
private
@ -87,5 +126,4 @@ class CommentsController < ApplicationController
@news
end
end

@ -301,7 +301,6 @@ class CoursesController < ApplicationController
def member
## 有角色参数的才是课程,没有的就是项目
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
@render_file = 'new_member_list'
@score_sort_by = "desc"
@sort_type = params[:sort_type] ? params[:sort_type] : "score"
@ -414,6 +413,9 @@ class CoursesController < ApplicationController
end
def settings
#添加成员消息状态
join_course_messages = CourseMessage.where("user_id =? and course_message_type =? and course_id =? and status = ? and viewed =?", User.current.id, 'JoinCourse', @course.id, 1, 0)
join_course_messages.update_all(:viewed => true)
if User.current.allowed_to?(:as_teacher,@course)
@select_tab = params[:tab]
@issue_custom_fields = IssueCustomField.sorted.all
@ -905,6 +907,7 @@ class CoursesController < ApplicationController
end
@type = params[:type]
@left_nav_type = 1
respond_to do |format|
format.js
format.html{render :layout => 'base_courses'}
@ -936,6 +939,7 @@ class CoursesController < ApplicationController
end
@jour = paginateHelper @jours,10
@state = false
@left_nav_type = 6
respond_to do |format|
format.html{render :layout => 'base_courses'}
format.api
@ -1119,6 +1123,14 @@ class CoursesController < ApplicationController
end
end
#统计
def statistics_course
@left_nav_type = 9
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
end
private
def update_quotes attachment
if attachment.copy_from

@ -29,6 +29,7 @@ class ExerciseController < ApplicationController
exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc")
end
@exercises = paginateHelper exercises,20 #分页
@left_nav_type = 8
respond_to do |format|
format.html
end
@ -72,6 +73,7 @@ class ExerciseController < ApplicationController
end
# @percent = get_percent(@exercise,User.current)
@exercise_questions = @exercise.exercise_questions
@left_nav_type = 8
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
@ -118,6 +120,7 @@ class ExerciseController < ApplicationController
end
def edit
@left_nav_type = 8
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@ -159,6 +162,7 @@ class ExerciseController < ApplicationController
@exercise = Exercise.find(params[:id])
exercise_questions = @exercise.exercise_questions
@exercise_questions = paginateHelper exercise_questions, 5
@left_nav_type = 8
respond_to do |format|
format.html{render :layout => 'base_courses'}
end
@ -379,6 +383,7 @@ class ExerciseController < ApplicationController
else
@exercise_users_list = []
end
@left_nav_type = 8
respond_to do |format|
format.html
format.xls {
@ -566,6 +571,7 @@ class ExerciseController < ApplicationController
eu = get_exercise_user(@exercise.id, @user.id)
eu.update_attributes(:score => score)
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
@left_nav_type = 8
respond_to do |format|
format.html {render :layout => 'base_courses'}
end

@ -366,6 +366,7 @@ class FilesController < ApplicationController
@tag_list = attachment_tag_list @all_attachments
@left_nav_type = 5
render :layout => 'base_courses'
elsif params[:org_subfield_id]
if params[:sort]
@ -445,6 +446,7 @@ class FilesController < ApplicationController
@versions = @project.versions.sort
@course_tag = @project.project_type
if @project.project_type == 1
@left_nav_type = 5
render :layout => 'base_courses'
end
end
@ -812,6 +814,7 @@ class FilesController < ApplicationController
@attachtype = params[:type].to_i
@contenttype = params[:contentType].to_s
# render layout: 'base_courses'
@left_nav_type = 5
respond_to do |format|
format.js
format.html {

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save