diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 52e1f5fd0..6c62c642a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -82,7 +82,7 @@ class AdminController < ApplicationController syllabus.update_attributes(:title => params[:title], :eng_name => params[:eng_name], :user_id => @user.id) syllabus.description = Message.where("id = 19412").first.nil? ? nil : Message.where("id = 19412").first.content if syllabus.save - course.update_attribute('syllabus_id', syllabus.id) + course.update_column('syllabus_id', syllabus.id) @flag = params[:flag].to_i @course = course respond_to do |format| @@ -96,7 +96,7 @@ class AdminController < ApplicationController def courses @name = params[:name].to_s.strip.downcase if @name && @name != "" - @courses = Course.select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)} + @courses = Course.select{ |course| course.teacher && ((course.teacher.show_name).include?(@name) || course.name.include?(@name))} @courses = @courses.sort{|x, y| y.created_at <=> x.created_at} else @courses = Course.order('created_at desc') @@ -135,6 +135,17 @@ class AdminController < ApplicationController end end + #修改课程名称 + def update_syllabus_title + @syllabus = Syllabus.where("id = #{params[:syllabus_id].to_i}").first + unless @syllabus.nil? + @syllabus.update_column("title", params[:name]) + respond_to do |format| + format.js + end + end + end + #管理员界面精品课程列表 def excellent_courses @courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 ) diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 5b29565ad..69c33f90e 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -47,6 +47,8 @@ class AtController < ApplicationController find_journals_for_message(id) when 'Principal' find_principal(id) + when 'BlogComment' + find_blog_comment(id) when 'All' nil else @@ -166,8 +168,8 @@ class AtController < ApplicationController #BlogComment def find_blog_comment(id) - blog = BlogComment.find(id).blog - blog.users + blog = BlogComment.find(id) + blog.author.watcher_users end end \ No newline at end of file diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index 4a8de5814..dcab1b360 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -70,6 +70,10 @@ class BlogCommentsController < ApplicationController @course.outline = 0 @course.save redirect_to course_path(:id=>params[:course_id]) + elsif params[:user_activity_id] + @article.children.destroy + @article.destroy + redirect_to user_path(User.current.id) else @article.children.destroy @article.destroy @@ -80,6 +84,17 @@ class BlogCommentsController < ApplicationController if params[:course_id] #如果带了course_id过来了,那么这是要跳到课程大纲去的 @article.destroy redirect_to syllabus_course_path(:id=>params[:course_id]) + elsif params[:user_activity_id] + if params[:homepage] && params[:homepage] == "1" + @in_user_homepage = true + end + @user_activity_id = params[:user_activity_id] + @blog_comment = @article.root + @article.destroy + respond_to do |format| + format.js + return + end else root = @article.root @article.destroy @@ -102,13 +117,9 @@ class BlogCommentsController < ApplicationController def quote @blogComment = BlogComment.find(params[:id]) - @subject = @blogComment.title - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - @content = "> #{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}\n> " @temp = BlogComment.new @course_id = params[:course_id] - @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, @blogComment.author.realname)}".html_safe respond_to do | format| format.js end @@ -116,23 +127,30 @@ class BlogCommentsController < ApplicationController #回复 def reply - if params[:homepage] + if params[:homepage] && params[:homepage] == "1" @in_user_homepage = true end if params[:in_user_center] @in_user_center = true end @article = BlogComment.find(params[:id]).root - @quote = params[:quote][:quote] @blogComment = BlogComment.new @blogComment.author = User.current @blogComment.blog = Blog.find(params[:blog_id]) params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @blogComment.safe_attributes = params[:blog_comment] - @blogComment.content = @quote + @blogComment.content @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] - @article.children << @blogComment + if params[:parent_id] + @blogComment.content = params[:blog_comment][:content] + parent = BlogComment.find params[:parent_id] + @blogComment.reply_id = params[:reply_id] + parent.children << @blogComment + else + @quote = params[:quote][:quote] || "" + @blogComment.content = @quote + @blogComment.content + @article.children << @blogComment + end @article.save # @article.update_attribute(:updated_on, @blogComment.updated_on) @user_activity_id = params[:user_activity_id] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index deb1d9bc2..665273ae0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -971,7 +971,7 @@ class CoursesController < ApplicationController @homework = HomeworkCommon.find params[:homework] #order("#{@order} #{@b_sort}" - @student_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("simi_value desc"),@name + @student_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("simi_value desc").has_committed,@name @works_hash = {} diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 44f0d15f4..049842e37 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -432,14 +432,15 @@ class IssuesController < ApplicationController def add_journal if User.current.logged? - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:notes] - jour.journalized = @issue - jour.save_attachments(params[:attachments]) - jour.save + @jour = Journal.new + @jour.user_id = User.current.id + @jour.notes = params[:notes] + @jour.journalized = @issue + @jour.save_attachments(params[:attachments]) + @jour.save update_user_activity(@issue.class,@issue.id) update_forge_activity(@issue.class,@issue.id) + @allowed_statuses = @issue.new_statuses_allowed_to(User.current) @user_activity_id = params[:user_activity_id] if params[:issue_id] @@ -492,7 +493,7 @@ class IssuesController < ApplicationController update_forge_activity(@issue.class,@issue.id) respond_to do |format| - format.js + format.html{redirect_to issue_url(@issue)} end end end @@ -502,7 +503,7 @@ class IssuesController < ApplicationController @issue = Issue.find(params[:id]) Journal.destroy(params[:journal_id]) respond_to do |format| - format.js + format.html{redirect_to issue_url(@issue)} end end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 264c1fc9f..924be596e 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -123,10 +123,14 @@ class OrgDocumentCommentsController < ApplicationController def destroy @org_document_comment = OrgDocumentComment.find(params[:id]) @org_sub_id = @org_document_comment.org_subfield_id - org = @org_document_comment.organization + org = @org_document_comment.root.organization if @org_document_comment.id == org.home_id org.update_attributes(:home_id => nil) end + if params[:user_activity_id] + @act = OrgActivity.find(params[:user_activity_id]) + @document = @org_document_comment.root + end if @org_document_comment.destroy end respond_to do |format| @@ -145,48 +149,26 @@ class OrgDocumentCommentsController < ApplicationController end def quote @org_comment = OrgDocumentComment.find(params[:id]) - @subject = @org_comment.content - @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - - @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " @temp = OrgDocumentComment.new - #@course_id = params[:course_id] - @temp.content = "
#{@blogComment.content.html_safe}
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}".html_safe respond_to do | format| format.js end end def reply - @document = OrgDocumentComment.find(params[:id]).root - @quote = params[:quote][:quote] + @document = OrgDocumentComment.find(params[:id]) @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) - # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 - # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 @org_document.title = params[:org_document_comment][:title] @org_document.content = params[:org_document_comment][:content] - @org_document.content = @quote + @org_document.content - #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document - # @user_activity_id = params[:user_activity_id] - # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first - # if user_activity - # user_activity.updated_at = Time.now - # user_activity.save - # end - # attachments = Attachment.attach_files(@org_document, params[:attachments]) - # render_attachment_warning_if_needed(@org_document) - #@article.save - # redirect_to user_blogs_path(:user_id=>params[:user_id]) + @document = @document.root + @user_activity_id = params[:user_activity_id] + @act = OrgActivity.find(@user_activity_id) if @user_activity_id respond_to do |format| format.html { - # if params[:course_id] #如果呆了course_id过来了,那么这是要跳到课程大纲去的 - # redirect_to syllabus_course_path(:id=>params[:course_id]) - # else redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) - # end - } format.js end diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index 03ed7945a..3c2f29c84 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -2,7 +2,7 @@ class QualityAnalysisController < ApplicationController before_filter :find_project_by_project_id#, :except => [:getattachtype] before_filter :find_quality_analysis, :only => [:edit, :update_jenkins_job] before_filter :authorize - before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index] + before_filter :connect_jenkins, :only => [:create, :edit, :update_jenkins_job, :index, :delete] layout "base_projects" include ApplicationHelper include QualityAnalysisHelper @@ -33,7 +33,6 @@ class QualityAnalysisController < ApplicationController arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"] quality_an = QualityAnalysis.where(:sonar_name => sonar_name).first if @client.job.exists?(job_name) && QualityAnalysis.where(:sonar_name => sonar_name).select{|qa| arr.include?(qa.sonar_name)}.blank? - logger.info("88888888888888888888") aa = @client.job.delete("#{job_name}") quality_an.delete unless quality_an.blank? end @@ -84,7 +83,7 @@ class QualityAnalysisController < ApplicationController end # sonar 缓冲,取数据 - sleep(5) + sleep(3) # 获取sonar output结果 console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"] @@ -152,11 +151,31 @@ class QualityAnalysisController < ApplicationController @gitlab_default_branch = @g.project(@project.gpid).default_branch end + # 删除的时候主要删除三方面数据:1/Trustie数据 2/jenkins数据 3/sonar数据 + # 如果只删除数据1,则新建的时候会有冲突 + def delete + begin + qa = QualityAnalysis.find(params[:id]) + rep_id = Repository.where(:project_id => @project.id, :identifier => qa.rep_identifier).first.try(:id) + job_name = "#{qa.author_login}-#{rep_id}" + logger.info("result: job_name ###################==>#{job_name}") + logger.info("result: @client.job ###################==>#{@client.job}") + + d_job = @client.job.delete(job_name) + logger.info("result: delete job ###################==>#{d_job}") + qa.delete + respond_to do |format| + format.html{redirect_to project_quality_analysis_path(:project_id => @project.id)} + end + rescue Exception => e + puts e + end + end + # 更新Jenkins job,主要包括相关配置文件参数的更新,Trustie平台数据的更新 def update_jenkins_job begin rep_id = Repository.where(:project_id => @project.id).first.try(:id) - logger.error("#############################===>666") sonar_name = @quality_analysis.sonar_name job_name = "#{@quality_analysis.author_login}-#{rep_id}" version = @quality_analysis.sonar_version @@ -223,7 +242,7 @@ class QualityAnalysisController < ApplicationController if key == "sqale_index" value = com["frmt_val"] else - value = com["val"].to_i + value = com["val"] end @ha.store(key,value) end @@ -260,9 +279,11 @@ class QualityAnalysisController < ApplicationController def connect_jenkins @gitlab_address = Redmine::Configuration['gitlab_address'] @jenkins_address = Redmine::Configuration['jenkins_address'] + jenkins_username = Redmine::Configuration['jenkins_username'] + jenkins_password = Redmine::Configuration['jenkins_password'] # connect jenkins - @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => "temp", :password => '123123') + @client = JenkinsApi::Client.new(:server_url => @jenkins_address, :username => jenkins_username, :password => jenkins_password) rescue => e logger.error("failed to connect Jenkins ==> #{e}") end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index bc1b97a2f..45b54cf0a 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -271,7 +271,7 @@ class StudentWorkController < ApplicationController all_studentwork = find_all_student_work_by_homeid() - @work_count = all_studentwork.count + @work_count = all_studentwork.has_committed.count end #代码查重 status: 0完成 -2不需要查重 -1查重失败不支持该语言 @@ -282,7 +282,7 @@ class StudentWorkController < ApplicationController @homework = HomeworkCommon.find params[:homework] - all_studentwork = find_all_student_work_by_homeid() + all_studentwork = find_all_student_work_by_homeid().has_committed if all_studentwork == nil resultObj[:status] = -2 diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb index 8d7195f38..291e6ca30 100644 --- a/app/controllers/syllabuses_controller.rb +++ b/app/controllers/syllabuses_controller.rb @@ -109,7 +109,11 @@ class SyllabusesController < ApplicationController sort_name = "updated_on" sort_type = @c_sort == 1 ? "asc" : "desc" - @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + if User.current == @syllabus.user || User.current.admin? + @courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + else + @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS #{sort_name}").order("#{sort_name} #{sort_type}") + end #根据 作业+资源数排序 if @order.to_i == 2 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 83a794cd9..5a88e90d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -92,6 +92,8 @@ class UsersController < ApplicationController @comment = JournalsForMessage.find params[:comment].to_i when 'Message' @comment = Message.find params[:comment].to_i + when 'BlogComment' + @comment = BlogComment.find params[:comment].to_i end end @@ -120,6 +122,17 @@ class UsersController < ApplicationController @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] + @type = 'BlogComment' + when 'OrgDocumentComment' + @reply = OrgDocumentComment.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'OrgDocumentComment' end respond_to do |format| format.js @@ -556,12 +569,12 @@ class UsersController < ApplicationController @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc" @user = User.current @r_sort = @b_sort == "desc" ? "asc" : "desc" - if(params[:type].blank? || params[:type] == "1") #题库 + if(params[:type].blank? || params[:type] == "1") #我的题库 + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") + elsif params[:type] == "2" #题库 visible_course = Course.where("is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") - elsif params[:type] == "2" #我的题库 - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") end @type = params[:type] @limit = 25 @@ -715,7 +728,11 @@ class UsersController < ApplicationController @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc" @r_sort = @b_sort == "desc" ? "asc" : "desc" @user = User.current - if(params[:type].blank? || params[:type] == "1") #题库 + if(params[:type].blank? || params[:type] == "1") #我的题库 + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") + elsif params[:type] == "2" #题库 if params[:is_import].to_i == 1 visible_course = Course.where("is_public = 1 && is_delete = 0") elsif params[:is_import].to_i == 0 @@ -723,10 +740,6 @@ class UsersController < ApplicationController end visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") - elsif params[:type] == "2" #我的题库 - courses = @user.courses.where("is_delete = 1") - course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") elsif params[:type] == "3" #申请题库 none_visible_course = Course.where("is_delete = 1") none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")" @@ -793,7 +806,18 @@ class UsersController < ApplicationController @user = User.current search = params[:name].to_s.strip.downcase type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")" - if(params[:type].blank? || params[:type] == "1") #全部 + if(params[:type].blank? || params[:type] == "1") #我的题库 + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + if @order == "course_name" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + @homeworks = HomeworkCommon.find_by_sql(sql) + elsif @order == "user_name" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + else + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") + end + elsif params[:type] == "2" #题库 if params[:is_import].to_i == 1 visible_course = Course.where("is_public = 1 && is_delete = 0") elsif params[:is_import].to_i == 0 @@ -812,17 +836,6 @@ class UsersController < ApplicationController else @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}") end - elsif params[:type] == "2" #我的题库 - courses = @user.courses.where("is_delete = 1") - course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" - if @order == "course_name" - sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" - @homeworks = HomeworkCommon.find_by_sql(sql) - elsif @order == "user_name" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") - else - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") - end elsif params[:type] == "3" #申请题库 apply_homeworks = ApplyHomework.where("user_id = ?",@user.id) homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")" @@ -1410,8 +1423,13 @@ class UsersController < ApplicationController @all_count = @user.courses.visible.where("is_delete =?", 0).count elsif @type == 'Syllabus' @syllabus = Syllabus.where("id = #{params[:syllabus]}").first - @courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5).offset(@page * 5) - @all_count = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).count + if User.current == @syllabus.user || User.current.admin? + all_courses = @syllabus.courses.where("is_delete = 0").select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + else + all_courses = User.current.courses.visible.where("is_delete =? and syllabus_id =?", 0, @syllabus.id).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc") + end + @courses = all_courses.limit(5).offset(@page * 5) + @all_count = all_courses.count end end @@ -2132,6 +2150,7 @@ class UsersController < ApplicationController # 添加资源到对应的项目 def add_exist_file_to_project @flag = true + # 发送单个资源 if params[:send_id].present? send_id = params[:send_id] project_ids = params[:projects_ids] @@ -2168,6 +2187,8 @@ class UsersController < ApplicationController quotes = ori.quotes.to_i + 1 ori.update_attribute(:quotes, quotes) unless ori.nil? ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # 项目中添加动态 + ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" ) end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, @@ -2176,6 +2197,7 @@ class UsersController < ApplicationController end @ori = ori end + # 发送多个资源 elsif params[:send_ids].present? send_ids = params[:send_ids].split(",") project_ids = params[:projects_ids] @@ -2214,6 +2236,8 @@ class UsersController < ApplicationController quotes = ori.quotes.to_i + 1 ori.update_attribute(:quotes, quotes) unless ori.nil? ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + # 项目中添加动态 + ForgeActivity.create(:user_id => User.current.id, :project_id => project_id, :forge_act_id => attach_copied_obj.id, :forge_act_type => "Attachment" ) end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) @@ -3273,7 +3297,10 @@ class UsersController < ApplicationController case params[:type] when 'OrgDocumentComment' obj = OrgDocumentComment.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_at desc") + @user_activity_id = params[:div_id].to_i if params[:div_id] + @type = 'OrgDocumentComment' + comments = [] + @journals = get_all_children(comments, obj) when 'Message' obj = Message.where('id = ?', params[:id].to_i).first @type = 'Message' @@ -3300,7 +3327,11 @@ class UsersController < ApplicationController @journals = obj.journals.reorder("created_on desc") when 'BlogComment' obj = BlogComment.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_on desc") + @user_activity_id = params[:div_id].to_i if params[:div_id] + @homepage = params[:homepage].to_i + @type = 'BlogComment' + comments = [] + @journals = get_all_children(comments, obj) when 'HomeworkCommon' obj = HomeworkCommon.where('id = ?', params[:id].to_i).first @journals = obj.journals_for_messages.reorder("created_on desc") diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 23fd401fd..1306d5625 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3141,13 +3141,18 @@ end #获取所有子节点 def get_all_children result, jour - if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) + if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message) || (jour.kind_of? BlogComment) || (jour.kind_of? OrgDocumentComment) jour.children.each do |jour_child| result << jour_child get_all_children result, jour_child end end - result.sort! { |a,b| b.created_on <=> a.created_on } + if jour.respond_to?(:created_on) + result.sort! { |a,b| b.created_on <=> a.created_on } + elsif jour.respond_to?(:created_at) + result.sort! { |a,b| b.created_at <=> a.created_at } + end + result end #将有置顶属性的提到数组前面 @@ -3296,6 +3301,14 @@ def strip_html(text,len=0,endss="...") return ss end +def message_content content + content = (strip_html content).strip + if content.gsub(" ", "") == "" + content = "[非文本消息]" + end + content +end + def get_hw_index(hw,is_teacher) if is_teacher homeworks = hw.course.homework_commons.order("created_at asc") diff --git a/app/models/user.rb b/app/models/user.rb index daf1237cf..996aa9be7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1148,17 +1148,17 @@ class User < Principal #为新注册用户发送留言 def add_new_jour - if Message.where("id=19278").any? and Message.where("id=19291").any? and Message.where("id=19292").any? - lead_message1 = Message.find(19278) + if Message.where("id=19504").any? and Message.where("id=19291").any? and Message.where("id=19292").any? + lead_message1 = Message.find(19292) notes1 = lead_message1.content - # lead_message2 = Message.find(19292) - # notes2 = lead_message2.content - # lead_message3 = Message.find(19291) - # notes3 = lead_message3.content - # # user_id 默认为课程使者创建 + lead_message2 = Message.find(19291) + notes2 = lead_message2.content + lead_message3 = Message.find(19504) + notes3 = lead_message3.content + #user_id 默认为课程使者创建 self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes1, :reply_id => 0, :status => true, :is_readed => false, :private => 0) - # self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0) - # self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0) + self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes2, :reply_id => 0, :status => true, :is_readed => false, :private => 0) + self.journals_for_messages << JournalsForMessage.new(:user_id => 1, :notes => notes3, :reply_id => 0, :status => true, :is_readed => false, :private => 0) end end diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 23acabd1f..cfe9cd695 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -62,7 +62,7 @@ }); $mail.blur(function (event) { - if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ + if (/^[a-zA-Z0-9]+([._\\]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(this.value) == false){ $('#mail_req').html( '邮件格式不对').show(); $mail_correct = false; return ; diff --git a/app/views/admin/_rename_syllabus_title.html.erb b/app/views/admin/_rename_syllabus_title.html.erb new file mode 100644 index 000000000..e3a175215 --- /dev/null +++ b/app/views/admin/_rename_syllabus_title.html.erb @@ -0,0 +1,3 @@ + + <%= syllabus.title %> + \ No newline at end of file diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb index 782f6b01c..194091abc 100644 --- a/app/views/admin/syllabuses.html.erb +++ b/app/views/admin/syllabuses.html.erb @@ -46,10 +46,8 @@
#{@org_comment.content.html_safe}
@@ -83,23 +76,6 @@ <%= render :partial => 'issues/attributes' %>
- - - - - <%#= link_to "", -# {:controller => 'watchers', :action => 'new', :project_id => @issue.project}, -# :remote => true, -# :method => 'get', - :class => "pic_sch mt5 ml5" %> - - <%#= javascript_tag "observeSearchfield('user_search', 'users_for_watcher', '#{ escape_javascript watchers_autocomplete_for_user_path(:user => @available_watchers, :format => 'js', :flag => 'ture') }')" %> - - - - - - <%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> <% end %> 确定 diff --git a/app/views/issues/_issue_replies.html.erb b/app/views/issues/_issue_replies.html.erb index 7b5383c1e..c120ca1b9 100644 --- a/app/views/issues/_issue_replies.html.erb +++ b/app/views/issues/_issue_replies.html.erb @@ -42,7 +42,6 @@ l(:button_delete), {:controller => 'issues',:action => 'delete_journal', :id => issue.id,:journal_id=>reply.id}, :method => :get, - :remote=>true, :class => 'fr newsGrey mr10', :data => {:confirm => l(:text_are_you_sure)}, :title => l(:button_delete) @@ -73,9 +72,9 @@