diff --git a/app/assets/javascripts/training_tasks.js.coffee b/app/assets/javascripts/training_tasks.js.coffee index 761567942..b3f5f376b 100644 --- a/app/assets/javascripts/training_tasks.js.coffee +++ b/app/assets/javascripts/training_tasks.js.coffee @@ -1,3 +1,3 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/training_tasks.css.scss b/app/assets/stylesheets/training_tasks.css.scss index 8a97abb85..5a071ec72 100644 --- a/app/assets/stylesheets/training_tasks.css.scss +++ b/app/assets/stylesheets/training_tasks.css.scss @@ -1,3 +1,3 @@ -// Place all the styles related to the training_tasks controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +// Place all the styles related to the training_tasks controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 6e91035d0..9d8a5ecc5 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -42,7 +42,7 @@ class AccountController < ApplicationController redirect_to user_path(User.current) end else - render :layout => 'login' + render :layout => 'login' end else authenticate_user diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ece68733b..c2499e824 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -783,8 +783,8 @@ class AdminController < ApplicationController begin #更新消息表的status applied_message_id = aas.school_id - applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") - applied_message.update_all(:status => 2) + #applied_message = AppliedMessage.where(:applied_id => applied_message_id, :applied_type => "ApplyAddSchools") + #applied_message.update_all(:status => 2) aas.update_attribute(:status, 2) AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name ) users = UserExtensions.where("school_id = #{aas.school_id}") diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index b2dd971bb..88d4c4d53 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -39,6 +39,9 @@ class BlogCommentsController < ApplicationController end end def show + # 更新博客消息为已读 + update_messsages_to_viewed("BlogMessage", params[:blog_id]) + @article = BlogComment.find(params[:id]) @replies = BlogComment.where("root_id = #{@article.id}").reorder("created_on desc") @reply_count = @replies.count diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index e6fb49ec7..30072bc2d 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -7,7 +7,8 @@ class ContestsController < ApplicationController helper :attachments helper :files include AvatarHelper - + include ApplicationHelper + before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :private_or_public, :switch_role, :set_invite_code_halt, :renew, :member, :export_all_members, :feedback] before_filter :is_logged, :only => [:index, :new, :create] @@ -18,8 +19,7 @@ class ContestsController < ApplicationController def show #更新创建课程消息状态 - contest_request_messages = ContestMessage.where("user_id = #{User.current.id} and contest_id = #{@contest.id} and contest_message_type in ('ContestRequestDealResult', 'JoinContest', 'RemoveFromContest') and viewed = 0") - contest_request_messages.update_all(:viewed => true) + update_messsages_to_viewed("ContestMessage", @contest) @left_nav_type = 1 respond_to do |format| diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 2f47fb808..b5b405d02 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -9,6 +9,7 @@ class CoursesController < ApplicationController helper :attachments helper :files helper :activity_notifys + include ApplicationHelper before_filter :auth_login1, :only => [:show, :course_activity, :feedback] menu_item :overview @@ -354,6 +355,44 @@ class CoursesController < ApplicationController #search_group_members group end + def change_manager + if params[:chooseteacher] + man_member = Member.where(:course_id => @course.id, :user_id => @course.tea_id).first + cha_member = Member.find params[:chooseteacher] + if man_member && cha_member + cha_member.member_roles.where("role_id = 9 || role_id = 7").first.update_attributes(:role_id => 3, :is_current => 1) + if cha_member.member_roles.where("role_id = 10").count > 0 + cha_member.member_roles.where("role_id = 10").first.destroy + StudentsForCourse.where(:course_id => @course.id, :student_id => cha_member.user_id).destroy_all + end + @course.update_attributes(:tea_id => cha_member.user_id) + man_member.member_roles.first.update_attributes(:role_id => 9) + course_act = CourseActivity.where(:course_id => @course.id, :course_act_id => @course.id, :course_act_type => 'Course').first + course_act.update_column('user_id', cha_member.user_id) + UserActivity.where(:act_id => @course.id, :container_type => 'Course', :act_type => 'Course', :container_id => @course.id).first.update_column('user_id', cha_member.user_id) + ws = WechatService.new + title = "您已成为班级管理员" + ws.create_class_notice cha_member.user_id, "create_course_notice", @course.id,title, @course.name, man_member.user.show_name, @course.members.count, "点击查看班级详情。" + end + end + end + + def search_course_teacher_list + q = params[:search] ? "#{params[:search].strip}" : "" + @members = searchTeacherAndAssistantNoManager(@course) + if q.nil? || q == "" + else + members = [] + @members.each do |m| + username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase + if m && m.user && (m.user[:login].to_s.downcase.include?(q) || m.user[:mail].to_s.downcase.include?(q) || username.include?(q)) + members << m + end + end + @members = members + end + end + #查找未分班的学生 def search_not_group_member @group = CourseGroup.find params[:group_id] @@ -454,6 +493,8 @@ class CoursesController < ApplicationController end def member + # 当前用户查看班级消息时,设置消息为已读 + update_messsages_to_viewed("CourseMessage", @course) ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) @render_file = 'new_member_list' @@ -1388,11 +1429,19 @@ class CoursesController < ApplicationController @members = @course.course_homework_statisticss.reorder("#{@type} #{@order}, total_score #{@order}") elsif params[:tab] == "3" + @homework_id = params[:homework_id] ? params[:homework_id].to_i : 0 @type = params[:type] ? params[:type] : 'project_act_score' - sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score, + if @homework_id == 0 + sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score, changeset_num, issue_num, issue_journal_num, attach_num, board_num, board_message_num, pss.project_id FROM project_scores pss JOIN student_work_projects ON student_work_projects.project_id = pss.project_id AND student_work_projects.course_id = #{@course.id} GROUP BY pss.project_id ORDER BY #{@type} #{@order}, project_act_score #{@order}" + else + sql = "SELECT (IFNULL(changeset_num, 0)*4 + issue_num*4 + issue_journal_num*1 + attach_num*5 + board_num*2 + board_message_num*1) AS project_act_score, + changeset_num, issue_num, issue_journal_num, attach_num, board_num, board_message_num, pss.project_id FROM project_scores pss + JOIN student_work_projects ON student_work_projects.project_id = pss.project_id AND student_work_projects.course_id = #{@course.id} AND student_work_projects.homework_common_id = #{@homework_id} + GROUP BY pss.project_id ORDER BY #{@type} #{@order}, project_act_score #{@order}" + end @members = ProjectScore.find_by_sql(sql) end diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index d5511cb44..7d6539e8d 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -150,6 +150,7 @@ class HomeworkCommonController < ApplicationController end elsif @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 homework_detail_manual.comment_status = 1 + create_works_list @homework status = true #更新CourseHomeworkStatistics中每个学生的未交作品数 @homework.course.student.each do |student| diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index 136915bbd..a60b85b90 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -1,168 +1,168 @@ -class PraiseTreadController < ApplicationController - - accept_api_auth :tread_plus,:praise_plus - # before_filter :require_login,:only => [:praise_plus,:tread_plus] - before_filter :user_unlogged_check,:only => [:praise_plus,:tread_plus,:praise_minus] - - def praise_plus - @obj = nil - @activity = false - if request.get? - @obj_id = params[:obj_id] - @obj_type = params[:obj_type] - if !params[:user_activity_id].nil? && !params[:type].nil? - @user_activity_id = params[:user_activity_id] - @type = params[:type] - @activity = true - end - # @is_in_list = nil - @obj = find_object_by_type_and_id(@obj_type,@obj_id) - pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id) - unless pts.empty? - respond_to do |format| - format.js - end - return - end - @horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal] - # if @obj.respond_to?("author_id") - # author_id = @obj.author_id - # elsif @obj.respond_to?("user_id") - # author_id = @obj.user_id - # end - # unless author_id == User.current.id - praise_tread_plus(@obj_type,@obj_id,1) - # end - respond_to do |format| - format.js - end - end - end - - def praise_minus - @obj = nil - @activity = false - if request.get? - #@obj = params[:obj] # 传的是对象,最后变成id了 - #首先更新praise_tread 表 删除关注记录 - #@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user") - @obj_id = params[:obj_id] - @obj_type = params[:obj_type] - if !params[:user_activity_id].nil? && !params[:type].nil? - @user_activity_id = params[:user_activity_id] - @type = params[:type] - @activity = true - end - @obj = find_object_by_type_and_id(@obj_type,@obj_id) - @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first - if @pt.nil? - respond_to do |format| - format.js - end - return - end - @pt.delete if !@pt.nil? - #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 - @ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first - @ptc.minus(1) if !@ptc.nil? - if @ptc.praise_num == 0 - @ptc.delete - end - - end - #@obj = User.find_by_id(@obj) - respond_to do |format| - format.js - end - end - - def tread_plus - @obj = nil - # @is_in_list = nil - if request.get? - @obj_id = params[:obj_id] - @obj_type = params[:obj_type] - #@horizontal = params[:horizontal].downcase == "false" ? false:true - @obj = find_object_by_type_and_id(@obj_type,@obj_id) - unless @obj.author_id == User.current.id - praise_tread_plus(@obj_type,@obj_id,0) - end - - end - end - - def tread_minus - respond_to do |format| - format.html - format.js - end - end - - private - - def find_object_by_type_and_id(type,id) - @obj = nil - case type - when 'Memo' - @obj = Memo.find_by_id(id) - when 'Message' - @obj = Message.find_by_id(id) - when 'HomeworkCommon' - @obj = HomeworkCommon.find_by_id(id) - when 'JournalsForMessage' - @obj = JournalsForMessage.find_by_id(id) - when 'News' - @obj = News.find_by_id(id) - when 'Comment' - @obj = Comment.find_by_id(id) - when 'Journal' - @obj = Journal.find_by_id(id) - when 'BlogComment' - @obj = BlogComment.find_by_id(id) - when 'OrgDocumentComment' - @obj = OrgDocumentComment.find_by_id(id) - when 'User' - @obj = User.find_by_id(id) - when 'Issue' - @obj = Issue.find_by_id(id) - when 'TrainingTask' - @obj = TrainingTask.find_by_id(id) - when 'Project' - @obj = Project.find_by_id(id) - when 'Bid' - @obj = Bid.find_by_id(id) - when 'Contest' - @obj = Contest.find_by_id(id) - when 'Syllabus' - @obj = Syllabus.find_by_id(id) - when 'Work' - @obj = Work.find_by_id(id) - else - @obj = nil - end - return @obj - end - - def praise_tread_plus(type,id,flag) - unless id.nil? and type.nil? - #首先创建或更新praise_tread 表 - @pt = PraiseTread.new - @pt.user_id = User.current.id - @pt.praise_tread_object_id = id.to_i - @pt.praise_tread_object_type = type - @pt.praise_or_tread = flag - @pt.save - # end - - #再创建或更新praise_tread_cache表 - #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) - @ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first - @ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc - @ptc.object_id = id.to_i - @ptc.object_type = type - @ptc.save - @ptc.plus(flag,1) - end - end - -end +class PraiseTreadController < ApplicationController + + accept_api_auth :tread_plus,:praise_plus + # before_filter :require_login,:only => [:praise_plus,:tread_plus] + before_filter :user_unlogged_check,:only => [:praise_plus,:tread_plus,:praise_minus] + + def praise_plus + @obj = nil + @activity = false + if request.get? + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end + # @is_in_list = nil + @obj = find_object_by_type_and_id(@obj_type,@obj_id) + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id) + unless pts.empty? + respond_to do |format| + format.js + end + return + end + @horizontal = params[:horizontal].downcase == "false" ? false:true if params[:horizontal] + # if @obj.respond_to?("author_id") + # author_id = @obj.author_id + # elsif @obj.respond_to?("user_id") + # author_id = @obj.user_id + # end + # unless author_id == User.current.id + praise_tread_plus(@obj_type,@obj_id,1) + # end + respond_to do |format| + format.js + end + end + end + + def praise_minus + @obj = nil + @activity = false + if request.get? + #@obj = params[:obj] # 传的是对象,最后变成id了 + #首先更新praise_tread 表 删除关注记录 + #@pt = PraiseTread.find_by_user_id_and_praise_tread_object_id_and_praise_tread_object_type(User.current.id,@obj,"user") + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] + if !params[:user_activity_id].nil? && !params[:type].nil? + @user_activity_id = params[:user_activity_id] + @type = params[:type] + @activity = true + end + @obj = find_object_by_type_and_id(@obj_type,@obj_id) + @pt = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",@obj_id,@obj_type.to_s,User.current.id).first + if @pt.nil? + respond_to do |format| + format.js + end + return + end + @pt.delete if !@pt.nil? + #再更新praise_tread_cache表 使相应的记录减1 当为0时删除 + @ptc = PraiseTreadCache.where("object_id=? and object_type=?",@obj_id,@obj_type.to_s).first + @ptc.minus(1) if !@ptc.nil? + if @ptc.praise_num == 0 + @ptc.delete + end + + end + #@obj = User.find_by_id(@obj) + respond_to do |format| + format.js + end + end + + def tread_plus + @obj = nil + # @is_in_list = nil + if request.get? + @obj_id = params[:obj_id] + @obj_type = params[:obj_type] + #@horizontal = params[:horizontal].downcase == "false" ? false:true + @obj = find_object_by_type_and_id(@obj_type,@obj_id) + unless @obj.author_id == User.current.id + praise_tread_plus(@obj_type,@obj_id,0) + end + + end + end + + def tread_minus + respond_to do |format| + format.html + format.js + end + end + + private + + def find_object_by_type_and_id(type,id) + @obj = nil + case type + when 'Memo' + @obj = Memo.find_by_id(id) + when 'Message' + @obj = Message.find_by_id(id) + when 'HomeworkCommon' + @obj = HomeworkCommon.find_by_id(id) + when 'JournalsForMessage' + @obj = JournalsForMessage.find_by_id(id) + when 'News' + @obj = News.find_by_id(id) + when 'Comment' + @obj = Comment.find_by_id(id) + when 'Journal' + @obj = Journal.find_by_id(id) + when 'BlogComment' + @obj = BlogComment.find_by_id(id) + when 'OrgDocumentComment' + @obj = OrgDocumentComment.find_by_id(id) + when 'User' + @obj = User.find_by_id(id) + when 'Issue' + @obj = Issue.find_by_id(id) + when 'TrainingTask' + @obj = TrainingTask.find_by_id(id) + when 'Project' + @obj = Project.find_by_id(id) + when 'Bid' + @obj = Bid.find_by_id(id) + when 'Contest' + @obj = Contest.find_by_id(id) + when 'Syllabus' + @obj = Syllabus.find_by_id(id) + when 'Work' + @obj = Work.find_by_id(id) + else + @obj = nil + end + return @obj + end + + def praise_tread_plus(type,id,flag) + unless id.nil? and type.nil? + #首先创建或更新praise_tread 表 + @pt = PraiseTread.new + @pt.user_id = User.current.id + @pt.praise_tread_object_id = id.to_i + @pt.praise_tread_object_type = type + @pt.praise_or_tread = flag + @pt.save + # end + + #再创建或更新praise_tread_cache表 + #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) + @ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first + @ptc = @ptc.nil? ? PraiseTreadCache.new : @ptc + @ptc.object_id = id.to_i + @ptc.object_type = type + @ptc.save + @ptc.plus(flag,1) + end + end + +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cfe4a6cd8..f3f91d558 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -72,6 +72,7 @@ class ProjectsController < ApplicationController include UsersHelper ### added by william include ActsAsTaggableOn::TagsHelper + include ApplicationHelper # 仅仅为了转换Gitlab地址 def project_home @@ -575,7 +576,7 @@ class ProjectsController < ApplicationController if params[:message_id] message_invite(params[:message_id], params[:key]) end - update_message_status(User.current, @project) + update_messsages_to_viewed("ForgeMessage", @project) # params[:login]为邮箱邀请用户加入,主要功能: # 1、自动注册 # 2、加入项目、创建角色 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index c27eade85..8d70980c8 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1253,7 +1253,7 @@ class StudentWorkController < ApplicationController def appeal_anonymous_score @student_work_score = StudentWorksScore.where("id = #{params[:score_id].to_i}").first - @is_last = params[:is_last] + @is_last = params[:is_last] == "true" ? true : false if @student_work_score @student_work_score.update_column('appeal_status', 1) score_appeal = StudentWorksScoresAppeal.create(:user_id => User.current.id, :student_works_score_id => @student_work_score.id, :comment => params[:appeal][:comment], :appeal_status => 1) @@ -1274,8 +1274,8 @@ class StudentWorkController < ApplicationController def deal_appeal_score @student_work_score = StudentWorksScore.where("id = #{params[:score_id].to_i}").first - @is_last = params[:is_last] - if @student_work_score + @is_last = params[:is_last] == "true" ? true : false + if @student_work_score && @student_work_score.appeal_status == 1 @student_work_score.update_column('appeal_status', params[:status].to_i) score_appeal = @student_work_score.student_works_scores_appeal score_appeal.applied_messages.update_all(:status => params[:status].to_i == 2 ? 3 : (params[:status].to_i == 3 ? 1 : 2)) @@ -1306,11 +1306,11 @@ class StudentWorkController < ApplicationController CourseMessage.create(:user_id => @student_work_score.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id) CourseMessage.create(:user_id => score_appeal.user_id, :course_id => course.id, :viewed => false,:course_message_id=> score_appeal.id,:course_message_type=>'StudentWorksScoresAppeal',:status=>params[:status].to_i,:apply_result =>User.current.id) end - @homework = @student_work_score.student_work.homework_common - @is_teacher = User.current.allowed_to?(:as_teacher, course) || User.current.admin? - @work = @student_work_score.student_work - @is_group_leader = !@work.student_work_projects.empty? end + @homework = @student_work_score.student_work.homework_common + @is_teacher = User.current.allowed_to?(:as_teacher, course) || User.current.admin? + @work = @student_work_score.student_work + @is_group_leader = !@work.student_work_projects.empty? end def forbidden_anonymous_comment diff --git a/app/controllers/training_tasks_controller.rb b/app/controllers/training_tasks_controller.rb index 467701e2a..aa716cf5c 100644 --- a/app/controllers/training_tasks_controller.rb +++ b/app/controllers/training_tasks_controller.rb @@ -1,800 +1,800 @@ -# encoding: utf-8 -class TrainingTasksController < ApplicationController - - layout 'base_projects' - before_filter :allow_manager, :only => [] - before_filter :allow_members, :only => [:new, :create] - before_filter :build_new_task_from_params, :only => [:new, :create, :update_form] - before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task] - - # before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] - before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete] - # before_filter :authorize, :except => [:index, :show] - # before_filter :authorize, :except => [:new, :index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue, :issue_commit_delete] - - before_filter :check_for_default_issue_status, :only => [:new, :create] - before_filter :build_new_task_from_params, :only => [:new, :create, :update_form] - accept_rss_auth :index, :show - accept_api_auth :index, :show, :create, :update, :destroy - - rescue_from Query::StatementInvalid, :with => :query_statement_invalid - - helper :journals - helper :projects - include ProjectsHelper - helper :custom_fields - include CustomFieldsHelper - helper :issue_relations - include IssueRelationsHelper - helper :watchers - include WatchersHelper - helper :attachments - include AttachmentsHelper - helper :queries - include QueriesHelper - helper :repositories - include RepositoriesHelper - helper :sort - include SortHelper - include IssuesHelper - helper :timelog - include Redmine::Export::PDF - helper :project_score - include ApplicationHelper - - def issue_commit_delete - commit_id = params[:commit_id].split(",") - issue_commit_ids = params[:issue_commit_ids] - # issue_id存在则为issue详情或者编辑的时候,否则为新建Issue - # 编辑和详情的时候需要在数据库中删除记录,新建的时候在内存中删除 - if params[:issue_id] - commit_issue = CommitIssues.where(:commit_id => commit_id, :issue_id => params[:issue_id], :project_id => @project.id).first - commit_issue.delete if commit_issue - end - @issue_commit_ids = issue_commit_ids - commit_id - end - # over - - def index - # 顶部导航 - @project_menu_type = 11 - @training_tasks = TrainingTask.where(:project_id => @project.id).order('updated_at desc') - @training_tasks_count = @training_tasks.count - @limit = 10 - @is_remote = true - @training_tasks_pages = Paginator.new @training_tasks_count, @limit, params['page'] || 1 - @offset ||= @training_tasks_pages.offset - @training_tasks = paginateHelper @training_tasks, @limit - respond_to do |format| - format.js - format.html - end - rescue ActiveRecord::RecordNotFound - render_404 - end - - def show - # 顶部导航 - @project_menu_type = 11 - # 打开编辑内容 - @is_edit = true unless params[:edit].nil? - @jour_reply = Journal.new - @journals = @training_task.journals.includes(:user, :details).reorder("#{Journal.table_name}.id desc").all - @journals = get_no_children_comments_all @journals - @journals.each_with_index {|j,i| j.indice = i+1} - @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @training_task.project) - @journals.reverse! if User.current.wants_comments_in_reverse_order? - @journal = Journal.new(:journalized => @training_task) - respond_to do |format| - format.html - end - end - - # Add a new issue - # The new issue will be created from an existing one if copy_from parameter is given - def new - # 顶部导航 - @project_menu_type = 11 - respond_to do |format| - format.html { render :action => 'new', :layout => 'base_projects' } - end - end - - # 用户发布新任务 - def create - @training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads])) - @training_task.subject = params[:training_task][:subject] - @training_task.description = params[:training_task][:description] - @training_task.tracker_id = params[:training_task][:tracker_id] - if @training_task.save - respond_to do |format| - format.html { - render_attachment_warning_if_needed(@training_task) - redirect_to training_task_url(@training_task) - } - end - return - else - respond_to do |format| - format.html { render :action => 'new' } - end - end - end - - def complete_training_task - taskId = @training_task.position - end - - def edit - # 修改实例变量的值 - return unless update_issue_from_params - # issue 关联的commit - commit_issues = CommitIssues.where(:issue_id => @issue.id, :project_id => @issue.project_id) - @issue_commit_ids = commit_issues.map{|commit_issue| commit_issue.commit_id} - - respond_to do |format| - format.html {render :layout => 'base_projects' }#added by young - format.xml { } - end - end - - # 用户编辑更改issue - def update - # params[:assigned_to_id] = nil if params[:assigned_to_id].to_i == 0 - # params[:fixed_version_id] = nil if params[:fixed_version_id].to_i == 0 - if params[:issue_detail] - issue = Issue.find(params[:id]) - issue = update_user_issue_detail(issue, params) - @saved = update_user_issue_detail(issue, params) - return - else - # 修改实例变量的值 - return unless update_issue_from_params - @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) - @issue.assigned_to_id = nil if @issue.assigned_to_id == 0 - @issue.fixed_version_id = nil if @issue.fixed_version_id == 0 - saved = false - begin - @saved = @issue.save_issue_with_child_records(params, @time_entry) - rescue ActiveRecord::StaleObjectError - @conflict = true - if params[:last_journal_id] - @conflict_journals = @issue.journals_after(params[:last_journal_id]).all - @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) - end - end - end - if @saved - # 更新commit关联情况 - update_issue_commit params[:commit_ids] - #修改界面增加跟踪者 - watcherlist = @issue.watcher_users - select_users = [] - if params[:issue] - if params[:issue][:watcher_user_ids] - params[:issue][:watcher_user_ids].each do |user_id| - select_users << User.find(user_id) - end - end - end - select_users.each do |user| - if watcherlist.include? user - else - @issue.add_watcher user - end - end - watcherlist.each do |user| - if select_users.include? user - else - @issue.remove_watcher user - end - end - - render_attachment_warning_if_needed(@issue) - reply_id = params[:reference_user_id].to_i - if reply_id > 0 - JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id) - end - #flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? 去掉这个notice,因为现在更新都是ajax操作 - respond_to do |format| - format.js - format.html { redirect_to issue_url(@issue.id) } - format.api { render_api_ok } - end - else - respond_to do |format| - - format.js - format.html { render :action => 'edit' } - format.api { render_validation_errors(@issue) } - end - end - end - - def update_user_issue_detail(issue, params) - case params[:type] - when "status" - issue.update_attribute(:status_id, params[:status_id]) - when "assigned" - issue.update_attribute(:assigned_to_id, params[:assigned_to_id]) - when "ratio" - issue.update_attribute(:done_ratio, params[:done_ratio]) - when "prior" - issue.update_attribute(:priority_id, params[:priority_id]) - end - end - - # Updates the issue form when changing the project, status or tracker - # on issue creation/update - def update_form - end - - # Bulk edit/copy a set of issues - def bulk_edit - @issues.sort! - @copy = params[:copy].present? - @notes = params[:notes] - - if User.current.allowed_to?(:move_issues, @projects) - @allowed_projects = Issue.allowed_target_projects_on_move - if params[:issue] - @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} - if @target_project - target_projects = [@target_project] - end - end - end - target_projects ||= @projects - - if @copy - @available_statuses = [IssueStatus.default] - else - @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) - end - @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&) - @assignables = target_projects.map(&:assignable_users).reduce(:&) - @trackers = target_projects.map(&:trackers).reduce(:&) - @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) - @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) - if @copy - @attachments_present = @issues.detect {|i| i.attachments.any?}.present? - @subtasks_present = @issues.detect {|i| !i.leaf?}.present? - end - - @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) - render :layout => false if request.xhr? - end - - def bulk_update - @issues.sort! - @copy = params[:copy].present? - attributes = parse_params_for_bulk_issue_attributes(params) - - unsaved_issue_ids = [] - moved_issues = [] - - if @copy && params[:copy_subtasks].present? - # Descendant issues will be copied with the parent task - # Don't copy them twice - @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}} - end - - @issues.each do |issue| - issue.reload - if @copy - issue = issue.copy({}, - :attachments => params[:copy_attachments].present?, - :subtasks => params[:copy_subtasks].present? - ) - end - journal = issue.init_journal(User.current, params[:notes]) - issue.safe_attributes = attributes - call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) - if issue.save - moved_issues << issue - else - # Keep unsaved issue ids to display them in flash error - unsaved_issue_ids << issue.id - end - end - set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) - - if params[:follow] - if @issues.size == 1 && moved_issues.size == 1 - redirect_to issue_url(moved_issues.first) - elsif moved_issues.map(&:project).uniq.size == 1 - redirect_to project_issues_url(moved_issues.map(&:project).first) - end - else - redirect_back_or_default _project_issues_path(@project) - end - end - - def destroy - # 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉 - page_classify = params[:page_classify] unless params[:page_classify].nil? - page_id = params[:page_id] unless params[:page_id].nil? - @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f - if @hours > 0 - case params[:todo] - when 'destroy' - # nothing to do - when 'nullify' - TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) - when 'reassign' - reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) - if reassign_to.nil? - flash.now[:error] = l(:error_issue_not_found_in_project) - return - else - TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) - end - else - # display the destroy form if it's a user request - return unless api_request? - end - end - @issues.each do |issue| - begin - issue.reload.destroy - rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists - # nothing to do, issue was already deleted (eg. by a parent) - end - end - respond_to do |format| - if page_classify - format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) } - else - format.html { redirect_back_or_default _project_issues_path(@project) } - end - format.api { render_api_ok } - end - end - - 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 - 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] - @priorities = IssuePriority.active - - respond_to do |format| - # Issue详情单独处理 - if params[:is_issue_show] - format.js{redirect_to issue_path(@issue)} - else - format.js - end - end - end - end - - def add_journal_in_org - if User.current.logged? - jour = Journal.new - jour.user_id = User.current.id - jour.notes = params[:notes] - jour.journalized = @issue - jour.save - org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first - org_activity.updated_at = jour.created_on - org_activity.save - @user_activity_id = params[:user_activity_id] - respond_to do |format| - format.js - end - end - end - - #对某个journ回复,显示回复框 - def reply - @issue = Issue.find(params[:id]) - @jour = Journal.find(params[:journal_id]) - respond_to do |format| - format.js - end - end - - #给issue添加journ。回复内容包含 对某个被回复的journ的内容 - def add_reply - if User.current.logged? - jour = Journal.find(params[:journal_id]) - @issue = Issue.find params[:id] - @project = @issue.project - @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - @priorities = IssuePriority.active - new_jour = Journal.new - new_jour.user_id = User.current.id - new_jour.reply_id = params[:journal_id] - new_jour.parent_id = jour.id - new_jour.notes = params[:content] - new_jour.journalized = @issue - new_jour.save_attachments(params[:attachments]) - # new_jour = @issue.journals.build(:user_id => User.current.id, :reply_id => params[:journal_id], :notes => params[:content], :parent_id => jour.id) - @user_activity_id = params[:user_activity_id] - if new_jour.save - update_user_activity(@issue.class,@issue.id) - update_forge_activity(@issue.class,@issue.id) - respond_to do |format| - if params[:is_issue_show] - format.js{redirect_to issue_path(@issue)} - else - format.js - end - end - end - end - end - - # 需要刷新详情页面,代码同步一致 - # 获取project和issue状态是为了刷新页面 - # 值所以用delete是因为issue和journal在act_as_attachment中是同一个类型 - # 非动态页面直接刷新,动态页面手动刷新 - def delete_journal - @is_project = params[:is_project] - @issue = Issue.find(params[:id]) - begin - forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]) - forge_acts.destroy_all unless forge_acts.empty? - at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]) - at_message.destroy_all unless at_message.empty? - Journal.delete(params[:journal_id]) - rescue Exception => e - puts e - end - @user_activity_id = params[:user_activity_id] - respond_to do |format| - if @user_activity_id - format.js - else - format.js{ redirect_to issue_url(@issue)} - end - end - end - - def statistics - @project = Project.find(params[:id]) - params[:author_id].to_i != 0 ? (@author = User.find(params[:author_id].to_i).show_name) : @author = 0 - case params[:tracker_id].to_i - when 1 - @tracker = "缺陷" - when 2 - @tracker = "功能" - when 3 - @tracker = "支持" - when 4 - @tracker = "任务" - when 5 - @tracker = "周报" - when 0 - @tracker = 0 - end - params[:subject].blank? ? @search = 0 : @search = params[:subject] - params[:assigned_to_id].to_i != 0 ? (@assigned = User.find(params[:assigned_to_id].to_i).show_name) : @assigned = 0 - params[:fixed_version_id].to_i != 0 ? (@version = Version.find(params[:fixed_version_id].to_i).name) : @version = 0 - params[:done_ratio].to_i != -1 ? (@done = params[:done_ratio].to_i) : @done = -1 - case params[:priority_id].to_i - when 1 - @prior = "低" - when 2 - @prior = "正常" - when 3 - @prior = "高" - when 4 - @prior = "紧急" - when 5 - @prior = "立刻" - when 0 - @prior = 0 - end - case params[:status_id].to_i - when 1 - @status = "新增" - when 2 - @status = "正在解决" - when 3 - @status = "已解决" - when 4 - @status = "反馈" - when 5 - @status = "关闭" - when 6 - @status = "拒绝" - when 0 - @status = 0 - end - params[:issue_create_date_start].blank? ? @start_time = 0 : @start_time = params[:issue_create_date_start] - params[:issue_create_date_end].blank? ? @end_time = 0 : @end_time = params[:issue_create_date_end] - @filter_condition = true - @filter_condition = false if (@author == 0 && @tracker == 0 && @search == 0 && @assigned == 0 && @version == 0 && @done == -1 && @prior ==0 && @status == 0 && @start_time ==0 && @end_time) - if @project.nil? - render_404 - end - retrieve_query - sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) - sort_update(@query.sortable_columns) - @query.sort_criteria = sort_criteria.to_a - @project_base_tag = 'base_projects' - if @query.valid? - @tracker_id = params[:tracker_id] - @assign_to_id = params[:assigned_to_id] - @author_id = params[:author_id] - @priority_id = params[:priority_id] - @status_id = params[:status_id] - @subject = params[:subject] - @done_ratio = params[:done_ratio] - @fixed_version_id = params[:fixed_version_id] - @issue_count = @query.issue_count - @test = params[:test] - @project_sort = 'issues.updated_on desc' - if params[:test] != "0" - case @test - when "1" - @project_sort = 'issues.created_on desc' - when "2" - @project_sort = 'issues.created_on asc' - when "3" - @project_sort = 'issues.updated_on desc' - when "4" - @project_sort = 'issues.updated_on asc' - end - end - # 搜索结果 - # SELECT assigned_to_id, count(*) as ac FROM `issues` where project_id = @project.id group by assigned_to_id order by ac desc; - @issues_filter = @query.issues.sort_by{ |i| Issue.where(:project_id => @project.id , :assigned_to_id => i.assigned_to_id).count }.reverse - # @issues_filter = @query.issues(:order => @project_sort) - - # if params[:type] == 1 || params[:type].nil? - # @results = @issues_filter - # elsif params[:type] == "2" - # @results = @issues_filter.collect{|result| result.status_id !=5 } - # elsif params[:type] == "3" - # @results = @issues_filter.collect{|result| result.status_id !=5 } - # end - - #统计 - @results = {} - - #统计total - @alltotal = {} - for i in 0..5 do - @alltotal[i] = 0 - end - - @opentotal = {} - for i in 0..5 do - @opentotal[i] = 0 - end - - @closetotal = {} - for i in 0..5 do - @closetotal[i] = 0 - end - - #开启关闭 - @issue_open_count = 0 - @issue_close_count = 0 - - @issues_filter.each do |issue| - @alltotal[0] = @alltotal[0] + 1 - @alltotal[issue.tracker_id.to_i] = @alltotal[issue.tracker_id.to_i] + 1 - user_id = issue.assigned_to_id - if issue.assigned_to_id.nil? - user_id = 0 - end - - if !@results[user_id].nil? - @results[user_id][0] = @results[user_id][0] + 1 - @results[user_id][issue.tracker_id.to_i] = @results[user_id][issue.tracker_id.to_i] + 1 - - if issue.status_id.to_i == 5 - @issue_close_count = @issue_close_count + 1 - @results[user_id][12] = @results[user_id][12]+1 - @results[user_id][12+issue.tracker_id.to_i] = @results[user_id][12+issue.tracker_id.to_i]+1 - - @closetotal[0] = @closetotal[0] + 1 - @closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1 - else - @issue_open_count = @issue_open_count + 1 - @results[user_id][6] = @results[user_id][6]+1 - @results[user_id][6+issue.tracker_id.to_i] = @results[user_id][6+issue.tracker_id.to_i]+1 - - @opentotal[0] = @opentotal[0] + 1 - @opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1 - end - else - - @results[user_id] = {} - - tmpuser = User.find(user_id) - - @results[user_id][:name] = tmpuser.nil? ? "" : tmpuser.show_name - #所有的 - @results[user_id][0] = 1 - for i in 1..17 do - @results[user_id][i] = 0 - end - # @results[user_id][1] = 0 - # @results[user_id][2] = 0 - # @results[user_id][3] = 0 - # @results[user_id][4] = 0 - # @results[user_id][5] = 0 - @results[user_id][issue.tracker_id.to_i] = 1 - - #开启的 status_id = 12346 - # @results[user_id][6] = 0 - # @results[user_id][7] = 0 - # @results[user_id][8] = 0 - # @results[user_id][9] = 0 - # @results[user_id][10] = 0 - # @results[user_id][11] = 0 - - #关闭的 status_id = 5 - # @results[user_id][12] = 0 - # @results[user_id][13] = 0 - # @results[user_id][14] = 0 - # @results[user_id][15] = 0 - # @results[user_id][16] = 0 - # @results[user_id][17] = 0 - - if issue.status_id.to_i == 5 - @results[user_id][12] = 1 - @results[user_id][12+issue.tracker_id.to_i] = 1 - @issue_close_count = @issue_close_count+1 - - @closetotal[0] = @closetotal[0] + 1 - @closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1 - else - @issue_open_count = @issue_open_count+1 - @results[user_id][6] = 1 - @results[user_id][6+issue.tracker_id.to_i] = 1 - - @opentotal[0] = @opentotal[0] + 1 - @opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1 - end - - end - end - - respond_to do |format| - format.js - end - - else - render_404 - end - end - - private - - def find_project - project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id]) - @project = Project.find(project_id) - rescue ActiveRecord::RecordNotFound - render_404 - end - - def allow_members - if !(User.current.member_of?(@project) || User.current.admin?) - render_403 - end - end - - def retrieve_previous_and_next_issue_ids - retrieve_query_from_session - if @query - sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) - sort_update(@query.sortable_columns, 'issues_index_sort') - limit = 500 - issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) - if (idx = issue_ids.index(@issue.id)) && idx < limit - if issue_ids.size < 500 - @issue_position = idx + 1 - @issue_count = issue_ids.size - end - @prev_issue_id = issue_ids[idx - 1] if idx > 0 - @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) - end - end - end - - # Used by #edit and #update to set some common instance variables - # from the params - # TODO: Refactor, not everything in here is needed by #edit - def update_issue_from_params - @edit_allowed = User.current.allowed_to?(:edit_issues, @project) - @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) - @time_entry.attributes = params[:time_entry] - - # 更新issue状态时,journal表产生记录,返回@current_journal - @issue.init_journal(User.current) - issue_attributes = params[:issue] - if issue_attributes && params[:conflict_resolution] - case params[:conflict_resolution] - when 'overwrite' - issue_attributes = issue_attributes.dup - issue_attributes.delete(:lock_version) - when 'add_notes' - issue_attributes = issue_attributes.slice(:notes) - when 'cancel' - redirect_to issue_url(@issue) - return false - end - end - - if params[:action] == "update" - senduser = User.find(params[:issue][:assigned_to_id]) - if senduser.id != User.current.id && @issue.assigned_to_id != params[:issue][:assigned_to_id].to_i - issue_id = @issue.id - issue_title = params[:issue][:subject] - priority_id = params[:issue][:priority_id] - ps = ProjectsService.new - ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id - end - end - - @issue.safe_attributes = issue_attributes - @priorities = IssuePriority.active - @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - true - end - - # TODO: Refactor, lots of extra code in here - # TODO: Changing tracker on an existing issue should not trigger this - def build_new_task_from_params - if params[:id].blank? - @training_task = TrainingTask.new - @training_task.project = @project - else - @training_task = @project.training_tasks.visible.find(params[:id]) - end - - @training_task.project = @project - @training_task.author ||= User.current - # Tracker must be set before custom field values - @training_task.tracker ||= @project.trackers.find((params[:training_task] && params[:training_task][:tracker_id]) || params[:tracker_id] || :first) - if @training_task.tracker.nil? - render_error l(:error_no_tracker_in_project) - return false - end - end - - def check_for_default_issue_status - if IssueStatus.default.nil? - render_error l(:error_no_default_issue_status) - return false - end - end - - def parse_params_for_bulk_issue_attributes(params) - attributes = (params[:issue] || {}).reject {|k,v| v.blank?} - attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} - if custom = attributes[:custom_field_values] - custom.reject! {|k,v| v.blank?} - custom.keys.each do |k| - if custom[k].is_a?(Array) - custom[k] << '' if custom[k].delete('__none__') - else - custom[k] = '' if custom[k] == '__none__' - end - end - end - attributes - end - - # Find the issue whose id is the :id parameter - # Raises a Unauthorized exception if the issue is not visible - def find_training_task - @training_task = TrainingTask.find(params[:id]) - @project = @training_task.project - rescue ActiveRecord::RecordNotFound - render_404 - end -end +# encoding: utf-8 +class TrainingTasksController < ApplicationController + + layout 'base_projects' + before_filter :allow_manager, :only => [] + before_filter :allow_members, :only => [:new, :create] + before_filter :build_new_task_from_params, :only => [:new, :create, :update_form] + before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task] + + # before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] + before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete] + # before_filter :authorize, :except => [:index, :show] + # before_filter :authorize, :except => [:new, :index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue, :issue_commit_delete] + + before_filter :check_for_default_issue_status, :only => [:new, :create] + before_filter :build_new_task_from_params, :only => [:new, :create, :update_form] + accept_rss_auth :index, :show + accept_api_auth :index, :show, :create, :update, :destroy + + rescue_from Query::StatementInvalid, :with => :query_statement_invalid + + helper :journals + helper :projects + include ProjectsHelper + helper :custom_fields + include CustomFieldsHelper + helper :issue_relations + include IssueRelationsHelper + helper :watchers + include WatchersHelper + helper :attachments + include AttachmentsHelper + helper :queries + include QueriesHelper + helper :repositories + include RepositoriesHelper + helper :sort + include SortHelper + include IssuesHelper + helper :timelog + include Redmine::Export::PDF + helper :project_score + include ApplicationHelper + + def issue_commit_delete + commit_id = params[:commit_id].split(",") + issue_commit_ids = params[:issue_commit_ids] + # issue_id存在则为issue详情或者编辑的时候,否则为新建Issue + # 编辑和详情的时候需要在数据库中删除记录,新建的时候在内存中删除 + if params[:issue_id] + commit_issue = CommitIssues.where(:commit_id => commit_id, :issue_id => params[:issue_id], :project_id => @project.id).first + commit_issue.delete if commit_issue + end + @issue_commit_ids = issue_commit_ids - commit_id + end + # over + + def index + # 顶部导航 + @project_menu_type = 11 + @training_tasks = TrainingTask.where(:project_id => @project.id).order('updated_at desc') + @training_tasks_count = @training_tasks.count + @limit = 10 + @is_remote = true + @training_tasks_pages = Paginator.new @training_tasks_count, @limit, params['page'] || 1 + @offset ||= @training_tasks_pages.offset + @training_tasks = paginateHelper @training_tasks, @limit + respond_to do |format| + format.js + format.html + end + rescue ActiveRecord::RecordNotFound + render_404 + end + + def show + # 顶部导航 + @project_menu_type = 11 + # 打开编辑内容 + @is_edit = true unless params[:edit].nil? + @jour_reply = Journal.new + @journals = @training_task.journals.includes(:user, :details).reorder("#{Journal.table_name}.id desc").all + @journals = get_no_children_comments_all @journals + @journals.each_with_index {|j,i| j.indice = i+1} + @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @training_task.project) + @journals.reverse! if User.current.wants_comments_in_reverse_order? + @journal = Journal.new(:journalized => @training_task) + respond_to do |format| + format.html + end + end + + # Add a new issue + # The new issue will be created from an existing one if copy_from parameter is given + def new + # 顶部导航 + @project_menu_type = 11 + respond_to do |format| + format.html { render :action => 'new', :layout => 'base_projects' } + end + end + + # 用户发布新任务 + def create + @training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads])) + @training_task.subject = params[:training_task][:subject] + @training_task.description = params[:training_task][:description] + @training_task.tracker_id = params[:training_task][:tracker_id] + if @training_task.save + respond_to do |format| + format.html { + render_attachment_warning_if_needed(@training_task) + redirect_to training_task_url(@training_task) + } + end + return + else + respond_to do |format| + format.html { render :action => 'new' } + end + end + end + + def complete_training_task + taskId = @training_task.position + end + + def edit + # 修改实例变量的值 + return unless update_issue_from_params + # issue 关联的commit + commit_issues = CommitIssues.where(:issue_id => @issue.id, :project_id => @issue.project_id) + @issue_commit_ids = commit_issues.map{|commit_issue| commit_issue.commit_id} + + respond_to do |format| + format.html {render :layout => 'base_projects' }#added by young + format.xml { } + end + end + + # 用户编辑更改issue + def update + # params[:assigned_to_id] = nil if params[:assigned_to_id].to_i == 0 + # params[:fixed_version_id] = nil if params[:fixed_version_id].to_i == 0 + if params[:issue_detail] + issue = Issue.find(params[:id]) + issue = update_user_issue_detail(issue, params) + @saved = update_user_issue_detail(issue, params) + return + else + # 修改实例变量的值 + return unless update_issue_from_params + @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) + @issue.assigned_to_id = nil if @issue.assigned_to_id == 0 + @issue.fixed_version_id = nil if @issue.fixed_version_id == 0 + saved = false + begin + @saved = @issue.save_issue_with_child_records(params, @time_entry) + rescue ActiveRecord::StaleObjectError + @conflict = true + if params[:last_journal_id] + @conflict_journals = @issue.journals_after(params[:last_journal_id]).all + @conflict_journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) + end + end + end + if @saved + # 更新commit关联情况 + update_issue_commit params[:commit_ids] + #修改界面增加跟踪者 + watcherlist = @issue.watcher_users + select_users = [] + if params[:issue] + if params[:issue][:watcher_user_ids] + params[:issue][:watcher_user_ids].each do |user_id| + select_users << User.find(user_id) + end + end + end + select_users.each do |user| + if watcherlist.include? user + else + @issue.add_watcher user + end + end + watcherlist.each do |user| + if select_users.include? user + else + @issue.remove_watcher user + end + end + + render_attachment_warning_if_needed(@issue) + reply_id = params[:reference_user_id].to_i + if reply_id > 0 + JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id) + end + #flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? 去掉这个notice,因为现在更新都是ajax操作 + respond_to do |format| + format.js + format.html { redirect_to issue_url(@issue.id) } + format.api { render_api_ok } + end + else + respond_to do |format| + + format.js + format.html { render :action => 'edit' } + format.api { render_validation_errors(@issue) } + end + end + end + + def update_user_issue_detail(issue, params) + case params[:type] + when "status" + issue.update_attribute(:status_id, params[:status_id]) + when "assigned" + issue.update_attribute(:assigned_to_id, params[:assigned_to_id]) + when "ratio" + issue.update_attribute(:done_ratio, params[:done_ratio]) + when "prior" + issue.update_attribute(:priority_id, params[:priority_id]) + end + end + + # Updates the issue form when changing the project, status or tracker + # on issue creation/update + def update_form + end + + # Bulk edit/copy a set of issues + def bulk_edit + @issues.sort! + @copy = params[:copy].present? + @notes = params[:notes] + + if User.current.allowed_to?(:move_issues, @projects) + @allowed_projects = Issue.allowed_target_projects_on_move + if params[:issue] + @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s} + if @target_project + target_projects = [@target_project] + end + end + end + target_projects ||= @projects + + if @copy + @available_statuses = [IssueStatus.default] + else + @available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) + end + @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&) + @assignables = target_projects.map(&:assignable_users).reduce(:&) + @trackers = target_projects.map(&:trackers).reduce(:&) + @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&) + @categories = target_projects.map {|p| p.issue_categories}.reduce(:&) + if @copy + @attachments_present = @issues.detect {|i| i.attachments.any?}.present? + @subtasks_present = @issues.detect {|i| !i.leaf?}.present? + end + + @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) + render :layout => false if request.xhr? + end + + def bulk_update + @issues.sort! + @copy = params[:copy].present? + attributes = parse_params_for_bulk_issue_attributes(params) + + unsaved_issue_ids = [] + moved_issues = [] + + if @copy && params[:copy_subtasks].present? + # Descendant issues will be copied with the parent task + # Don't copy them twice + @issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}} + end + + @issues.each do |issue| + issue.reload + if @copy + issue = issue.copy({}, + :attachments => params[:copy_attachments].present?, + :subtasks => params[:copy_subtasks].present? + ) + end + journal = issue.init_journal(User.current, params[:notes]) + issue.safe_attributes = attributes + call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) + if issue.save + moved_issues << issue + else + # Keep unsaved issue ids to display them in flash error + unsaved_issue_ids << issue.id + end + end + set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) + + if params[:follow] + if @issues.size == 1 && moved_issues.size == 1 + redirect_to issue_url(moved_issues.first) + elsif moved_issues.map(&:project).uniq.size == 1 + redirect_to project_issues_url(moved_issues.map(&:project).first) + end + else + redirect_back_or_default _project_issues_path(@project) + end + end + + def destroy + # 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉 + page_classify = params[:page_classify] unless params[:page_classify].nil? + page_id = params[:page_id] unless params[:page_id].nil? + @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f + if @hours > 0 + case params[:todo] + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end + else + # display the destroy form if it's a user request + return unless api_request? + end + end + @issues.each do |issue| + begin + issue.reload.destroy + rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists + # nothing to do, issue was already deleted (eg. by a parent) + end + end + respond_to do |format| + if page_classify + format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) } + else + format.html { redirect_back_or_default _project_issues_path(@project) } + end + format.api { render_api_ok } + end + end + + 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 + 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] + @priorities = IssuePriority.active + + respond_to do |format| + # Issue详情单独处理 + if params[:is_issue_show] + format.js{redirect_to issue_path(@issue)} + else + format.js + end + end + end + end + + def add_journal_in_org + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first + org_activity.updated_at = jour.created_on + org_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + + #对某个journ回复,显示回复框 + def reply + @issue = Issue.find(params[:id]) + @jour = Journal.find(params[:journal_id]) + respond_to do |format| + format.js + end + end + + #给issue添加journ。回复内容包含 对某个被回复的journ的内容 + def add_reply + if User.current.logged? + jour = Journal.find(params[:journal_id]) + @issue = Issue.find params[:id] + @project = @issue.project + @allowed_statuses = @issue.new_statuses_allowed_to(User.current) + @priorities = IssuePriority.active + new_jour = Journal.new + new_jour.user_id = User.current.id + new_jour.reply_id = params[:journal_id] + new_jour.parent_id = jour.id + new_jour.notes = params[:content] + new_jour.journalized = @issue + new_jour.save_attachments(params[:attachments]) + # new_jour = @issue.journals.build(:user_id => User.current.id, :reply_id => params[:journal_id], :notes => params[:content], :parent_id => jour.id) + @user_activity_id = params[:user_activity_id] + if new_jour.save + update_user_activity(@issue.class,@issue.id) + update_forge_activity(@issue.class,@issue.id) + respond_to do |format| + if params[:is_issue_show] + format.js{redirect_to issue_path(@issue)} + else + format.js + end + end + end + end + end + + # 需要刷新详情页面,代码同步一致 + # 获取project和issue状态是为了刷新页面 + # 值所以用delete是因为issue和journal在act_as_attachment中是同一个类型 + # 非动态页面直接刷新,动态页面手动刷新 + def delete_journal + @is_project = params[:is_project] + @issue = Issue.find(params[:id]) + begin + forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]) + forge_acts.destroy_all unless forge_acts.empty? + at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]) + at_message.destroy_all unless at_message.empty? + Journal.delete(params[:journal_id]) + rescue Exception => e + puts e + end + @user_activity_id = params[:user_activity_id] + respond_to do |format| + if @user_activity_id + format.js + else + format.js{ redirect_to issue_url(@issue)} + end + end + end + + def statistics + @project = Project.find(params[:id]) + params[:author_id].to_i != 0 ? (@author = User.find(params[:author_id].to_i).show_name) : @author = 0 + case params[:tracker_id].to_i + when 1 + @tracker = "缺陷" + when 2 + @tracker = "功能" + when 3 + @tracker = "支持" + when 4 + @tracker = "任务" + when 5 + @tracker = "周报" + when 0 + @tracker = 0 + end + params[:subject].blank? ? @search = 0 : @search = params[:subject] + params[:assigned_to_id].to_i != 0 ? (@assigned = User.find(params[:assigned_to_id].to_i).show_name) : @assigned = 0 + params[:fixed_version_id].to_i != 0 ? (@version = Version.find(params[:fixed_version_id].to_i).name) : @version = 0 + params[:done_ratio].to_i != -1 ? (@done = params[:done_ratio].to_i) : @done = -1 + case params[:priority_id].to_i + when 1 + @prior = "低" + when 2 + @prior = "正常" + when 3 + @prior = "高" + when 4 + @prior = "紧急" + when 5 + @prior = "立刻" + when 0 + @prior = 0 + end + case params[:status_id].to_i + when 1 + @status = "新增" + when 2 + @status = "正在解决" + when 3 + @status = "已解决" + when 4 + @status = "反馈" + when 5 + @status = "关闭" + when 6 + @status = "拒绝" + when 0 + @status = 0 + end + params[:issue_create_date_start].blank? ? @start_time = 0 : @start_time = params[:issue_create_date_start] + params[:issue_create_date_end].blank? ? @end_time = 0 : @end_time = params[:issue_create_date_end] + @filter_condition = true + @filter_condition = false if (@author == 0 && @tracker == 0 && @search == 0 && @assigned == 0 && @version == 0 && @done == -1 && @prior ==0 && @status == 0 && @start_time ==0 && @end_time) + if @project.nil? + render_404 + end + retrieve_query + sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) + sort_update(@query.sortable_columns) + @query.sort_criteria = sort_criteria.to_a + @project_base_tag = 'base_projects' + if @query.valid? + @tracker_id = params[:tracker_id] + @assign_to_id = params[:assigned_to_id] + @author_id = params[:author_id] + @priority_id = params[:priority_id] + @status_id = params[:status_id] + @subject = params[:subject] + @done_ratio = params[:done_ratio] + @fixed_version_id = params[:fixed_version_id] + @issue_count = @query.issue_count + @test = params[:test] + @project_sort = 'issues.updated_on desc' + if params[:test] != "0" + case @test + when "1" + @project_sort = 'issues.created_on desc' + when "2" + @project_sort = 'issues.created_on asc' + when "3" + @project_sort = 'issues.updated_on desc' + when "4" + @project_sort = 'issues.updated_on asc' + end + end + # 搜索结果 + # SELECT assigned_to_id, count(*) as ac FROM `issues` where project_id = @project.id group by assigned_to_id order by ac desc; + @issues_filter = @query.issues.sort_by{ |i| Issue.where(:project_id => @project.id , :assigned_to_id => i.assigned_to_id).count }.reverse + # @issues_filter = @query.issues(:order => @project_sort) + + # if params[:type] == 1 || params[:type].nil? + # @results = @issues_filter + # elsif params[:type] == "2" + # @results = @issues_filter.collect{|result| result.status_id !=5 } + # elsif params[:type] == "3" + # @results = @issues_filter.collect{|result| result.status_id !=5 } + # end + + #统计 + @results = {} + + #统计total + @alltotal = {} + for i in 0..5 do + @alltotal[i] = 0 + end + + @opentotal = {} + for i in 0..5 do + @opentotal[i] = 0 + end + + @closetotal = {} + for i in 0..5 do + @closetotal[i] = 0 + end + + #开启关闭 + @issue_open_count = 0 + @issue_close_count = 0 + + @issues_filter.each do |issue| + @alltotal[0] = @alltotal[0] + 1 + @alltotal[issue.tracker_id.to_i] = @alltotal[issue.tracker_id.to_i] + 1 + user_id = issue.assigned_to_id + if issue.assigned_to_id.nil? + user_id = 0 + end + + if !@results[user_id].nil? + @results[user_id][0] = @results[user_id][0] + 1 + @results[user_id][issue.tracker_id.to_i] = @results[user_id][issue.tracker_id.to_i] + 1 + + if issue.status_id.to_i == 5 + @issue_close_count = @issue_close_count + 1 + @results[user_id][12] = @results[user_id][12]+1 + @results[user_id][12+issue.tracker_id.to_i] = @results[user_id][12+issue.tracker_id.to_i]+1 + + @closetotal[0] = @closetotal[0] + 1 + @closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1 + else + @issue_open_count = @issue_open_count + 1 + @results[user_id][6] = @results[user_id][6]+1 + @results[user_id][6+issue.tracker_id.to_i] = @results[user_id][6+issue.tracker_id.to_i]+1 + + @opentotal[0] = @opentotal[0] + 1 + @opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1 + end + else + + @results[user_id] = {} + + tmpuser = User.find(user_id) + + @results[user_id][:name] = tmpuser.nil? ? "" : tmpuser.show_name + #所有的 + @results[user_id][0] = 1 + for i in 1..17 do + @results[user_id][i] = 0 + end + # @results[user_id][1] = 0 + # @results[user_id][2] = 0 + # @results[user_id][3] = 0 + # @results[user_id][4] = 0 + # @results[user_id][5] = 0 + @results[user_id][issue.tracker_id.to_i] = 1 + + #开启的 status_id = 12346 + # @results[user_id][6] = 0 + # @results[user_id][7] = 0 + # @results[user_id][8] = 0 + # @results[user_id][9] = 0 + # @results[user_id][10] = 0 + # @results[user_id][11] = 0 + + #关闭的 status_id = 5 + # @results[user_id][12] = 0 + # @results[user_id][13] = 0 + # @results[user_id][14] = 0 + # @results[user_id][15] = 0 + # @results[user_id][16] = 0 + # @results[user_id][17] = 0 + + if issue.status_id.to_i == 5 + @results[user_id][12] = 1 + @results[user_id][12+issue.tracker_id.to_i] = 1 + @issue_close_count = @issue_close_count+1 + + @closetotal[0] = @closetotal[0] + 1 + @closetotal[issue.tracker_id.to_i] = @closetotal[issue.tracker_id.to_i] + 1 + else + @issue_open_count = @issue_open_count+1 + @results[user_id][6] = 1 + @results[user_id][6+issue.tracker_id.to_i] = 1 + + @opentotal[0] = @opentotal[0] + 1 + @opentotal[issue.tracker_id.to_i] = @opentotal[issue.tracker_id.to_i] + 1 + end + + end + end + + respond_to do |format| + format.js + end + + else + render_404 + end + end + + private + + def find_project + project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id]) + @project = Project.find(project_id) + rescue ActiveRecord::RecordNotFound + render_404 + end + + def allow_members + if !(User.current.member_of?(@project) || User.current.admin?) + render_403 + end + end + + def retrieve_previous_and_next_issue_ids + retrieve_query_from_session + if @query + sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) + sort_update(@query.sortable_columns, 'issues_index_sort') + limit = 500 + issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version]) + if (idx = issue_ids.index(@issue.id)) && idx < limit + if issue_ids.size < 500 + @issue_position = idx + 1 + @issue_count = issue_ids.size + end + @prev_issue_id = issue_ids[idx - 1] if idx > 0 + @next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1) + end + end + end + + # Used by #edit and #update to set some common instance variables + # from the params + # TODO: Refactor, not everything in here is needed by #edit + def update_issue_from_params + @edit_allowed = User.current.allowed_to?(:edit_issues, @project) + @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) + @time_entry.attributes = params[:time_entry] + + # 更新issue状态时,journal表产生记录,返回@current_journal + @issue.init_journal(User.current) + issue_attributes = params[:issue] + if issue_attributes && params[:conflict_resolution] + case params[:conflict_resolution] + when 'overwrite' + issue_attributes = issue_attributes.dup + issue_attributes.delete(:lock_version) + when 'add_notes' + issue_attributes = issue_attributes.slice(:notes) + when 'cancel' + redirect_to issue_url(@issue) + return false + end + end + + if params[:action] == "update" + senduser = User.find(params[:issue][:assigned_to_id]) + if senduser.id != User.current.id && @issue.assigned_to_id != params[:issue][:assigned_to_id].to_i + issue_id = @issue.id + issue_title = params[:issue][:subject] + priority_id = params[:issue][:priority_id] + ps = ProjectsService.new + ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id + end + end + + @issue.safe_attributes = issue_attributes + @priorities = IssuePriority.active + @allowed_statuses = @issue.new_statuses_allowed_to(User.current) + true + end + + # TODO: Refactor, lots of extra code in here + # TODO: Changing tracker on an existing issue should not trigger this + def build_new_task_from_params + if params[:id].blank? + @training_task = TrainingTask.new + @training_task.project = @project + else + @training_task = @project.training_tasks.visible.find(params[:id]) + end + + @training_task.project = @project + @training_task.author ||= User.current + # Tracker must be set before custom field values + @training_task.tracker ||= @project.trackers.find((params[:training_task] && params[:training_task][:tracker_id]) || params[:tracker_id] || :first) + if @training_task.tracker.nil? + render_error l(:error_no_tracker_in_project) + return false + end + end + + def check_for_default_issue_status + if IssueStatus.default.nil? + render_error l(:error_no_default_issue_status) + return false + end + end + + def parse_params_for_bulk_issue_attributes(params) + attributes = (params[:issue] || {}).reject {|k,v| v.blank?} + attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} + if custom = attributes[:custom_field_values] + custom.reject! {|k,v| v.blank?} + custom.keys.each do |k| + if custom[k].is_a?(Array) + custom[k] << '' if custom[k].delete('__none__') + else + custom[k] = '' if custom[k] == '__none__' + end + end + end + attributes + end + + # Find the issue whose id is the :id parameter + # Raises a Unauthorized exception if the issue is not visible + def find_training_task + @training_task = TrainingTask.find(params[:id]) + @project = @training_task.project + rescue ActiveRecord::RecordNotFound + render_404 + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7315d7630..f479432ca 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1036,6 +1036,32 @@ module ApplicationHelper return @result end + # 更新各类消息为已读 + def update_messsages_to_viewed(message_type, forge_message_id) + if(message_type == "CourseMessage") + query = CourseMessage.where(:course_message_type => ["JoinCourse", "RemoveFromCourse"], + :user_id => User.current, + :course_id => forge_message_id, + :viewed => false) + elsif(message_type == "ForgeMessage") + query = ForgeMessage.where(:forge_message_type => ["ProjectInvite", "JoinProject", "RemoveFromProject"], + :user_id => User.current, + :project_id => forge_message_id, + :viewed => false) + elsif(message_type == "ContestMessage") + query = ContestMessage.where(:contest_message_type => ["ContestRequestDealResult", "JoinContest", "RemoveFromContest"], + :user_id => User.current, + :contest_id => forge_message_id, + :viewed => false) + elsif(message_type == "BlogMessage") + query = BlogMessage.where(:blog_message_type => "BlogComment", + :user_id => User.current, + :blog_id => forge_message_id, + :viewed => false) + end + query.update_all(:viewed => true) unless query.blank? + end + def show_attachment_tip container_id, container_type atts = Attachment.where(:container_id => container_id, :container_type => container_type, :is_public => 0) atts.count > 0 ? true :false diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index e97d32523..559160d60 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -257,6 +257,14 @@ module CoursesHelper count.to_s << '+' end + def searchTeacherAndAssistantNoManager course + members = [] + course.members.includes(:user).each do |m| + members << m if m && m.user && m.user != course.teacher && m.user.has_teacher_role(course) + end + members + end + # ===================================================================================== # return people list def searchTeacherAndAssistant project @@ -928,5 +936,11 @@ module CoursesHelper result = !m_roles.blank? result end + + #获取该班级下已关联项目的分组作业 + def select_group_homeworks course + student_work_pros = course.student_work_projects.where("project_id != -1 && project_id != 0") + homeworks = @course.homework_commons.where(:id => student_work_pros.map(&:homework_common_id)) + end end diff --git a/app/helpers/training_tasks_helper.rb b/app/helpers/training_tasks_helper.rb index 27569b973..4096b1cb0 100644 --- a/app/helpers/training_tasks_helper.rb +++ b/app/helpers/training_tasks_helper.rb @@ -1,2 +1,2 @@ -module TrainingTasksHelper -end +module TrainingTasksHelper +end diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index ec0711bc4..d0c067437 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -1,100 +1,100 @@ -class PraiseTread < ActiveRecord::Base - attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread - belongs_to :user - belongs_to :praise_tread_object, polymorphic: true - #after_create :be_user_score - #after_destroy :down_user_score - include UserScoreHelper - def self.find_object_by_type_and_id(type,id) - @obj = nil - case type - when 'User' - @obj = User.find_by_id(id) - when 'Issue' - @obj = Issue.find_by_id(id) - when 'TrainingTask' - @obj = TrainingTask.find_by_id(id) - when 'Project' - @obj = Project.find_by_id(id) - when 'Bid' - @obj = Bid.find_by_id(id) - when 'Contest' - @obj = Contest.find_by_id(id) - when 'Memo' - @obj = Memo.find_by_id(id) - when 'Message' - @obj = Message.find_by_id(id) - end - return @obj - end - - # 获取裁定对象为Message时Message所属的项目或课程 - def project - project = nil - if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues' - obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) - project = obj.project - end - project - end - - #更新用户分数 - by zjc - def be_user_score - #踩贴吧或讨论区帖子 - if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') - obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) - target_user = obj.author - UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) - update_tread(self.user,1) - update_tread(target_user,1) - unless self.project.nil? - update_tread(self.user,2,self.project) - update_tread(target_user,2,self.project) - end - #顶贴吧或讨论区帖子 - elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') - obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) - target_user = obj.author - UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) - update_praise(target_user,1) - unless self.project.nil? - update_praise(target_user,2,self.project) - end - #更新用户等级 - UserLevels.update_user_level(target_user) - end - end - - def down_user_score - #踩贴吧或讨论区帖子 - if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') - obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) - target_user = obj.author - #UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) - update_tread(self.user,1) - update_tread(target_user,1) - unless self.project.nil? - update_tread(self.user,2,self.project) - update_tread(target_user,2,self.project) - end - #顶贴吧或讨论区帖子 - elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') - obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) - target_user = obj.author - #UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) - update_praise(target_user,1) - unless self.project.nil? - update_praise(target_user,2,self.project) - end - #更新用户等级 - UserLevels.update_user_level(target_user) - end - end - - def self.praised(activity) - self.where(praise_tread_object_id: activity.id, - praise_tread_object_type: activity.class.to_s, - user_id: User.current.id).empty? - end - -end +class PraiseTread < ActiveRecord::Base + attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread + belongs_to :user + belongs_to :praise_tread_object, polymorphic: true + #after_create :be_user_score + #after_destroy :down_user_score + include UserScoreHelper + def self.find_object_by_type_and_id(type,id) + @obj = nil + case type + when 'User' + @obj = User.find_by_id(id) + when 'Issue' + @obj = Issue.find_by_id(id) + when 'TrainingTask' + @obj = TrainingTask.find_by_id(id) + when 'Project' + @obj = Project.find_by_id(id) + when 'Bid' + @obj = Bid.find_by_id(id) + when 'Contest' + @obj = Contest.find_by_id(id) + when 'Memo' + @obj = Memo.find_by_id(id) + when 'Message' + @obj = Message.find_by_id(id) + end + return @obj + end + + # 获取裁定对象为Message时Message所属的项目或课程 + def project + project = nil + if self.praise_tread_object_type == 'Message' || self.praise_tread_object_type == 'Issues' + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + project = obj.project + end + project + end + + #更新用户分数 - by zjc + def be_user_score + #踩贴吧或讨论区帖子 + if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) + update_tread(self.user,1) + update_tread(target_user,1) + unless self.project.nil? + update_tread(self.user,2,self.project) + update_tread(target_user,2,self.project) + end + #顶贴吧或讨论区帖子 + elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) + update_praise(target_user,1) + unless self.project.nil? + update_praise(target_user,2,self.project) + end + #更新用户等级 + UserLevels.update_user_level(target_user) + end + end + + def down_user_score + #踩贴吧或讨论区帖子 + if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + #UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) + update_tread(self.user,1) + update_tread(target_user,1) + unless self.project.nil? + update_tread(self.user,2,self.project) + update_tread(target_user,2,self.project) + end + #顶贴吧或讨论区帖子 + elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Issue' || self.praise_tread_object_type == 'Message') + obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) + target_user = obj.author + #UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) + update_praise(target_user,1) + unless self.project.nil? + update_praise(target_user,2,self.project) + end + #更新用户等级 + UserLevels.update_user_level(target_user) + end + end + + def self.praised(activity) + self.where(praise_tread_object_id: activity.id, + praise_tread_object_type: activity.class.to_s, + user_id: User.current.id).empty? + end + +end diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb index 5ef2922b0..f3e0cb530 100644 --- a/app/models/students_for_course.rb +++ b/app/models/students_for_course.rb @@ -31,7 +31,7 @@ class StudentsForCourse < ActiveRecord::Base #加入班级时创建已发布作业的作品 def create_student_works course = self.course - course.homework_commons.each do |hw| + course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").each do |hw| if hw.homework_type != 3 && hw.student_works.where("user_id = #{self.student_id}").count == 0 hw.student_works << StudentWork.new(:user_id => self.student_id, :name => hw.name.to_s+"的作品提交", :work_status => 0) end diff --git a/app/models/training_task.rb b/app/models/training_task.rb index 54fa72648..e518b1b4c 100644 --- a/app/models/training_task.rb +++ b/app/models/training_task.rb @@ -1,20 +1,20 @@ -class TrainingTask < ActiveRecord::Base - attr_accessible :description, :project_id, :subject, :tracker_id - belongs_to :project,:touch=> true - belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' - belongs_to :tracker - has_many :journals, :as => :journalized, :dependent => :destroy - has_many :visible_journals, - :class_name => 'Journal', - :as => :journalized, - :conditions => Proc.new { - ["(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(User.current, :view_private_notes)}))", false] - }, - :readonly => true - has_many :praise_tread, as: :praise_tread_object, dependent: :destroy - has_one :praise_tread_cache, as: :object, dependent: :destroy - acts_as_attachable - - validates_presence_of :subject, :author - validates_length_of :subject, :maximum => 255 -end +class TrainingTask < ActiveRecord::Base + attr_accessible :description, :project_id, :subject, :tracker_id + belongs_to :project,:touch=> true + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + belongs_to :tracker + has_many :journals, :as => :journalized, :dependent => :destroy + has_many :visible_journals, + :class_name => 'Journal', + :as => :journalized, + :conditions => Proc.new { + ["(#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(User.current, :view_private_notes)}))", false] + }, + :readonly => true + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy + has_one :praise_tread_cache, as: :object, dependent: :destroy + acts_as_attachable + + validates_presence_of :subject, :author + validates_length_of :subject, :maximum => 255 +end diff --git a/app/views/cooperation/index.html.erb b/app/views/cooperation/index.html.erb index c3a102788..2a3a7a430 100644 --- a/app/views/cooperation/index.html.erb +++ b/app/views/cooperation/index.html.erb @@ -34,6 +34,12 @@
  • ucloud
  • +
  • + 南京大学 +
  • +
  • + 湘潭大学 +
  • diff --git a/app/views/courses/_course_activity_users.html.erb b/app/views/courses/_course_activity_users.html.erb index 525a9ce85..6bc049ebd 100644 --- a/app/views/courses/_course_activity_users.html.erb +++ b/app/views/courses/_course_activity_users.html.erb @@ -4,7 +4,7 @@ diff --git a/app/views/layouts/base_project_community.html.erb b/app/views/layouts/base_project_community.html.erb index 357cfddb3..a9caebcdb 100644 --- a/app/views/layouts/base_project_community.html.erb +++ b/app/views/layouts/base_project_community.html.erb @@ -58,7 +58,7 @@
  • <%= link_to "新建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :style => "font-size:14px;" %>
  • -
  • +
  • <%= link_to "加入项目", applied_join_project_path, :remote => true, :method => "post", :style => "font-size:14px;" %>
  • diff --git a/app/views/poll/_polls_list.html.erb b/app/views/poll/_polls_list.html.erb index a23af8e73..e22e8fbdf 100644 --- a/app/views/poll/_polls_list.html.erb +++ b/app/views/poll/_polls_list.html.erb @@ -1,10 +1,15 @@ -<% polls.each_with_index do |poll, i|%> - -
    -<% end%> +<% if polls.count != 0 %> + <% polls.each_with_index do |poll, i|%> + +
    + <% end%> - \ No newline at end of file + +<% else %> +
    +

    没有数据可以显示!

    +<% end %> \ No newline at end of file diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb index cce8ba32e..25f5cc8d2 100644 --- a/app/views/projects/_applied_status.html.erb +++ b/app/views/projects/_applied_status.html.erb @@ -1,49 +1,49 @@ -<% if !User.current.member_of?(@project) %> - <% if User.current.login? && !User.current.admin %> - -
  • - <%= watcher_link_for_project(@project, User.current) %> - <%= link_to "#{@project.watcher_users.count}", {:controller => "projects", :action => "project_watcherlist", - :id => @project.id}, :id => "fans_num", :class => 'pro_new_topbtn fl', :title => "关注成员列表" %> -
  • - -
  • - <% if AppliedProject.where(:user_id => User.current, :project_id => @project_id).first.nil? %> - <%= join_in_project_link(@project, User.current) %> - <% else %> - 等待审批 - <% end %> - <%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员列表" %> -
  • - <% end %> -<% else %> - - <% if User.current.login? %> -
  • - <%= watcher_link_for_project(@project, User.current) %> - <%= link_to "#{@project.watcher_users.count}", {:controller => "projects", :action => "project_watcherlist", - :id => @project.id}, :id => "fans_num", :class => 'pro_new_topbtn fl', :title => "关注成员列表" %> -
  • -
  • - 已加入 - - <%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员列表" %> -
  • - <%#= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员" %> - <% end %> -<% end %> - - -
  • - - <% if !@project.enabled_modules.where("name = 'training_tasks'").empty? && @project.forked_from_project_id.nil? %> - <%= link_to "开始实训", forked_pop_project_path(@project, :task => true), :class => "sy_btn_green fr" %> - <% else %> - <%= link_to "".html_safe+"Fork", forked_pop_project_path(@project), - :class=>"pro_new_topbtn_left fl", :remote => true %> - <%= project_fork_count %> - <% end %> - -
  • - - +<% if !User.current.member_of?(@project) %> + <% if User.current.login? && !User.current.admin %> + +
  • + <%= watcher_link_for_project(@project, User.current) %> + <%= link_to "#{@project.watcher_users.count}", {:controller => "projects", :action => "project_watcherlist", + :id => @project.id}, :id => "fans_num", :class => 'pro_new_topbtn fl', :title => "关注成员列表" %> +
  • + +
  • + <% if AppliedProject.where(:user_id => User.current, :project_id => @project_id).first.nil? %> + <%= join_in_project_link(@project, User.current) %> + <% else %> + 等待审批 + <% end %> + <%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员列表" %> +
  • + <% end %> +<% else %> + + <% if User.current.login? %> +
  • + <%= watcher_link_for_project(@project, User.current) %> + <%= link_to "#{@project.watcher_users.count}", {:controller => "projects", :action => "project_watcherlist", + :id => @project.id}, :id => "fans_num", :class => 'pro_new_topbtn fl', :title => "关注成员列表" %> +
  • +
  • + 已加入 + + <%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员列表" %> +
  • + <%#= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员" %> + <% end %> +<% end %> + + +
  • + + <% if !@project.enabled_modules.where("name = 'training_tasks'").empty? && @project.forked_from_project_id.nil? %> + <%= link_to "开始实训", forked_pop_project_path(@project, :task => true), :class => "sy_btn_green fr" %> + <% else %> + <%= link_to "".html_safe+"Fork", forked_pop_project_path(@project), + :class=>"pro_new_topbtn_left fl", :remote => true %> + <%= project_fork_count %> + <% end %> + +
  • + + diff --git a/app/views/projects/settings/_new_modules.html.erb b/app/views/projects/settings/_new_modules.html.erb index 6413823c5..b1f9718f7 100644 --- a/app/views/projects/settings/_new_modules.html.erb +++ b/app/views/projects/settings/_new_modules.html.erb @@ -2,8 +2,8 @@

    请选择此项目可以使用的模块:

    <%= form_for @project,:url => { :action => 'modules', :id => @project },:html => {:id => 'modules-form',:method => :post} do |f| %> <% Redmine::AccessControl.available_project_modules.each do |m| %> -
  • - <%= check_box_tag('enabled_module_names[]', m, @project.module_enabled?(m), :class=>"fl mt8").html_safe -%> +
  • + <%= check_box_tag('enabled_module_names[]', m, @project.module_enabled?(m), :class=>"fl mt8", :id => 'project_module_'+m.to_s ).html_safe -%>

    <%= l_or_humanize(m, :prefix => "project_module_").html_safe %>

  • <% end %> @@ -16,27 +16,26 @@ - - - + \ No newline at end of file diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index 3dd3483a5..4b9bd6b88 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -57,14 +57,14 @@ <% if @type == nil || @type == "1" %> -
    +
    <%= render :partial => "pull_requests/pull_request_comments" %>
    <% end %> -
    +
    <%= render :partial => "pull_requests/pull_request_commits" %>
    -
    +
    <%= render :partial => "pull_requests/pull_request_changes" %>
    diff --git a/app/views/student_work/_score_appeal_box.html.erb b/app/views/student_work/_score_appeal_box.html.erb index 874da4fd5..52ef67e91 100644 --- a/app/views/student_work/_score_appeal_box.html.erb +++ b/app/views/student_work/_score_appeal_box.html.erb @@ -8,7 +8,7 @@ :method => "post", :remote => true) do |f|%>
    - + *申诉理由: <%= f.text_area 'comment', :id => 'appeal_comment', :style => 'height: 70px; width: 414px;', :placeholder => "请输入你的申诉理由,最多250个字符。",:maxlength => 250 %>

    请输入申诉理由

    diff --git a/app/views/student_work/_student_work_score.html.erb b/app/views/student_work/_student_work_score.html.erb index decc093c8..1b36503e7 100644 --- a/app/views/student_work/_student_work_score.html.erb +++ b/app/views/student_work/_student_work_score.html.erb @@ -23,7 +23,7 @@ 回复 <% if @homework.anonymous_appeal == 1 %> <% if score.student_work.user == User.current && score.reviewer_role == 3 && score.appeal_status == 0 %> - 申诉 + 申诉 <% elsif score.reviewer_role == 3 && score.appeal_status == 1 %> 申诉中 <% elsif score.reviewer_role == 3 && score.appeal_status == 2 %> @@ -55,10 +55,10 @@
    申诉 <% if score.appeal_status == 1 && score.student_work.user == User.current %> - 撤销申诉 + 撤销申诉 <% elsif @is_teacher && score.appeal_status == 1 %> - 接受 - 拒绝 + 接受 + 拒绝 <% end %> <%=format_time score.student_works_scores_appeal.updated_at %> diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index a6a2c9a95..1837b66a9 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -15,6 +15,7 @@ $("#student_work_tab2").click(); <% elsif @tab == 3 %> $("#student_work_tab3").click(); + $("#project_activities").show(); <% end %> sd_create_editor_from_data(<%= @homework.id %>, null, "100%", "<%= @homework.class.to_s %>"); }); @@ -26,6 +27,11 @@ } $('#student_work_tab'+n).addClass('selected'); $('#student_work_con'+n).removeClass('undis'); + if (n == 3){ + $("#project_activities").show(); + } else{ + $("#project_activities").hide(); + } } $("#moreProject_<%=@homework.id %>").click(function(){ @@ -160,11 +166,19 @@
  • 关联项目列表
  • -
  •  
  • + <% if !@homework.student_work_projects.empty? %> +
  •   + <%= link_to '项目活跃度', course_statistics_course_path(@homework.course, :tab => 3, :homework_id => @homework.id), + :id => 'project_activities', :class => 'fr fontBlue2 none', :style => 'font-weight: normal;', :target => '_blank' %> +
  • + <% else %> +
  •  
  • + <% end %> <% else %>
  •  
  • <% end %> +
    @@ -184,7 +198,7 @@
    - <% if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + <% if is_group_project_homework %>
    <% student_work_ids = @homework.student_works.has_committed.blank? ? "(-1)" : "(" + @homework.student_works.has_committed.map{|st| st.id}.join(",") + ")" %> <% student_work_projects = @homework.student_work_projects.where("student_work_id in #{student_work_ids} or student_work_id is null") %> diff --git a/app/views/training_tasks/_all_list.html.erb b/app/views/training_tasks/_all_list.html.erb index b712b814d..501c25514 100644 --- a/app/views/training_tasks/_all_list.html.erb +++ b/app/views/training_tasks/_all_list.html.erb @@ -1,12 +1,12 @@ -<% tasks.each do |task| -%> - <%= render :partial => 'content_list', :locals => {:activity => task, :user_activity_id => task.id} %> -<% end %> - -
    -
    -
      - <%= pagination_links_full @training_tasks_pages, @training_tasks_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %> -
    -
    -
    +<% tasks.each do |task| -%> + <%= render :partial => 'content_list', :locals => {:activity => task, :user_activity_id => task.id} %> +<% end %> + +
    +
    +
      + <%= pagination_links_full @training_tasks_pages, @training_tasks_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %> +
    +
    +
    \ No newline at end of file diff --git a/app/views/training_tasks/_content_list.html.erb b/app/views/training_tasks/_content_list.html.erb index e3871c925..e7e2b5124 100644 --- a/app/views/training_tasks/_content_list.html.erb +++ b/app/views/training_tasks/_content_list.html.erb @@ -1,71 +1,71 @@ -<% unless activity.author.nil? %> -
    -
    - -
    -
    - -
    - <%# if activity.try(:author).try(:realname) == ' ' %> - <%#= link_to activity.try(:author), user_path(activity.author_id), :class => "fl issues_list_name" %> - <%# else %> - <%#= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "fl issues_list_name" %> - <%# end %> - -

    <%= format_time(activity.created_at) %> 发布

    -

    <%= format_time(activity.updated_at) %> 更新

    -
    -
    -
      -
    • - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id)%> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id)%> - <% end %> -
    • - -
    • - <% case activity.tracker_id %> - <% when 1%> - 缺陷 - <% when 2%> - 功能 - <% when 3%> - 支持 - <% when 4%> - 任务 - <% when 5%> - 周报 - <% end %> -
    • -
    -
    -<% end %> - - - +<% unless activity.author.nil? %> +
    +
    + +
    +
    + +
    + <%# if activity.try(:author).try(:realname) == ' ' %> + <%#= link_to activity.try(:author), user_path(activity.author_id), :class => "fl issues_list_name" %> + <%# else %> + <%#= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "fl issues_list_name" %> + <%# end %> + +

    <%= format_time(activity.created_at) %> 发布

    +

    <%= format_time(activity.updated_at) %> 更新

    +
    +
    +
      +
    • + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id)%> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id)%> + <% end %> +
    • + +
    • + <% case activity.tracker_id %> + <% when 1%> + 缺陷 + <% when 2%> + 功能 + <% when 3%> + 支持 + <% when 4%> + 任务 + <% when 5%> + 周报 + <% end %> +
    • +
    +
    +<% end %> + + + diff --git a/app/views/training_tasks/_detail.html.erb b/app/views/training_tasks/_detail.html.erb index f7612de08..5bf14de6e 100644 --- a/app/views/training_tasks/_detail.html.erb +++ b/app/views/training_tasks/_detail.html.erb @@ -1,54 +1,54 @@ -
    -
    - <%= link_to image_tag(url_to_avatar(@training_task.author), :width => 46, :height => 46), user_path(@training_task.author), :class => "ping_dispic" %> -
    -
    -

    - <% case @training_task.tracker_id %> - <% when 1%> - 【缺陷】 - <% when 2%> - 【功能】 - <% when 3%> - 【支持】 - <% when 4%> - 【任务】 - <% when 5%> - 【周报】 - <% end %> - <%= @training_task.subject %>

    - -
    -
    - 由<%=link_to @training_task.author.show_name, user_path(@training_task.author), :class => "link-blue" %>添加于 <%= format_time(@training_task.created_at).html_safe %> -
    - <%= link_to "完成", complete_training_task_training_task_path(@training_task), :class => "sy_btn_green fr" %> - - - - <%#= render :partial => 'action_menu' %> -
    - <% if @training_task.description? || @training_task.attachments.any? -%> -
    - <% if @training_task.description? %> - <%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %> - <%= textAreailizable @training_task, :description, :attachments => @training_task.attachments %> - <% end %> -
    - <% end -%> - - <%# 附件局部刷新 %> -
    - <%= render :partial => 'task_attachments',:locals => {:training_task => @training_task} %> -
    - - <%#= render :partial => 'issues/attributes_show' %> -
    -
    - - \ No newline at end of file diff --git a/app/views/training_tasks/_form.html.erb b/app/views/training_tasks/_form.html.erb index 704a420fe..790c8b17b 100644 --- a/app/views/training_tasks/_form.html.erb +++ b/app/views/training_tasks/_form.html.erb @@ -1,55 +1,55 @@ -<%= labelled_fields_for :training_task, @training_task do |f| %> -
      -
    • - 类   型 - <%= f.select :tracker_id, Tracker.all.collect{ |t| [t.name, t.id] },{:required => true, :no_label => true}, - :class => "fl", :style => "width:160px;padding-left:0px;" %> -
    • -
    • - - <%= f.text_field :subject, :style => "font-size:small;width:606px;", :no_label => true, :id => "training_task_id" %> - 标题不能为空 - - <%= javascript_tag do %> - observeAutocompleteField('issue_subject', - '<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil)) %>', - { select: function(event, ui) { - $('input#issue_subject').val(ui.item.value); - } - }); - <% end %> -
    • -
    • - - <%= f.label_for_field :description, :no_label => true, :class => "label" %> - <%#= link_to_function image_tag('edit.png'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %> - <%#= content_tag 'span', :id => "issue_description_and_toolbar" do %> - <%= f.kindeditor :description,:editor_id => "training_task_desc_editor", :width=>'85%', :height =>159, :resizeType => 0, :no_label => true, at_id: @project.id, at_type: @project.class.to_s %> - <%# end %> - <%#= wikitoolbar_for 'issue_description' %> - -
    • - -
    • - - <%= render :partial => 'attachments/form', :locals => {:container => @training_task} %> -
    • -
    • - <% if params[:action] == "new" %> - 取消 - <% else %> - <%= link_to "取消", training_task_path(@training_task), :class => "sy_btn_grey mr5 fr" %> - <% end %> - - - -
    • -
    - -<% end %> - +<%= labelled_fields_for :training_task, @training_task do |f| %> +
      +
    • + 类   型 + <%= f.select :tracker_id, Tracker.all.collect{ |t| [t.name, t.id] },{:required => true, :no_label => true}, + :class => "fl", :style => "width:160px;padding-left:0px;" %> +
    • +
    • + + <%= f.text_field :subject, :style => "font-size:small;width:606px;", :no_label => true, :id => "training_task_id" %> + 标题不能为空 + + <%= javascript_tag do %> + observeAutocompleteField('issue_subject', + '<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (Setting.cross_project_issue_relations? ? 'all' : nil)) %>', + { select: function(event, ui) { + $('input#issue_subject').val(ui.item.value); + } + }); + <% end %> +
    • +
    • + + <%= f.label_for_field :description, :no_label => true, :class => "label" %> + <%#= link_to_function image_tag('edit.png'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %> + <%#= content_tag 'span', :id => "issue_description_and_toolbar" do %> + <%= f.kindeditor :description,:editor_id => "training_task_desc_editor", :width=>'85%', :height =>159, :resizeType => 0, :no_label => true, at_id: @project.id, at_type: @project.class.to_s %> + <%# end %> + <%#= wikitoolbar_for 'issue_description' %> + +
    • + +
    • + + <%= render :partial => 'attachments/form', :locals => {:container => @training_task} %> +
    • +
    • + <% if params[:action] == "new" %> + 取消 + <% else %> + <%= link_to "取消", training_task_path(@training_task), :class => "sy_btn_grey mr5 fr" %> + <% end %> + + + +
    • +
    + +<% end %> + diff --git a/app/views/training_tasks/_issue_replies.html.erb b/app/views/training_tasks/_issue_replies.html.erb index 4ea392103..029dc2337 100644 --- a/app/views/training_tasks/_issue_replies.html.erb +++ b/app/views/training_tasks/_issue_replies.html.erb @@ -1,89 +1,89 @@ -
      - <% @journals.each do |comment| %> - -
    • -
      - <%= 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, :type => 'Issue', :user_activity_id => issue.id}%> - -
      - <% if comment.details.any? %> - <% details_to_strings(comment.details).each do |string| %> -

      <%= string %>

      - <% end %> - <% end %> -

      <%= comment.notes.html_safe %>

      -
      -
      -
      - - - <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> - - - <%= link_to( - l(:button_reply), - {:controller => 'issues', :action => 'reply', :user_id => comment.user_id, :id => issue.id, :journal_id => comment.id}, - :remote => true, - :method => 'get', - :title => l(:button_reply)) %> - - - <%= link_to( - l(:button_delete), - {:controller => 'issues',:action => 'delete_journal', :id => issue.id, :journal_id=>comment.id}, - :method => :get, - :remote => true, - :id => "delete_reply_#{comment.id}", - :class => 'fr mr20 undis', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if comment.user_id == User.current.id %> - -
      -
      -
      -

      -
      -
      -
    • - <% end %> -
    -
    - -
    - <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@training_task.author_id), :alt => "用户头像" %> -
    - -
    - <% if User.current.logged? %> -
    - <%= form_for('new_form', :url => add_journal_issue_path(@training_task.id, :is_issue_show => true), :method => "post", :remote => true) do |f| %> - -
    -
    - -
    -
    - <%= render :partial => 'attachments/issue_reply', :locals => {:container => @training_task} %> -
    - - -
    - <% end %> -
    - <% else %> - <%= render :partial => "users/show_unlogged" %> - <% end %> -
    - -
    -
    +
      + <% @journals.each do |comment| %> + +
    • +
      + <%= 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, :type => 'Issue', :user_activity_id => issue.id}%> + +
      + <% if comment.details.any? %> + <% details_to_strings(comment.details).each do |string| %> +

      <%= string %>

      + <% end %> + <% end %> +

      <%= comment.notes.html_safe %>

      +
      +
      +
      + + + <%= render :partial => "praise_tread/praise", :locals => {:activity => comment, :user_activity_id => comment.id, :type => "reply"} %> + + + <%= link_to( + l(:button_reply), + {:controller => 'issues', :action => 'reply', :user_id => comment.user_id, :id => issue.id, :journal_id => comment.id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <%= link_to( + l(:button_delete), + {:controller => 'issues',:action => 'delete_journal', :id => issue.id, :journal_id=>comment.id}, + :method => :get, + :remote => true, + :id => "delete_reply_#{comment.id}", + :class => 'fr mr20 undis', + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if comment.user_id == User.current.id %> + +
      +
      +
      +

      +
      +
      +
    • + <% end %> +
    +
    + +
    + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@training_task.author_id), :alt => "用户头像" %> +
    + +
    + <% if User.current.logged? %> +
    + <%= form_for('new_form', :url => add_journal_issue_path(@training_task.id, :is_issue_show => true), :method => "post", :remote => true) do |f| %> + +
    +
    + +
    +
    + <%= render :partial => 'attachments/issue_reply', :locals => {:container => @training_task} %> +
    + + +
    + <% end %> +
    + <% else %> + <%= render :partial => "users/show_unlogged" %> + <% end %> +
    + +
    +
    \ No newline at end of file diff --git a/app/views/training_tasks/_reply_banner.html.erb b/app/views/training_tasks/_reply_banner.html.erb index 8b49a10bf..9bbd17831 100644 --- a/app/views/training_tasks/_reply_banner.html.erb +++ b/app/views/training_tasks/_reply_banner.html.erb @@ -1,5 +1,5 @@ -<% count = @training_task.journals.count %> -回复<%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity => @training_task, :user_activity_id=> @training_task.id, :type => "activity"}%> +<% count = @training_task.journals.count %> +回复<%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity => @training_task, :user_activity_id=> @training_task.id, :type => "activity"}%> \ No newline at end of file diff --git a/app/views/training_tasks/_task_attachments.html.erb b/app/views/training_tasks/_task_attachments.html.erb index c3e5fafc0..c47ac4c92 100644 --- a/app/views/training_tasks/_task_attachments.html.erb +++ b/app/views/training_tasks/_task_attachments.html.erb @@ -1,10 +1,10 @@ -<% if training_task.attachments.any? %> -
    - - - <%= link_to_attachment_project training_task, :thumbnails => true %> -
    - <%#= call_hook(:view_issues_show_description_bottom, :training_task => training_task) %> -
    -
    +<% if training_task.attachments.any? %> +
    + + + <%= link_to_attachment_project training_task, :thumbnails => true %> +
    + <%#= call_hook(:view_issues_show_description_bottom, :training_task => training_task) %> +
    +
    <% end %> \ No newline at end of file diff --git a/app/views/training_tasks/index.html.erb b/app/views/training_tasks/index.html.erb index 120b2c392..978c17a07 100644 --- a/app/views/training_tasks/index.html.erb +++ b/app/views/training_tasks/index.html.erb @@ -1,232 +1,232 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true,init_activity: true) %> -<% end %> - - - - -
    -
    - - 新建 -
    - <% if @training_tasks.empty? %> - <%= render :partial => "projects/no_data" %> - <% else %> -
    - <%= render :partial => 'all_list', :locals => {:tasks => @training_tasks, :query => @query, :training_tasks_pages=> @training_tasks_pages, :training_tasks_count=> @training_tasks_count, :project=> @project, :subject => @subject} %> -
    - <% end %> -<%#= render :partial => 'issues/all_list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project,:subject=>@subject} %> -
    -
    - -
    -
    -
    -
    -
    -
    - +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true,init_activity: true) %> +<% end %> + + + + +
    +
    + + 新建 +
    + <% if @training_tasks.empty? %> + <%= render :partial => "projects/no_data" %> + <% else %> +
    + <%= render :partial => 'all_list', :locals => {:tasks => @training_tasks, :query => @query, :training_tasks_pages=> @training_tasks_pages, :training_tasks_count=> @training_tasks_count, :project=> @project, :subject => @subject} %> +
    + <% end %> +<%#= render :partial => 'issues/all_list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project,:subject=>@subject} %> +
    +
    + +
    +
    +
    +
    +
    +
    + diff --git a/app/views/training_tasks/new.html.erb b/app/views/training_tasks/new.html.erb index c789561cc..d6c059a8e 100644 --- a/app/views/training_tasks/new.html.erb +++ b/app/views/training_tasks/new.html.erb @@ -1,27 +1,27 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> -<% end %> - - - -
    -
    - <%#= call_hook(:view_issues_new_top, {:training_task => @training_task}) %> - <%= labelled_form_for @training_task, :url => project_training_tasks_url(@project), - :html => {:id => 'project_training_form', :multipart => true} do |f| %> - <%= error_messages_for 'training_task' %> - <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %> -
    - <%= render :partial => 'training_tasks/form', :locals => {:f => f} %> -
    - <% end %> -
    -
    - - - +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> +<% end %> + + + +
    +
    + <%#= call_hook(:view_issues_new_top, {:training_task => @training_task}) %> + <%= labelled_form_for @training_task, :url => project_training_tasks_url(@project), + :html => {:id => 'project_training_form', :multipart => true} do |f| %> + <%= error_messages_for 'training_task' %> + <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %> +
    + <%= render :partial => 'training_tasks/form', :locals => {:f => f} %> +
    + <% end %> +
    +
    + + + diff --git a/app/views/training_tasks/show.html.erb b/app/views/training_tasks/show.html.erb index 1b61f634d..bf4afb093 100644 --- a/app/views/training_tasks/show.html.erb +++ b/app/views/training_tasks/show.html.erb @@ -1,42 +1,42 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true) %> - <%= javascript_include_tag 'create_kindeditor'%> -<% end %> - - -
    - - -
    -
    -
    -
    - <%= render :partial => 'detail'%> -
    -
    - - -
    -
    -
    -
    -
    - <%=render :partial => 'reply_banner' %> -
    -
    -
    -
    - <%= render :partial => 'issue_replies',:locals => {:issue => @training_task, :replies_all_i => 0} %> -
    -
    -
    -
    - -
    -
    - +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true) %> + <%= javascript_include_tag 'create_kindeditor'%> +<% end %> + + +
    + + +
    +
    +
    +
    + <%= render :partial => 'detail'%> +
    +
    + + +
    +
    +
    +
    +
    + <%=render :partial => 'reply_banner' %> +
    +
    +
    +
    + <%= render :partial => 'issue_replies',:locals => {:issue => @training_task, :replies_all_i => 0} %> +
    +
    +
    +
    + +
    +
    + diff --git a/app/views/users/_unfinished_homework_list.html.erb b/app/views/users/_unfinished_homework_list.html.erb index f153f9f03..3cb0b111c 100644 --- a/app/views/users/_unfinished_homework_list.html.erb +++ b/app/views/users/_unfinished_homework_list.html.erb @@ -13,25 +13,25 @@ <% @unfinished_homeworks.each do |uh| %> - + <%= link_to image_tag(url_to_avatar(uh.user), :width => "30", :height => "30"), user_path(uh.user), :target => '_blank' %> - - + +
  • <%= link_to uh.name.to_s, student_work_index_path( :homework => uh.id, :tab => 1), :target => "_blank", :class => "homepageTabTitle fl ml5", :title => "#{uh.name.to_s}" %>
  • - - + +
  • <%= link_to uh.course.try(:name), course_path(uh.course_id), :target => "_blank", :class => "homepageTabTitle ml5", :target => "_blank", :title => "#{uh.course.try(:name)}" %>
  • - - + +
  • <%= homework_type_tip(uh.homework_type) %>
  • - - + +
  • <% end_time = uh.end_time.to_time.to_i + 24*60*60 - 1 %> <% if end_time > Time.now.to_i %> @@ -42,7 +42,7 @@ 已截止 <% end %>
  • - + <% end %> diff --git a/app/views/users/_unfinished_poll_list.html.erb b/app/views/users/_unfinished_poll_list.html.erb index 704909a8e..8dc828125 100644 --- a/app/views/users/_unfinished_poll_list.html.erb +++ b/app/views/users/_unfinished_poll_list.html.erb @@ -11,21 +11,21 @@ <% @unfinished_poll.each do |up| %> - + <%= link_to image_tag(url_to_avatar(up.user), :width => "30", :height => "30"), user_path(up.user), :target => '_blank' %> - - + +
  • <%= link_to up.polls_name.to_s, poll_path(up.id), :target => "_blank", :class => "homepageTabPollTitle fl ml5", :title => "#{up.polls_name.to_s}" %>
  • - - + +
  • <% if up.polls_type == "Course" %> <%= link_to Course.find(up.polls_group_id).name, course_path(Course.find(up.polls_group_id)), :target => "_blank", :title => "#{Course.find(up.polls_group_id).name}" %> <% end %>
  • - + <% end %> diff --git a/app/views/users/_unfinished_test_list.html.erb b/app/views/users/_unfinished_test_list.html.erb index c6d38d26a..09903704b 100644 --- a/app/views/users/_unfinished_test_list.html.erb +++ b/app/views/users/_unfinished_test_list.html.erb @@ -13,20 +13,20 @@ <% @unfinished_test.each do |ut| %> - + <%= link_to image_tag(url_to_avatar(ut.user), :width => "30", :height => "30"), user_path(ut.user), :target => '_blank' %> - - + +
  • <%= link_to ut.exercise_name.to_s, exercise_index_path(:course_id => ut.course_id), :target => "_blank", :class => "homepageTabTitle fl ml5", :title => "#{ut.exercise_name.to_s}" %>
  • - - + +
  • <%= link_to ut.course.try(:name), course_path(ut.course_id), :target => "_blank", :class => "homepageTabTitle ml5", :title => "#{ut.course.try(:name)}" %>
  • - - + +
  • <% if ut.time.to_i == -1 %> 不限时 @@ -34,8 +34,8 @@ <%= ut.time %> <% end %>
  • - - + +
  • <% if ut.end_time > Time.now %> <%= (ut.end_time.to_i - Time.now.to_i) / (24*60*60) %> 天 @@ -45,7 +45,7 @@ 已截止 <% end %>
  • - + <% end %> diff --git a/app/views/users/_unsolved_issues_list.html.erb b/app/views/users/_unsolved_issues_list.html.erb index 09835cad6..b9a98f623 100644 --- a/app/views/users/_unsolved_issues_list.html.erb +++ b/app/views/users/_unsolved_issues_list.html.erb @@ -14,20 +14,20 @@ <% @unsolved_issues.each do |ui| %> - + <%= link_to image_tag(url_to_avatar(ui.author), :width => "30", :height => "30"), user_path(ui.author), :target => '_blank' %> - - + +
  • <%= link_to ui.subject.to_s, issue_path(ui), :target => "_blank", :class => "homepageTabTitle fl ml5", :title => "#{ui.subject.to_s}" %>
  • - - + +
  • <%= link_to ui.project.try(:name), project_path(ui.project_id), :target => "_blank", :title => "#{ui.project.try(:name)}" %>
  • - - + +
  • <% if ui.author.show_name == ' ' %> <%= link_to ui.try(:author), user_path(ui.author_id), :target => "_blank", :title => "#{ui.try(:author)}" %> @@ -35,17 +35,17 @@ <%= link_to ui.author.show_name, user_path(ui.author_id), :target => "_blank", :title => "#{ui.author.show_name}" %> <% end %>
  • - - + +
  • <%= ui.priority.name %>
  • - - + +
  • <%= ui.status.name %>
  • - + <% end %> diff --git a/app/views/users/_user_message_applied_school_action.html.erb b/app/views/users/_user_message_applied_school_action.html.erb index b4b0cdb6d..d08601d64 100644 --- a/app/views/users/_user_message_applied_school_action.html.erb +++ b/app/views/users/_user_message_applied_school_action.html.erb @@ -3,7 +3,7 @@ “<%= ma.name %>”的申请,已通过审核。谢谢! <% elsif ma.status == 2 %> - + “<%= ma.applied.name %>”的申请,因名称不符合规范,系统已将其更改为“<%= ma.name %>”。谢谢! <% elsif ma.status == 3 %> diff --git a/app/views/users/user_manage_issues.html.erb b/app/views/users/user_manage_issues.html.erb index 10f10db68..7227e02b3 100644 --- a/app/views/users/user_manage_issues.html.erb +++ b/app/views/users/user_manage_issues.html.erb @@ -213,6 +213,12 @@ add_class("reorder_turnover_time"); }); }); + $(document).ready(function(){ + if($.browser.webkit){ + $("#issues_filter_por").css("padding-left","5px"); + $("#issue_filter_status").css("padding-left","10px"); + } + }); @@ -258,36 +264,33 @@
    -
    +
    <%= select( :project, :project_id, options_for_issue_project_list(@issues_filter), { :include_blank => false,:selected => @project_id ? @project_id : 0 }, - { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"} + { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style => "margin: 0 15px;text-align: left;"} )%> - - <%= select( :issue, :user_id, [[@user.show_name, @user.id]].unshift(["指派给",0]), { :include_blank => false, :selected => @assigned_to ? @assigned_to : 0}, {:onchange=>"remote_function();add_style();",:id => "assigned_to_id",:name => "assigned_to_id", :class => "fl", :style => "visibility:hidden; width:0px;margin:0px;padding:0px;"} ) %> - - - - -
    diff --git a/app/views/users/user_receive_issues.html.erb b/app/views/users/user_receive_issues.html.erb index f5815d470..20bdfdbfd 100644 --- a/app/views/users/user_receive_issues.html.erb +++ b/app/views/users/user_receive_issues.html.erb @@ -213,6 +213,11 @@ add_class("reorder_turnover_time"); }); }); + $(document).ready(function(){ + if($.browser.webkit){ + $("#issue_filter_status").css("padding-left","10px"); + } + }); @@ -258,12 +263,12 @@
    -
    +
    <%= select( :project, :project_id, options_for_issue_project_list(@issues_filter), { :include_blank => false,:selected => @project_id ? @project_id : 0 }, - { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style=>"width: 80px; margin-right:20px;"} + { :onchange => "remote_function();add_style();", :id => "project_id", :name => "project_id", :class => "fl", :style => "margin: 0 15px;text-align: left;"} )%> - <%= select( :issue, :user_id, [[@user.show_name, @user.id]].unshift(["发布人",0]), @@ -271,24 +276,21 @@ {:onchange => "remote_function();add_style();",:id => "author_id", :name => "author_id", :class => "fl", :style => "visibility:hidden;width: 0px;margin:0px;padding:0px;"} ) %> - - - - - > -
    diff --git a/config/routes.rb b/config/routes.rb index de24241ac..b8a2b738a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1384,6 +1384,8 @@ RedmineApp::Application.routes.draw do get "switch_role" get 'search_not_group_member' post 'add_members' + get 'search_course_teacher_list' + post 'change_manager' get 'delete_member' get 'archive_course' get 'set_invite_code_halt' diff --git a/db/migrate/20170217004513_update_applied_messages_status.rb b/db/migrate/20170217004513_update_applied_messages_status.rb new file mode 100644 index 000000000..a9100ac09 --- /dev/null +++ b/db/migrate/20170217004513_update_applied_messages_status.rb @@ -0,0 +1,9 @@ +class UpdateAppliedMessagesStatus < ActiveRecord::Migration + def up + sql = "update applied_messages set status = 1 where applied_id in(2495, 2496, 2497)" + execute(sql) + end + + def down + end +end diff --git a/db/migrate/20170217092541_create_training_tasks.rb b/db/migrate/20170217092541_create_training_tasks.rb index 316f38d5b..41331d024 100644 --- a/db/migrate/20170217092541_create_training_tasks.rb +++ b/db/migrate/20170217092541_create_training_tasks.rb @@ -1,12 +1,12 @@ -class CreateTrainingTasks < ActiveRecord::Migration - def change - create_table :training_tasks do |t| - t.integer :project_id - t.integer :tracker_id - t.string :subject - t.text :description - - t.timestamps - end - end -end +class CreateTrainingTasks < ActiveRecord::Migration + def change + create_table :training_tasks do |t| + t.integer :project_id + t.integer :tracker_id + t.string :subject + t.text :description + + t.timestamps + end + end +end diff --git a/db/migrate/20170217092859_add_author_id_to_training_tasks.rb b/db/migrate/20170217092859_add_author_id_to_training_tasks.rb index c5502b7ed..91d2513bc 100644 --- a/db/migrate/20170217092859_add_author_id_to_training_tasks.rb +++ b/db/migrate/20170217092859_add_author_id_to_training_tasks.rb @@ -1,6 +1,6 @@ -class AddAuthorIdToTrainingTasks < ActiveRecord::Migration - def change - add_column :training_tasks, :author_id, :integer - add_column :training_tasks, :status, :integer, :limit => 1, :default => 1 - end -end +class AddAuthorIdToTrainingTasks < ActiveRecord::Migration + def change + add_column :training_tasks, :author_id, :integer + add_column :training_tasks, :status, :integer, :limit => 1, :default => 1 + end +end diff --git a/db/migrate/20170217104309_delete_excess_student_works.rb b/db/migrate/20170217104309_delete_excess_student_works.rb new file mode 100644 index 000000000..d4cee6f7d --- /dev/null +++ b/db/migrate/20170217104309_delete_excess_student_works.rb @@ -0,0 +1,23 @@ +class DeleteExcessStudentWorks < ActiveRecord::Migration + def up + homework = HomeworkCommon.where(:id => 4818) + unless homework.empty? + homework = homework.first + homework.course.student.each do |student| + student_works = homework.student_works.where(:user_id => student.student_id).reorder("created_at asc") + if student_works.count > 1 + if student_works.first.work_status != 0 + student_works.last.destroy + elsif student_works.last.work_status != 0 + student_works.first.destroy + else + student_works.first.destroy + end + end + end + end + end + + def down + end +end diff --git a/public/images/footer_logo/p-nju.png b/public/images/footer_logo/p-nju.png new file mode 100644 index 000000000..42f7ab686 Binary files /dev/null and b/public/images/footer_logo/p-nju.png differ diff --git a/public/images/footer_logo/p-xtu.png b/public/images/footer_logo/p-xtu.png new file mode 100644 index 000000000..c7ba3a334 Binary files /dev/null and b/public/images/footer_logo/p-xtu.png differ diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index febc642d7..a0ee39245 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -101,7 +101,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .mw380 {max-width: 380px !important;}.mw400 {max-width: 400px !important;}.mw450 {max-width: 450px !important;}.mw550 {max-width: 550px !important;} .mt-20 {margin-top:-20px;}.mt-10 {margin-top:-10px;}.mt-4 {margin-top:-4px;}.mt-5 {margin-top:-5px;}.mt-2 {margin-top:-2px;}.mt0 {margin-top: 0px !important;} .mt1{margin-top: 1px;}.mt2{ margin-top:2px;}.mt3{ margin-top:3px;}.mt4{ margin-top:4px;}.mt5{ margin-top:5px;}.mt6{ margin-top:6px;}.mt7 {margin-top:7px;} -.mt8{ margin-top:8px !important;}.mt9{ margin-top:9px !important;}.mt10{ margin-top:10px !important;}.mt12 { margin-top:12px !important;} +.mt8{ margin-top:8px !important;}.mt9{ margin-top:9px !important;}.mt10{ margin-top:10px !important;}.mt12 { margin-top:12px !important;}.mt14 {margin-top:14px;} .mt15 {margin-top:15px;}.mt16{ margin-top:16px !important;}.mt19 {margin-top:19px !important;}.mt20{margin-top: 20px;}.mt28 {margin-top:28px;}.mt30{ margin-top: 30px;} .mt35 {margin-top:35px;}.mt40{ margin-top: 40px;}.mt45{ margin-top: 45px;}.mt50{ margin-top:50px;}.mt100{ margin-top:100px;}.mb0 {margin-bottom: 0px !important;}.mb4{ margin-bottom:4px;} .mb5{ margin-bottom:5px;}.mb8 {margin-bottom:8px !important;}.pb5{ padding-bottom: 5px;}.mb10{ margin-bottom:10px !important;}.mb12 {margin-bottom:12px !important;} diff --git a/public/stylesheets/css/project.css b/public/stylesheets/css/project.css index bbf5b2f14..92b372bb7 100644 --- a/public/stylesheets/css/project.css +++ b/public/stylesheets/css/project.css @@ -363,7 +363,12 @@ a:hover.upload_btn_grey{background:#8a8a8a;} .issues_nav_hover{border-bottom:3px solid #3498db; font-weight:bold; } .issues_nav_nomall {border-bottom:none; } .issues_nav_tag{ background-color:#eaeaea; padding:2px 8px;-webkit-border-radius:15px;-moz-border-radius:15px;-o-border-radius:15px;border-radius:15px; font-size:12px;} -.issues_form_filter{ position: absolute; top:0; right: 0;} +.my_issues_form_filter{ position: absolute; top:0; right: 0; width:520px} +.my_issues_form_filter select{ width:70px; height:30px; border:none; border:none;border-right:none; color: #888; font-size: 12px; line-height: 30px; text-align:center} +.my_issues_form_filter select:focus,.issues_form_filter input:focus{border:none; } +.my_issues_form_filter select.my_issues_filter{ background:none; width:50px; padding: 0px} +.my_issues_form_filter select{appearance:none;-moz-appearance:none;-webkit-appearance:none; background: url("/images/new_project/arrow.png") no-repeat scroll right center transparent;}.issues_form_filter{ position: absolute; top:0; right: 0;} + .issues_form_filter select{ width:70px; height:30px; border:none; border:none;border-right:none; color: #888; font-size: 12px; line-height: 30px; padding-right:10px; background-color:#fff; margin-bottom: 10px; color: #888;} .issues_form_filter select.issues_filter_select_min{width:50px; } .issues_form_filter select:focus,.issues_form_filter input:focus{border:none; } @@ -373,7 +378,7 @@ a:hover.upload_btn_grey{background:#8a8a8a;} .issues_form_filter select::-ms-expand { display: none; } input.issues_calendar_input{ padding-left:5px; color:#444; border-right:none;} .issues_data_img{ display:block; width:25px; height:28px; border:1px solid #c8c8c8; border-left:none; background: url("../images/public_icon.png") -29px 9px no-repeat; } -.issues_list_box{ padding:15px; padding-right: 0px; border-bottom:1px dashed #c8c8c8;} +.issues_list_box{ padding:15px; padding-right: 0px; border-bottom:1px dashed #c8c8c8; position: relative;} .issues_list_titlebox{ font-size:14px; font-weight:bold; margin-bottom:8px;} a.issues_list_title{ color:#444; max-width:380px; overflow:hidden; text-overflow:ellipsis; -o-text-overflow:ellipsis; white-space:nowrap; } a:hover.issues_list_title{color:#3b94d6;} @@ -431,7 +436,7 @@ a:hover.btn_newpro_grey,a:active.btn_newpro_grey{ background: #eaeaea;} .table-td-w180{display:inline-block;with:180px; overflow:hidden; text-overflow:ellipsis; -o-text-overflow:ellipsis; white-space:nowrap;} .table-td-w380{display:inline-block;with:380px; overflow:hidden; text-overflow:ellipsis; -o-text-overflow:ellipsis; white-space:nowrap;} /*项目简介*/ -.pro_new_info{ border:1px solid #ddd; background-color:#fff;} +.pro_new_info{ border:1px solid #ddd; background-color:#fff; width:100%;} .pro_new_info h2{ background: #fff; font-size: 14px; color: #333; height: 40px; line-height: 40px; padding-left: 15px; border-bottom:1px solid #e5e5e5;} .pro_description_new_info{ border:1px solid #ddd; background-color:#fff;} /*.pro_new_info p{ padding-bottom:2px; padding-left: 15px; color: #666; padding-right: 5px}*/ @@ -485,7 +490,7 @@ p.pro_new_grey{ line-height: 1.9; } .new_roadmap_type_hover{color: #fff;} .new_roadmap_nav_tagnomal{ background-color:#eaeaea; padding:0px 5px;-webkit-border-radius:15px;-moz-border-radius:15px;-o-border-radius:15px;border-radius:15px; font-size:12px;} .new_roadmap_nav_taghover{ padding:0px 5px;-webkit-border-radius:15px;-moz-border-radius:15px;-o-border-radius:15px;border-radius:15px; font-size:12px;background: #6bb1e5; color: #fff;} -.new_roadmap_listbox{ padding:15px;border-bottom:1px solid #dbdbdb;} +.new_roadmap_listbox{width: 970px; padding:15px;border-bottom:1px solid #dbdbdb;} .new_roadmap_listbox_commit{ padding:15px;} .new_roadmap_listtitle a{ color: #333;display:block;max-width:800px; overflow:hidden;white-space: nowrap; text-overflow:ellipsis;} .new_roadmap_listtitle a:hover{ color:#3498db;} @@ -582,10 +587,6 @@ select.issues_filter_active { font-weight: bold; color: #333;} .issues_list_txt li.issues_list_max{ width:90px } .btn_newpro_grey{display: inline-block;color: #7b7b7b; border:1px solid #dbdbdb;background:#fff;text-align: center;font-size: 12px; padding:0 15px; height:24px; line-height: 24px; -webkit-border-radius:3px; -moz-border-radius:3px; -o-border-radius:3px; border-radius:3px;} a:hover.btn_newpro_grey,a:active.btn_newpro_grey{ background: #eaeaea;} -.my_issues_form_filter{ position: absolute; top:0; right: 0;} -.my_issues_form_filter select{ width:70px; height:30px; border:none; border:none;border-right:none; color: #888; font-size: 12px; line-height: 30px; text-align:center} -.my_issues_form_filter select.issues_filter_select_min{width:50px; } -.my_issues_form_filter select{appearance:none;-moz-appearance:none;-webkit-appearance:none;} /* 版本库分析20170103byLB*/ #conbox {font-size: 12px; width:100%;} #tags {padding-right: 0px; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px; height: 30px} diff --git a/public/stylesheets/css/public.css b/public/stylesheets/css/public.css index 670721683..7b2f4413c 100644 --- a/public/stylesheets/css/public.css +++ b/public/stylesheets/css/public.css @@ -918,6 +918,7 @@ a.syllabusbox_a_blue{ color:#3b94d6;} .popup_tip_box { position: relative; padding: 5px 10px; white-space: nowrap; background-color: #FFFEF4; border:1px solid #F3DDB3;} .popup_tip_box em { display: block; border-width: 9px; position: absolute; top: 5px; left: -18px; border-style: dashed solid dashed dashed; border-color: transparent #F3DDB3 transparent transparent; font-size: 0; line-height: 0;} .popup_tip_box span { display: block; border-width: 9px;position: absolute; top: 5px; left: -17px; border-style: dashed solid dashed dashed;border-color: transparent #FFFEF4 transparent transparent; font-size: 0; line-height: 0; } +.popup_tip_box>p{ line-height: 20px !important;} /*模拟title*/ .simulation-title {position:absolute; background-color:#fff; padding:5px 10px; z-index:99; white-space:nowrap; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); display:none; color:#666; border:1px solid #666; line-height:1;} /*项目创建*/ diff --git a/spec/controllers/training_tasks_controller_spec.rb b/spec/controllers/training_tasks_controller_spec.rb index d358a1412..cf6be24a8 100644 --- a/spec/controllers/training_tasks_controller_spec.rb +++ b/spec/controllers/training_tasks_controller_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' - -RSpec.describe TrainingTasksController, :type => :controller do - -end +require 'rails_helper' + +RSpec.describe TrainingTasksController, :type => :controller do + +end diff --git a/spec/factories/training_tasks.rb b/spec/factories/training_tasks.rb index 027184bd3..22845a60b 100644 --- a/spec/factories/training_tasks.rb +++ b/spec/factories/training_tasks.rb @@ -1,9 +1,9 @@ -FactoryGirl.define do - factory :training_task do - project_id 1 -tracker_id 1 -subject "MyString" -description "MyText" - end - -end +FactoryGirl.define do + factory :training_task do + project_id 1 +tracker_id 1 +subject "MyString" +description "MyText" + end + +end diff --git a/spec/models/training_task_spec.rb b/spec/models/training_task_spec.rb index c7374ac60..ef8ddbede 100644 --- a/spec/models/training_task_spec.rb +++ b/spec/models/training_task_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' - -RSpec.describe TrainingTask, :type => :model do - pending "add some examples to (or delete) #{__FILE__}" -end +require 'rails_helper' + +RSpec.describe TrainingTask, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end