diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 148f45d2c..b0475097d 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -40,9 +40,10 @@ class BlogCommentsController < ApplicationController end def show @article = BlogComment.find(params[:id]) - all_comments = [] - @replies = get_all_children(all_comments, @article) + @replies = BlogComment.where("root_id = #{@article.id}").reorder("created_on desc") @reply_count = @replies.count + @replies = get_no_children_comments_all @replies + @limit_count = @replies.count @page = params[:page] ? params[:page].to_i + 1 : 0 @limit = 10 @replies = @replies[@page * @limit..@page * @limit + 9] diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 0c7eb570f..51fcdcc2d 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -50,6 +50,8 @@ class MessagesController < ApplicationController all_comments = [] @replies = Message.where("root_id = #{@topic.id}").reorder("created_on desc") @reply_count = @replies.count + @replies = get_no_children_comments_all @replies + @limit_count = @replies.count @page = params[:page] ? params[:page].to_i + 1 : 0 @limit = 10 @replies = @replies[@page * @limit..@page * @limit + 9] @@ -171,9 +173,6 @@ class MessagesController < ApplicationController @reply.root_id = parent.root_id.nil? ? parent.id : parent.root_id # @reply.reply_id = params[:id] parent.children << @reply - @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @is_course = params[:is_course] if params[:is_course] - @is_board = params[:is_board] if params[:is_board] else @quote = params[:quote][:quote] @reply = Message.new @@ -207,8 +206,8 @@ class MessagesController < ApplicationController end if params[:user_activity_id] @user_activity_id = params[:user_activity_id] - @is_course = params[:is_course] - @is_board = params[:is_board] + @is_course = params[:is_course] if params[:is_course] + @is_board = params[:is_board] if params[:is_board] respond_to do |format| format.js end @@ -282,8 +281,8 @@ class MessagesController < ApplicationController @message.destroy @topic = Message.find(params[:activity_id].to_i) @user_activity_id = params[:user_activity_id] - @is_course = params[:is_course] - @is_board = params[:is_board] + @is_course = params[:is_course] if params[:is_course] + @is_board = params[:is_board] if params[:is_board] respond_to do |format| format.js end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 53afa50aa..aa037b8d5 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -172,6 +172,8 @@ class NewsController < ApplicationController @news = result[:news] @comments = result[:comments] @comments_count = @comments.count + @comments = get_no_children_comments_all @comments + @limit_count = @comments.count @page = params[:page] ? params[:page].to_i + 1 : 0 @limit = 10 @comments = @comments[@page * @limit..@page * @limit + 9] diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 49e970af7..6b8d11479 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -41,8 +41,10 @@ class OrgDocumentCommentsController < ApplicationController @org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first @subfield_content = @organization.org_subfields.order("priority") all_comments = [] - @replies = get_all_children(all_comments, @document) + @replies = OrgDocumentComment.where("root_id = #{@document.id}").reorder("created_at desc") @reply_count = @replies.count + @replies = get_no_children_comments_all @replies + @limit_count = @replies.count @page = params[:page] ? params[:page].to_i + 1 : 0 @limit = 10 @replies = @replies[@page * @limit..@page * @limit + 9] diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 13a1a1e58..09cede45a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -601,6 +601,13 @@ class ProjectsController < ApplicationController def member_forked @forked_projects = Project.where(:forked_from_project_id => @project.id) + @limit = 20 + @is_remote = true + @forked_count = @project.forked_count + @forked_pages = Paginator.new @forked_count, @limit, params['page'] || 1 + @offset ||= @forked_pages.offset + @forked_projects = paginateHelper @forked_projects, @limit + # @forked_members = User.find_by_sql("SELECT u.* FROM `projects` p,`users` u where p.user_id = u.id and p.forked_from_project_id = #{@project.id} ;") end @@ -664,7 +671,13 @@ class ProjectsController < ApplicationController end def statistics - + @watchers = @project.watcher_users + @limit = 20 + @is_remote = true + @watchers_count = @watchers.count + @watcher_pages = Paginator.new @watchers_count, @limit, params['page'] || 1 + @offset ||= @watcher_pages.offset + @watchers = paginateHelper @watchers, 20 end #end @@ -972,14 +985,6 @@ class ProjectsController < ApplicationController else @users -= watched.watcher_users if @watched end - @watchers = @project.watcher_users - @limit = 20 - @is_remote = true - @watchers_count = @watchers.count - @watcher_pages = Paginator.new @watchers_count, @limit, params['page'] || 1 - @offset ||= @watcher_pages.offset - #@curse_attachments_all = @all_attachments[@offset, @limit] - @watchers = paginateHelper @watchers,20 end end diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index cad65f88d..13bacbd4b 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -92,7 +92,7 @@ class SyllabusesController < ApplicationController def destroy if @syllabus && @syllabus.courses.not_deleted.empty? @syllabus.destroy - redirect_to user_courselist_user_path(User.current.id) + redirect_to user_courselist_user_path(User.current) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 049789115..262c014d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -171,7 +171,6 @@ class UsersController < ApplicationController else @user_activity_id = -1 end - @hw_status = params[:hw_status].to_i when 'JournalsForMessage' @reply = JournalsForMessage.find params[:reply_id] @user_activity_id = params[:user_activity_id] @@ -181,15 +180,11 @@ class UsersController < ApplicationController @reply = Message.find params[:reply_id] @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] - @is_course = params[:is_course] - @is_board = params[:is_board] @type = 'Message' when 'BlogComment' @reply = BlogComment.find params[:reply_id] @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] - @homepage = params[:homepage] - @user_id = params[:user_id] @type = 'BlogComment' when 'OrgDocumentComment' @reply = OrgDocumentComment.find params[:reply_id] @@ -215,6 +210,96 @@ class UsersController < ApplicationController end end + #叠层回复框中的回复 + def reply_to_comment + @type = params[:type] + @reply = get_reply_by_type @type, params[:reply_id] + @user_activity_id = params[:user_activity_id] + @is_project = params[:is_project] if params[:is_project] + respond_to do |format| + format.js + end + end + + #多级回复 + def reply_detail + @type = params[:type] + reply = get_reply_by_type @type, params[:reply_id] + @user_activity_id = params[:user_activity_id] + case params[:type] + when 'HomeworkCommon' + @root = HomeworkCommon.find reply.jour_id + options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => User.current.id,:m_parent_id => params[:reply_id].to_i,:m_reply_id => params[:reply_id].to_i, :root_id => reply.root_id} + comment = HomeworkCommon.add_homework_jour(User.current, params[:reply_message], reply.jour_id, reply.root_id, options) + @root.update_column('updated_at', Time.now) + @is_teacher = User.current.allowed_to?(:as_teacher, @root.course) || User.current.admin? + when 'JournalsForMessage' + options = {:user_id => User.current.id, + :status => true, + :m_parent_id => params[:reply_id], + :m_reply_id => params[:reply_id], + :reply_id => reply.user.id, + :notes => params[:reply_message], + :root_id => reply.root_id, + :is_readed => false} + @root = reply.root + comment = add_reply_adapter(@root, options) + @root.update_attribute(:updated_on,Time.now) + when 'Message' + @root = reply.root + comment = Message.new + comment.author = User.current + comment.board = reply.board + comment.content = params[:reply_message] + comment.subject = "RE: #{@root.subject}" + comment.reply_id = params[:reply_id] + comment.root_id = reply.root_id + reply.children << comment + @is_project = params[:is_project] if params[:is_project] + when 'BlogComment' + @root = reply.root + comment = BlogComment.new + comment.author = User.current + comment.blog = reply.blog + comment.title = "RE: #{@root.title}" + comment.content = params[:reply_message] + comment.reply_id = params[:reply_id] + comment.root_id = reply.root_id + reply.children << comment + when 'OrgDocumentComment' + @root = reply.root + comment = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:reply_id]) + comment.title = "RE:#{@root.title}" + comment.content = params[:reply_message] + comment.root_id = reply.root_id + reply.children << comment + when 'News' + @root = News.find reply.commented_id + comment = @root.comments.build(:author_id => User.current.id, :reply_id => params[:reply_id], :comments => params[:reply_message], :parent_id => reply.id) + comment.save + when 'Issue' + @root = reply.issue + comment = @root.journals.build(:user_id => User.current.id, :reply_id => params[:reply_id], :notes => params[:reply_message], :parent_id => reply.id) + comment.save + @is_project = params[:is_project] if params[:is_project] + when 'Syllabus' + @root = Syllabus.find reply.jour_id + options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => User.current.id,:m_parent_id => params[:reply_id].to_i,:m_reply_id => params[:reply_id].to_i, :root_id => reply.root_id} + comment = Syllabus.add_syllabus_jour(User.current, params[:reply_message], reply.jour_id, reply.root_id, options) + @root.update_column('updated_at', Time.now) + @count = @root.journals_for_messages.count + @comments = @root.journals_for_messages.reorder("created_on desc").limit(3) + end + update_course_activity(@root.class.to_s,@root.id) + update_user_activity(@root.class.to_s,@root.id) + update_forge_activity(@root.class.to_s,@root.id) + update_org_activity(@root.class.to_s,@root.id) + update_principal_activity(@root.class.to_s,@root.id) + respond_to do |format| + format.js + end + end + def refresh_changests if !(@user.nil?) && !(@user.memberships.nil?) @user.memberships.each do |member| @@ -3398,7 +3483,11 @@ class UsersController < ApplicationController @my_syllabuses = @user.syllabuses - my_syllabus_ids = @my_syllabuses.empty? ? "(-1)" : "(" + @my_syllabuses.map{|syllabus| syllabus.id}.join(',') + ")" + if @user == User.current + archive_ids = Course.where("tea_id = #{@user.id} and is_delete = 1").blank? ? "(-1)" : "(" + Course.where("tea_id = #{@user.id} and is_delete = 1").map{|course| course.syllabus_id}.join(",") + ")" + @archive_syllabuses = Syllabus.where("id in #{archive_ids}") + end + sy_courses = @user.courses.visible.not_deleted syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" syllabus_members = SyllabusMember.where("user_id = #{@user.id}") @@ -3470,11 +3559,58 @@ class UsersController < ApplicationController end end + #归档班级列表 + def user_archive_courses + if User.current.logged? + @order, @c_sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 + + #确定 sort_type + if @order.to_i == @type.to_i + @c_sort = @c_sort.to_i == 1 ? 2 : 1 #1升序 2降序 + else + @c_sort = 2 + end + + @user = User.current + sort_name = "updated_at" + archive_ids = Course.where("tea_id = #{@user.id} and is_delete = 1").blank? ? "(-1)" : "(" + Course.where("tea_id = #{@user.id} and is_delete = 1").map{|course| course.syllabus_id}.join(",") + ")" + @archive_syllabuses = Syllabus.where("id in #{archive_ids}") + + if @order.to_i == 1 #根据 班级更新时间排序 + @archive_syllabuses = syllabus_course_list_sort @archive_syllabuses + @c_sort == 1 ? (@archive_syllabuses = @archive_syllabuses.sort{|x,y| x[:last_update] <=> y[:last_update] }) : (@archive_syllabuses = @archive_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}) + @type = 1 + elsif @order.to_i == 2 #根据 作业+资源数排序 + @type = 2 + @archive_syllabuses.each do |syllabus| + count = 0 + courses = syllabus.courses.not_deleted + courses.each do |c| + count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count) + end + syllabus[:infocount] = count + end + @c_sort == 1 ? (@archive_syllabuses = @archive_syllabuses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@archive_syllabuses = @archive_syllabuses.sort{|x,y| y[:infocount] <=> x[:infocount]}) + @archive_syllabuses = sortby_time_countcommon_nosticky @archive_syllabuses,sort_name + else + @type = 1 + end + respond_to do |format| + format.js + format.html {render :layout => 'new_base_user'} + end + end + end + #展开课程下的班级 def expand_courses @syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first unless @syllabus.nil? - @courses = @syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") + if params[:is_delete] && params[:is_delete] == '1' + @courses = @syllabus.courses.where("is_delete = 1").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") + else + @courses = @syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc") + end respond_to do |format| format.js end @@ -3567,18 +3703,12 @@ class UsersController < ApplicationController if params[:type].present? case params[:type] when 'OrgDocumentComment' - #obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] @type = 'OrgDocumentComment' - #comments = [] @journals = OrgDocumentComment.where("root_id = #{params[:id].to_i}").reorder("created_at desc") when 'Message','is_project_message' - #obj = Message.where('id = ?', params[:id].to_i).first @type = 'Message' - @is_course = params[:is_course] - @is_board = params[:is_board] @user_activity_id = params[:div_id].to_i if params[:div_id] - #comments = [] @journals = Message.where("root_id = #{params[:id].to_i}").reorder("created_on desc") when 'News' obj = News.where('id = ?', params[:id].to_i).first @@ -3591,8 +3721,6 @@ class UsersController < ApplicationController @type = 'Syllabus' @user_activity_id = params[:div_id].to_i if params[:div_id] when 'JournalsForMessage' - #obj = JournalsForMessage.where('id = ?', params[:id].to_i).first - #journals = [] @journals = JournalsForMessage.where("root_id = #{params[:id].to_i}").reorder("created_on desc") @type = 'JournalsForMessage' @user_activity_id = params[:div_id].to_i if params[:div_id] @@ -3609,20 +3737,17 @@ class UsersController < ApplicationController when 'BlogComment' obj = BlogComment.where('id = ?', params[:id].to_i).first @user_activity_id = params[:div_id].to_i if params[:div_id] - @homepage = params[:homepage].to_i @type = 'BlogComment' - @user_id = obj.author_id - #comments = [] @journals = BlogComment.where("root_id = #{params[:id].to_i}").reorder("created_on desc") when 'HomeworkCommon' obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @type = 'HomeworkCommon' @journals = obj.journals_for_messages.reorder("created_on desc") - @hw_status = params[:hw_status].to_i if params[:hw_status] @is_teacher = User.current.allowed_to?(:as_teacher,obj.course) @user_activity_id = params[:user_activity_id].to_i if params[:user_activity_id] end end + @journals = get_no_children_comments_all @journals end def homepage diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index e4b480e2f..2ce505e15 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -116,7 +116,7 @@ class WordsController < ApplicationController else @user_activity_id = -1 end - @hw_status = params[:hw_status].to_i + @hw_status = params[:hw_status].to_i if @is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? elsif @journal_destroyed.jour_type == 'Syllabus' @syllabus = Syllabus.find @journal_destroyed.jour_id @@ -315,7 +315,7 @@ class WordsController < ApplicationController respond_to do |format| format.js{ @user_activity_id = params[:user_activity_id].to_i - @hw_status = params[:hw_status].to_i + @hw_status = params[:hw_status].to_i if params[:hw_status] @is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin? } end @@ -349,7 +349,7 @@ class WordsController < ApplicationController respond_to do |format| format.js{ @user_activity_id = params[:user_activity_id].to_i - @hw_status = params[:hw_status].to_i + @hw_status = params[:hw_status].to_i if params[:hw_status] @is_teacher = User.current.allowed_to?(:as_teacher, @homework_common.course) || User.current.admin? } end @@ -454,45 +454,5 @@ class WordsController < ApplicationController end obj end - - def add_reply_adapter obj, options - #modify by nwb - #添加对课程留言的支持 - #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 - case obj.jour_type - when 'Principal' - obj.jour.add_jour(nil, nil, nil, options) - when 'Project' - Project.add_new_jour(nil, nil, obj.jour_id, options) - when 'Course' - Course.add_new_jour(nil, nil, obj.jour_id, options) - when 'Bid' - obj.jour.add_jour(nil, nil, nil, options) - when 'Contest' - obj.jour.add_jour(nil, nil, obj.jour_id, options) - when 'Softapplication' - obj.jour.add_jour(nil, nil, obj.jour_id, options) - when 'HomeworkAttach' - obj.jour.add_jour(nil, nil, obj.jour_id, options) - end - # obj = obj_distinguish_url_origin || User.find_by_id(2) - # if obj.kind_of? User - # obj.add_jour(nil, nil, nil, options) - # elsif obj.kind_of? Project - # Project.add_new_jour(nil, nil, obj.id, options) - # elsif obj.kind_of? Course - # Course.add_new_jour(nil, nil, obj.id, options) - # elsif obj.kind_of? Bid - # obj.add_jour(nil, nil, nil, options) - # elsif obj.kind_of? Contest - # obj.add_jour(nil, nil, obj.id, options) #new added - # elsif obj.kind_of? Softapplication - # obj.add_jour(nil, nil, obj.id, options) #new added - # elsif obj.kind_of? HomeworkAttach - # obj.add_jour(nil, nil, obj.id, options) #new added - # else - # raise "create reply obj unknow type.#{obj.class}" - # end - end #######end of message end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c52182b01..ad3d2c61d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3394,6 +3394,61 @@ def secdomain_with_protocol secdomain return Setting.protocol + "://" + secdomain + ".trustie.net" end +#根据回复类型获取回复 +def get_reply_by_type type, reply_id + reply = nil + case type + when 'HomeworkCommon' + reply = JournalsForMessage.find reply_id + when 'JournalsForMessage' + reply = JournalsForMessage.find reply_id + when 'Message' + reply = Message.find reply_id + when 'BlogComment' + reply = BlogComment.find reply_id + when 'OrgDocumentComment' + reply = OrgDocumentComment.find reply_id + when 'News' + reply = Comment.find reply_id + when 'Issue' + reply = Journal.find reply_id + when 'Syllabus' + reply = JournalsForMessage.find reply_id + end + reply +end + +#获取不包含子节点的回复(前三个) +def get_no_children_comments comments + result = {} + no_children_comments = [] + count = 0 + three_more = false + comments.each do |comment| + if comment.children.blank? + count = count + 1 + if count > 3 + three_more = true + end + break if count > 3 + no_children_comments << comment + end + end + result[:three_more] = three_more + result[:no_children_comments] = no_children_comments + result +end + +#获取不包含子节点的回复(所有) +def get_no_children_comments_all comments + no_children_comments = [] + comments.each do |comment| + if comment.children.blank? + no_children_comments << comment + end + end + no_children_comments +end #获取回复的所有父节点 def get_reply_parents parents_rely, comment @@ -3746,3 +3801,43 @@ def homework_type_option type end +def add_reply_adapter obj, options + #modify by nwb + #添加对课程留言的支持 + #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 + case obj.jour_type + when 'Principal' + obj.jour.add_jour(nil, nil, nil, options) + when 'Project' + Project.add_new_jour(nil, nil, obj.jour_id, options) + when 'Course' + Course.add_new_jour(nil, nil, obj.jour_id, options) + #when 'Bid' + # obj.jour.add_jour(nil, nil, nil, options) + #when 'Contest' + # obj.jour.add_jour(nil, nil, obj.jour_id, options) + #when 'Softapplication' + # obj.jour.add_jour(nil, nil, obj.jour_id, options) + #when 'HomeworkAttach' + # obj.jour.add_jour(nil, nil, obj.jour_id, options) + end + # obj = obj_distinguish_url_origin || User.find_by_id(2) + # if obj.kind_of? User + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Project + # Project.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Course + # Course.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Bid + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Contest + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? Softapplication + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? HomeworkAttach + # obj.add_jour(nil, nil, obj.id, options) #new added + # else + # raise "create reply obj unknow type.#{obj.class}" + # end +end + diff --git a/app/views/blog_comments/_blog_comment_show_replies.html.erb b/app/views/blog_comments/_blog_comment_show_replies.html.erb index ba33aaf5a..3a3e8ef81 100644 --- a/app/views/blog_comments/_blog_comment_show_replies.html.erb +++ b/app/views/blog_comments/_blog_comment_show_replies.html.erb @@ -10,7 +10,7 @@ <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
- <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%> + <%= render :partial => 'users/message_contents', :locals => {:comment => comment, :type => 'BlogComment', :user_activity_id => @article.id}%> <% if !comment.content_detail.blank? %>
@@ -52,7 +52,7 @@
<% end %> -<% if @reply_count > @page * @limit + 10 %> +<% if @limit_count > @page * @limit + 10 %>
diff --git a/app/views/blog_comments/destroy.js.erb b/app/views/blog_comments/destroy.js.erb index 52ecbb925..ffdc27c22 100644 --- a/app/views/blog_comments/destroy.js.erb +++ b/app/views/blog_comments/destroy.js.erb @@ -1,7 +1,8 @@ -<% if @in_user_homepage %> - <% homepage = BlogComment.find(@user.blog.homepage_id) %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => @blog_comment, :user_activity_id => homepage.id}) %>"); -<% else%> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @blog_comment,:user_activity_id =>@user_activity_id}) %>"); -<% end %> +<%# if @in_user_homepage %> + <%# homepage = BlogComment.find(@user.blog.homepage_id) %> + //$("#user_activity_<%#= @user_activity_id%>").replaceWith("<%#= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => @blog_comment, :user_activity_id => homepage.id}) %>"); +<%# else%> + //$("#user_activity_<%#= @user_activity_id%>").replaceWith("<%#= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @blog_comment,:user_activity_id =>@user_activity_id}) %>"); +<%# end %> +$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_blog_post_reply', :locals => {:activity => @blog_comment,:user_activity_id =>@user_activity_id}) %>"); sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); \ No newline at end of file diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index f612cfe98..3fb9f4c54 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -1,11 +1,12 @@ -<% if @in_user_homepage %> - <% homepage = BlogComment.find(@user.blog.homepage_id) %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id}) %>"); -<% elsif @in_user_center%> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +<%# if @in_user_homepage %> + <%# homepage = BlogComment.find(@user.blog.homepage_id) %> + //$("#user_activity_<%#= @user_activity_id%>").replaceWith("<%#= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id}) %>"); +<%# elsif @in_user_center%> + //$("#user_activity_<%#= @user_activity_id%>").replaceWith("<%#= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); // init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); -<% else%> -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); +<%# else%> +//$("#user_activity_<%#= @user_activity_id%>").replaceWith("<%#= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); //init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity'); -<% end %> +<%# end %> +$("#activity_post_reply_<%= @user_activity_id%>").html("<%= escape_javascript(render :partial => 'users/user_blog_post_reply', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", 'UserActivity'); \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 144560388..8195e5ee3 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -109,9 +109,7 @@
- <% all_comments = []%> - <% all_replies = BlogComment.where("root_id = #{@article.id}").reorder("created_on desc") %> - <% count= all_replies.count %> +
回复 @@ -124,7 +122,6 @@
- <%# comments = all_replies %> <% if @reply_count > 0 %>
<%= render :partial => 'blog_comment_show_replies' %> diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 8ddc3062d..9e13cbafc 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -1,7 +1,7 @@
-

博客列表

+

博客列表

排序: <%= link_to "时间", {:controller => 'blogs', :action => 'index', :id =>@user, :type => @type, :sort => @b_sort, :order => 1 }, :class => "sortTxt", :remote => true %> @@ -21,9 +21,9 @@
  • <% if activity.parent_id.nil? %> - <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=> activity.author, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %> + <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=> activity.author, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title-normal fl" %> <% else %> - <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> + <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title-normal fl"%> <% end %> <%# if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> @@ -36,7 +36,8 @@ <% end %>
  • - <% count=BlogComment.where("root_id = #{activity.id}").count%>
  • + <% count=BlogComment.where("root_id = #{activity.id}").count%> +
  • 发布:<%= format_time(activity.created_on) %> 更新:<%= format_time(activity.updated_on) %>

    diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb index 6b40a23da..2b921c7a4 100644 --- a/app/views/blogs/_homepage.html.erb +++ b/app/views/blogs/_homepage.html.erb @@ -45,16 +45,15 @@

- <% all_comments = []%> <% all_repies = BlogComment.where("root_id = #{activity.id}").reorder("created_on desc") %> <% count = all_repies.count %> + <% no_children_comments = get_no_children_comments all_repies %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 1} %> + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :homepage => 1, :expand_more =>no_children_comments[:three_more]} %> - <% comments = all_repies[0..2] %> <% if count > 0 %>
- <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 1, :user_id => activity.author_id}%> + <%= render :partial => 'users/message_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 1, :user_id => activity.author_id}%>
<% end %> diff --git a/app/views/comments/destroy.js.erb b/app/views/comments/destroy.js.erb index e8f425a85..1df37cd43 100644 --- a/app/views/comments/destroy.js.erb +++ b/app/views/comments/destroy.js.erb @@ -2,7 +2,7 @@ <% if @news.project_id && @news.project_id != -1 %> $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% elsif @news.course_id %> - $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); + $("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% elsif @news.org_subfield_id %> $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% end %> diff --git a/app/views/comments/reply.js.erb b/app/views/comments/reply.js.erb index e8f425a85..1df37cd43 100644 --- a/app/views/comments/reply.js.erb +++ b/app/views/comments/reply.js.erb @@ -2,7 +2,7 @@ <% if @news.project_id && @news.project_id != -1 %> $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% elsif @news.course_id %> - $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); + $("#activity_post_reply_<%= @user_activity_id %>").html("<%= escape_javascript(render :partial => 'users/course_news_post_reply', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% elsif @news.org_subfield_id %> $("#user_activity_<%= @user_activity_id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); <% end %> diff --git a/app/views/courses/archive_course.js.erb b/app/views/courses/archive_course.js.erb index 9d66c8441..a5ef39035 100644 --- a/app/views/courses/archive_course.js.erb +++ b/app/views/courses/archive_course.js.erb @@ -13,5 +13,11 @@ function click_OK(){ hideModal(); <% if params[:source] == "1" %> window.location.href = "<%=syllabus_courselist_syllabus_path(@syllabus, :list_type => params[:type].to_i) %>"; + <% elsif params[:source] == "0" %> + <% if params[:type] == "0" %> + window.location.href = "<%=user_courselist_user_path(User.current) %>"; + <% else %> + window.location.href = "<%=user_archive_courses_users_path() %>"; + <% end %> <% end %> } \ No newline at end of file diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index 2d2eecab1..606c0d67c 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -4,7 +4,7 @@

<%= @subPage_title%>

<% if User.current.allowed_to?(:as_teacher,@course) %> - <%=link_to "成员管理", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member', :class => 'hw_more_li' %> + <%=link_to "成员管理", {:controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member'}, :class => 'hw_more_li' %> <% end %>
@@ -13,21 +13,12 @@ <% else %>
-

<%= @subPage_title %>

-
-
    -
  • -
      -
    • <%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'), :class => 'hw_more_li'%>
    • - <% if User.current.allowed_to?(:as_teacher,@course) %> -
    • - <%=link_to "成员管理", {:controller => 'courses', :action => 'settings', :id => @course.id, :tab => 'member'}, :class => 'hw_more_li' %> -
    • - <% end %> -
    -
  • -
-
+

<%= @subPage_title %>

+ <% if User.current.allowed_to?(:as_teacher,@course) %> + <%=link_to "成员管理", {:controller => 'courses', :action => 'settings', :id => @course.id, :tab => 'member'}, :class => 'link-blue ml10 fr mt5' %> + <% end %> + <%= link_to l(:label_export_excel), export_course_member_excel_course_path(@course,:format => 'xls'), :class => 'link-blue fr mt5'%> +
<%= render :partial => 'course_student', :locals => {:members => @members} %>
diff --git a/app/views/courses/teacher_assign_group.js.erb b/app/views/courses/teacher_assign_group.js.erb index 4df0924ea..503c530cd 100644 --- a/app/views/courses/teacher_assign_group.js.erb +++ b/app/views/courses/teacher_assign_group.js.erb @@ -1,5 +1,9 @@ <% if params[:group_id] != "0" %> -$("#member_li_<%=@member.id %>").html(""); +var all_indexes = $("#member_li_<%=@member.id %>").nextAll().find("td:first-child"); +for(var i = 0; i < all_indexes.length; i++){ + $(all_indexes[i]).html(parseInt($(all_indexes[i]).html()) - 1); +} +$("#member_li_<%=@member.id %>").remove(); <% end %> <% if @group && @group != "-1" %> //$("#member_content").html("<%#= escape_javascript( render :partial => 'new_member_list', :locals => {:members => @results})%>"); diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index 8a0c182ce..4cc5a6cf8 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -11,8 +11,6 @@ 测验时长:<%= exercise.time %>分钟 <% end %>
-
-    <%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
-  
+
<%= exercise.exercise_description.nil? ? "" :exercise.exercise_description.html_safe%>
\ No newline at end of file diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index baf46762c..e67040138 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -11,7 +11,7 @@ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/news_contents', :locals => {:comment => comment}%> + <%= render :partial => 'users/news_contents', :locals => {:comment => comment, :type => 'Issue', :user_activity_id => issue.id}%>
<% if comment.details.any? %> diff --git a/app/views/layouts/base_users_new.html.erb b/app/views/layouts/base_users_new.html.erb index 2f3ef2928..316d10c4c 100644 --- a/app/views/layouts/base_users_new.html.erb +++ b/app/views/layouts/base_users_new.html.erb @@ -140,25 +140,25 @@