diff --git a/Gemfile b/Gemfile index 5fe70bc76..c739e1085 100644 --- a/Gemfile +++ b/Gemfile @@ -47,10 +47,9 @@ group :development do if RUBY_PLATFORM =~ /w32/ gem 'win32console' end - end -group :development, :test do +group :development, :test do unless RUBY_PLATFORM =~ /w32/ gem 'pry-rails' if RUBY_VERSION >= '2.0.0' @@ -59,7 +58,7 @@ group :development, :test do gem 'pry-stack_explorer' if RUBY_PLATFORM =~ /darwin/ gem 'puma' - end + end end gem 'rspec-rails', '~> 3.0' @@ -73,7 +72,7 @@ group :assets do gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby + gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb new file mode 100644 index 000000000..8c551d0df --- /dev/null +++ b/app/controllers/at_controller.rb @@ -0,0 +1,152 @@ +#coding=utf-8 + +class AtController < ApplicationController + respond_to :json + + def show + @logger = Logger.new(Rails.root.join('log', 'at.log').to_s) + users = find_at_users(params[:type], params[:id]) + @users = users + @users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } if users + end + + private + def find_at_users(type, id) + @logger.info("#{type}, #{id}") + case type + when "Issue" + find_issue(id) + when 'Project' + find_project(id) + when 'Course' + find_course(id) + when 'Activity', 'CourseActivity', 'ForgeActivity','UserActivity', 'OrgActivity','PrincipalActivity' + find_activity(id, type) + when 'Attachment' + find_attachment(id) + when 'Message' + find_message(id) + when 'HomeworkCommon' + find_homework(id) + when 'Topic' + find_topic(id) + else + nil + end + end + + def find_topic(id) + + end + + def find_issue(id) + #1. issues list persons + #2. project persons + issue = Issue.find(id) + journals = issue.journals + at_persons = journals.map(&:user) + issue.project.users + at_persons.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } + end + + def find_project(id) + at_persons = Project.find(id).users + at_persons.delete_if { |u| u.id == User.current.id } + end + + def find_course(id) + at_persons = Course.find(id).users + at_persons.delete_if { |u| u.id == User.current.id } + end + + def find_activity(id, type) + + ## 基本上是本类型中的 加上所属类型的用户 + case type + when 'Activity' + activity = Activity.find(id) + (find_at_users(activity.act_type, activity.act_id) ||[]) + + (find_at_users(activity.activity_container_type, activity.activity_container_id) || []) + when 'CourseActivity' + activity = CourseActivity.find(id) + (find_at_users(activity.course_act_type, activity.course_act_id) || []) + (find_course(activity.course.id) || []) + when 'ForgeActivity' + activity = ForgeActivity.find(id) + (find_at_users(activity.forge_act_type, activity.forge_act_id) ||[]) + + (find_project(activity.project_id) || []) + when 'UserActivity' + activity = UserActivity.find(id) + (find_at_users(activity.act_type, activity.act_id) || []) + + (find_at_users(activity.container_type, activity.container_id) || []) + when 'OrgActivity' + activity = OrgActivity.find(id) + (find_at_users(activity.org_act_type, activity.org_act_id) || []) + + (find_at_users(activity.container_type, activity.container_id) || []) + when 'PrincipalActivity' + activity = PrincipalActivity.find(id) + find_at_users(activity.principal_act_type, activity.principal_act_id) + else + nil + end + end + + #作业应该是关联课程,取课程的用户列表 + def find_homework(id) + homework = HomeworkCommon.find(id) + find_course(homework.course_id) + end + + def find_attachment(id) + attachment = Attachment.find(id) + find_at_users(attachment.container_type, attachment.container_id) + end + + #Message + def find_message(id) + message = Message.find(id) + at_persons = message.board.messages.map(&:author) + (at_persons || []) + (find_project(message.board.project_id)||[]) + end + + #News + def find_news(id) + find_project(News.find(id).project_id) + end + + #JournalsForMessage + def find_journals_for_message(id) + jounrnal = JournalsForMessage.find(id) + find_at_users(jounrnal.jour_type, jounrnal.jour_id) + end + + #Poll + def find_poll(id) + end + + #Journal + def find_journal(id) + journal = Journal.find(id) + find_at_users(journal.journalized_type, journal.journalized_id) + end + + #Document + def find_document(id) + find_project(Document.find(id).project_id) + end + + #ProjectCreateInfo + def find_project_create_info(id) + + end + + #Principal + def find_principal(id) + + end + + #BlogComment + def find_blog_comment(id) + blog = BlogComment.find(id).blog + blog.users + end + +end \ No newline at end of file diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d371ed4cb..664dc4cf5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -438,6 +438,46 @@ class AttachmentsController < ApplicationController end end + def add_exist_file_to_org_subfield + file = Attachment.find(params[:file_id]) + org_subfields = params[:org_subfields][:org_subfield] + @message = "" + org_subfields.each do |org_subfield| + s = OrgSubfield.find(org_subfield) + if s.attachments.include?file + if @message && @message == "" + @message += l(:label_resource_subfield_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + else + @message += "
" + l(:label_resource_subfield_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed) + next + end + end + attach_copied_obj = file.copy + attach_copied_obj.tag_list.add(file.tag_list) # tag关联 + attach_copied_obj.container = s + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + @obj = s + @save_flag = attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages + update_quotes attach_copied_obj + end + respond_to do |format| + format.js + end + rescue NoMethodError + @save_flag = false + @save_message = [] << l(:label_resource_subfield_empty_select) + respond_to do |format| + format.js + end + end + def update_quotes attachment if attachment.copy_from attachments = Attachment.find_by_sql("select * from attachments where copy_from = #{attachment.copy_from} or id = #{attachment.copy_from}") diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index b92223edc..7c09e2cdf 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -118,6 +118,7 @@ class BlogCommentsController < ApplicationController @blogComment.content = @quote + @blogComment.content @blogComment.title = "RE: #{@article.title}" unless params[:blog_comment][:title] @article.children << @blogComment + @article.save @user_activity_id = params[:user_activity_id] user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first if user_activity diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 2ec3cac0d..0c3236d4e 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -79,6 +79,13 @@ class BoardsController < ApplicationController end end end + + @project.boards.each do |board| + board.messages.each do |m| + User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} + end + end + elsif @course query_course_messages = @board.messages query_course_messages.each do |query_course_message| @@ -146,6 +153,7 @@ class BoardsController < ApplicationController end end + @page = params[:page] ? params[:page].to_i + 1 : 0 @message = Message.new(:board => @board) #modify by nwb respond_to do |format| diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1b0ead141..aa0e1596f 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -36,17 +36,18 @@ class CoursesController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end + limit = 15 course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id) if course_org_ids.empty? - @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit) @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count else course_org_ids = "(" + course_org_ids.join(',') + ")" - @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit) @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count end # @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,params[:page] + @orgs_page = Paginator.new @org_count, limit,params[:page] @hint_flag = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json respond_to do |format| diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 8fa90ea46..25b5dacec 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -16,10 +16,7 @@ class ExerciseController < ApplicationController exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) end end - end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) - end_exercises.each do |exercise| - exercise.update_column('exercise_status', 3) - end + if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 return @@ -46,10 +43,7 @@ class ExerciseController < ApplicationController exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) end end - end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) - end_exercises.each do |exercise| - exercise.update_column('exercise_status', 3) - end + unless User.current.member_of_course?(@course) || User.current.admin? render_403 return diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 328446fbb..121cd3a42 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -24,7 +24,7 @@ class FilesController < ApplicationController before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment] + before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,:search_files_in_subfield] helper :sort include SortHelper @@ -131,6 +131,45 @@ class FilesController < ApplicationController end end + def search_files_in_subfield + sort = "" + @sort = "" + @order = "" + @is_remote = true + @q = params[:name].strip + if params[:sort] + order_by = params[:sort].split(":") + @sort = order_by[0] + if order_by.count > 1 + @order = order_by[1] + end + sort = "#{@sort} #{@order}" + end + # show_attachments [@course] + begin + q = "%#{params[:name].strip}%" + #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? + if params[:insite] + if q == "%%" + @result = [] + @searched_attach = paginateHelper @result,10 + else + @result = find_public_attache q,sort + @result = visable_attachemnts_insite @result,@org_subfield + @searched_attach = paginateHelper @result,10 + end + else + @result = find_org_subfield_attache q,@org_subfield,sort + @result = visable_attachemnts @result + @searched_attach = paginateHelper @result,10 + @tag_list = attachment_tag_list @result + end + #rescue Exception => e + # #render 'stores' + # redirect_to search_course_files_url + end + end + def find_course_attache keywords,course,sort = "" if sort == "" sort = "created_on DESC" @@ -144,6 +183,19 @@ class FilesController < ApplicationController #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") end + def find_org_subfield_attache keywords,org_subfield,sort = "" + if sort == "" + sort = "created_on DESC" + end + if keywords != "%%" + resultSet = Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' AND filename LIKE :like ", like: "%#{keywords}%"). + reorder(sort) + else + resultSet = Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' "). reorder(sort) + end + #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC") + end + def find_project_attache keywords,project,sort = "" if sort == "" sort = "created_on DESC" @@ -298,10 +350,52 @@ class FilesController < ApplicationController render :layout => 'base_courses' elsif params[:org_subfield_id] + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + when "quotes" + attribute = "quotes" + else + attribute = "created_on" + end + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + else + sort = "#{Attachment.table_name}.created_on desc" + end @container_type = 2 - @organization = Organization.find(params[:organization_id]) @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + @organization = Organization.find(@containers.first.organization_id) show_attachments @containers + @tag_list = attachment_tag_list @all_attachments render :layout => 'base_org' # @subfield = params[:org_subfield_id] end @@ -318,6 +412,12 @@ class FilesController < ApplicationController @can_quote = attachment_candown @file end + def quote_resource_show_org_subfield + @file = Attachment.find(params[:id]) + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @can_quote = attachment_candown @file + end + def new @versions = @project.versions.sort @course_tag = @project.project_type @@ -430,14 +530,29 @@ class FilesController < ApplicationController end elsif @org_subfield @addTag=false - # if params[:in_org_subfield_toolbar] - # @in_org_subfield_toolbar = params[:in_org_subfield_toolbar] - # end attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type]) - # if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') - # Mailer.run.attachments_added(attachments[:files]) - # end + if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array) + params[:org_subfield_attachment_type].each do |type| + tag_name = get_tag_name_by_type_number type + if !attachments.empty? && attachments[:files] && tag_name != "" + attachments[:files].each do |attachment| + attachment.tag_list.add(tag_name) + attachment.save + end + end + end + else + if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5" + tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type] + if !attachments.empty? && attachments[:files] && tag_name != "" + attachments[:files].each do |attachment| + attachment.tag_list.add(tag_name) + attachment.save + end + end + end + end # TODO: 临时用 nyan sort_init 'created_on', 'desc' @@ -446,19 +561,18 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" - @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)] #modify by Long Jun - # @containers += @org_subfield.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)] show_attachments @containers - + @tag_list = attachment_tag_list @all_attachments @attachtype = 0 @contenttype = 0 respond_to do |format| format.js - format.html { - redirect_to org_subfield_files_url(@org_subfield) - } + # format.html { + # redirect_to org_subfield_files_url(@org_subfield) + # } end end end @@ -640,4 +754,34 @@ class FilesController < ApplicationController # format.html end end + + #搜索资源栏目的指定TAG的资源列表 + def search_org_subfield_tag_attachment + @q,@tag_name,@order = params[:q],params[:tag_name] + @is_remote = true + if params[:sort] + order_by = params[:sort].split(":") + @sort = order_by[0] + if order_by.count > 1 + @order = order_by[1] + end + sort = "#{@sort} #{@order}" + end + + q = "%#{@q.strip}%" + @result = find_org_subfield_attache q,@org_subfield,sort + @result = visable_attachemnts @result + @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank? + @searched_attach = paginateHelper @result,10 + @tag_list = get_org_subfield_tag_list @org_subfield + + respond_to do |format| + format.js + # format.html + end + end + + def subfield_upload_file + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + end end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index efbb4ffab..3332f1207 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -147,8 +147,8 @@ class ForumsController < ApplicationController order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}" @order_str = "reorder_time="+params[:reorder_time] else - order = "last_replies_memos.created_at desc, #{Memo.table_name}.created_at desc" - @order_str = "reorder_complex=desc" + order = "#{Memo.table_name}.updated_at desc" + @order_str = "reorder_time=desc" end @memo = Memo.new(:forum => @forum) @topic_count = @forum.topics.count diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a8d6dfe8f..048f62296 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -19,6 +19,14 @@ class HomeworkCommonController < ApplicationController @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] + + #设置at已读 + @homeworks.each do |homework| + homework.journals_for_messages.each do |j| + User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!} + end + end + respond_to do |format| format.js format.html @@ -84,9 +92,20 @@ class HomeworkCommonController < ApplicationController end end + #分组作业 + if @homework.homework_type == 3 + @homework.homework_detail_group ||= HomeworkDetailGroup.new + @homework_detail_group = @homework.homework_detail_group + @homework_detail_group.min_num = params[:min_num].to_i + @homework_detail_group.max_num = params[:max_num].to_i + @homework_detail_group.base_on_project = params[:base_on_project].to_i + end + if @homework.save @homework_detail_manual.save if @homework_detail_manual @homework_detail_programing.save if @homework_detail_programing + @homework_detail_group.save if @homework_detail_group + if params[:is_in_course] == "1" redirect_to homework_common_index_path(:course => @course.id) elsif params[:is_in_course] == "0" @@ -156,6 +175,7 @@ class HomeworkCommonController < ApplicationController end end @homework_detail_manual.update_column('comment_status', 2) + @homework_detail_manual.update_column('evaluation_start', Date.today) @statue = 1 # 匿评开启消息邮件通知 send_message_anonymous_comment(@homework, m_status = 2) @@ -175,6 +195,7 @@ class HomeworkCommonController < ApplicationController #关闭匿评 def stop_anonymous_comment @homework_detail_manual.update_column('comment_status', 3) + @homework_detail_manual.update_column('evaluation_end', Date.today) #计算缺评扣分 work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")" @homework.student_works.each do |student_work| @@ -255,7 +276,13 @@ class HomeworkCommonController < ApplicationController #启动匿评参数设置 def start_evaluation_set - + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] + @course_activity = params[:course_activity].to_i end #设置匿评参数 @@ -271,6 +298,9 @@ class HomeworkCommonController < ApplicationController @homework_detail_manual.evaluation_num = params[:evaluation_num] @homework_detail_manual.save + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7cdc838e2..a132ec295 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -24,7 +24,7 @@ class IssuesController < ApplicationController before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -81,12 +81,15 @@ class IssuesController < ApplicationController @status_id = params[:status_id] @subject = params[:subject] @issue_count = @query.issue_count - @issue_pages = Paginator.new @issue_count, @limit, params['page'] + @issue_pages = Paginator.new @issue_count, @limit, params['page'].to_i + 1 @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], :order => sort_clause, :offset => @offset, :limit => @limit) + if params[:set_filter] + @set_filter = params[:set_filter] + end @issue_count_by_group = @query.issue_count_by_group respond_to do |format| format.js @@ -115,6 +118,14 @@ class IssuesController < ApplicationController # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query.update_attribute(:viewed, true) unless query.nil? + + # issue 新建的at消息 + User.current.at_messages.unviewed('Issue', @issue.id).each {|x| x.viewed!} + # 回复的at消息 + @issue.journals.each do |j| + User.current.at_messages.unviewed('Journal', j.id).each {|x| x.viewed!} + end + # 缺陷状态更新 query_journals = @issue.journals query_journals.each do |query_journal| @@ -142,24 +153,17 @@ class IssuesController < ApplicationController @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq - #id name email - #1. issues list persons - #2. project persons - @at_persons = @journals.map(&:user) + @issue.project.users - @at_persons = @at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} - @at_persons = nil - - respond_to do |format|`` - format.html { - retrieve_previous_and_next_issue_ids - render :template => 'issues/show', :layout => @project_base_tag#by young - } - format.api - format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } - format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) - } + respond_to do |format| + format.html { + retrieve_previous_and_next_issue_ids + render :template => 'issues/show', :layout => @project_base_tag#by young + } + format.api + format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } + format.pdf { + pdf = issue_to_pdf(@issue, :journals => @journals) + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) + } end end @@ -216,7 +220,7 @@ class IssuesController < ApplicationController @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) saved = false begin - saved = @issue.save_issue_with_child_records(params, @time_entry) + @saved = @issue.save_issue_with_child_records(params, @time_entry) rescue ActiveRecord::StaleObjectError @conflict = true if params[:last_journal_id] @@ -225,7 +229,7 @@ class IssuesController < ApplicationController end end - if saved + if @saved #修改界面增加跟踪者 watcherlist = @issue.watcher_users select_users = [] @@ -254,13 +258,16 @@ class IssuesController < ApplicationController 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? + #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 @@ -398,6 +405,9 @@ class IssuesController < ApplicationController user_activity.updated_at = jour.created_on user_activity.save @user_activity_id = params[:user_activity_id] + if params[:issue_id] + @issue_id = params[:issue_id] + end respond_to do |format| format.js end @@ -421,6 +431,43 @@ class IssuesController < ApplicationController end end + #对某个journ回复,显示回复框 + def reply + @issue = Issue.find(params[:id]) + @jour = Journal.find(params[:journal_id]) + @tempContent = "
#{ll(Setting.default_language, :text_user_wrote, @jour.user.realname.blank? ? @jour.user.login: @jour.user.realname)}
#{@jour.notes.html_safe}
".html_safe + respond_to do |format| + format.js + end + end + + #给issue添加journ。回复内容包含 对某个被回复的journ的内容 + def add_reply + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:quote]+params[:notes] + @issue = Issue.find params[:id] + jour.journalized = @issue + jour.save + user_activity = UserActivity.where("act_type='Issue' and act_id =#{@issue.id}").first + user_activity.updated_at = jour.created_on + user_activity.save + respond_to do |format| + format.js + end + end + end + + # + def delete_journal + @issue = Issue.find(params[:id]) + Journal.destroy(params[:journal_id]) + respond_to do |format| + format.js + end + end + private def find_project diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 2d2c058d4..a47ddf787 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -159,7 +159,8 @@ class MemosController < ApplicationController @memo.update_column(:content, params[:memo][:content]) && @memo.update_column(:sticky, params[:memo][:sticky]) && @memo.update_column(:lock, params[:memo][:lock]) && - @memo.update_column(:subject,params[:memo][:subject])) + @memo.update_column(:subject,params[:memo][:subject]) && + @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ab2cfa2ba..ccebdccfa 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -75,17 +75,18 @@ class ProjectsController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end + limit = 15 project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id) if project_org_ids.empty? - @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit) @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count else project_org_ids = "(" + project_org_ids.join(',') + ")" - @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit) @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count end # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,params[:page] + @orgs_page = Paginator.new @org_count, limit,params[:page] @no_roll_hint = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json respond_to do |format| diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b35471286..0b2b6bd1c 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -348,13 +348,10 @@ update # end # end - - - @changesets = g.commits(@project.gpid, :ref_name => @rev) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count - @changesets_all_count = 0 + @changesets_all_count = changesets_num(@project) @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories @@ -377,19 +374,6 @@ update alias_method :browse, :show - #add by hx - def count_commits(project_id , left , right) - count = 0 - (left..right).each do |page| - if $g.commits(project_id,:page => page).count == 0 - break - else - count = count + $g.commits(project_id,:page => page).count - end - end - return count - end - def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry @@ -399,26 +383,10 @@ update @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) #add by hx - if g.commits(@project.gpid , :page=>200).count > 0 - count = 4020 - elsif g.commits(@project.gpid , :page=>25).count==0 - count = count_commits(@project.gpid , 0 , 25) - elsif g.commits(@project.gpid , :page=>50).count ==0 - count = count_commits(@project.gpid , 25 , 50)+ 25 * 20 - elsif g.commits(@project.gpid , :page=>75).count ==0 - count = count_commits(@project.gpid , 50 , 75)+ 50 * 20 - elsif g.commits(@project.gpid , :page=>100).count==0 - count = count_commits(@project.gpid , 75 , 100) + 75 * 20 - elsif g.commits(@project.gpid , :page=>125).count==0 - count = count_commits(@project.gpid , 100 , 125) + 100 * 20 - elsif g.commits(@project.gpid , :page=>150).count==0 - count = count_commits(@project.gpid , 125 , 150) + 125 * 20 - else - count = count_commits(@project.gpid , 150 ,200) + 150 * 20 - end + #rep_count = commit_count(@project) #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 - @commits_count = count + @commits_count = params[:commit_count].to_i @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commit = g.commit(@project.gpid,@rev) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index d20a58b75..e0aff6254 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -120,15 +120,16 @@ class SchoolController < ApplicationController condition.scan(/./).each_with_index do |char,index| if char =~ /[a-zA-Z0-9]/ pinyin << char + elsif char =~ /\'/ else chinese << char end end if(condition == '') - @school = School.page((params[:page].to_i || 1) - 1).per(100) + @school = School.reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.count else - @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").page((params[:page].to_i || 1) - 1).per(100) + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('pinyin').page((params[:page].to_i || 1) - 1).per(100) @school_count = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b79adda2d..5cb646c8e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -215,7 +215,6 @@ class StudentWorkController < ApplicationController student_work ||= StudentWork.new student_work.name = params[:student_work][:name] student_work.description = params[:student_work][:description] - student_work.project_id = params[:student_work][:project_id] student_work.homework_common_id = @homework.id student_work.user_id = User.current.id student_work.save_attachments(params[:attachments]) @@ -305,15 +304,28 @@ class StudentWorkController < ApplicationController @work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@work) if @work.save + if @homework.homework_type == 3 + @student_work_project = @homework.student_work_projects.where("user_id=?",User.current.id).first + student_work_projects = @homework.student_work_projects.where("student_work_id=? and is_leader =?",@work.id,0) + student_work_projects.delete_all + members = params[:group_member_ids].split(',') + for i in 1 .. members.count-1 + stu_project = StudentWorkProject.new + stu_project.homework_common_id = @homework.id + stu_project.student_work_id = @work.id + if @homework.homework_detail_group.base_on_project == 1 + stu_project.project_id = @student_work_project.project_id + else @homework.homework_detail_group.base_on_project == 0 + stu_project.project_id = -1 + end + stu_project.user_id = members[i].to_i + stu_project.is_leader = 0 + stu_project.save + end + end + course_message = CourseMessage.new(:user_id =>User.current.id,:content=>"edit",:course_message_id=>@work.id,:course_id => @course.id,:course_message_type=>"StudentWork", :status => 9) #作品提交记录 course_message.save -=begin - respond_to do |format| - format.html { - flash[:notice] = l(:notice_successful_edit) - redirect_to student_work_index_url(:homework => @homework.id) - } -=end @student_work = @work respond_to do |format| format.js @@ -689,7 +701,12 @@ class StudentWorkController < ApplicationController unless params[:name].nil? name = params[:name] end - all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")" + if @homework.homework_detail_group.base_on_project == 0 + all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")" + else + pro = Project.find @homework.student_work_projects.where("user_id=?",User.current.id).first.project_id + all_student_ids = "(" + pro.members.map{|member| member.user_id}.join(",") + ")" + end all_students = User.where("id in #{all_student_ids}") @commit_student_ids = @homework.student_work_projects.map{|student| student.user_id} @users = searchstudent_by_name all_students,name diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index cb61177f5..d40bc7c7c 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -227,6 +227,12 @@ class TagsController < ApplicationController @tag_list = get_course_tag_list @course @select_tag_name = params[:select_tag_name] end + + if @obj && @object_flag == '6' && @obj.container.kind_of?(OrgSubfield) + @org_subfield = @obj.container + @tag_list = get_org_subfield_tag_list @org_subfield + @select_tag_name = params[:select_tag_name] + end # end end end @@ -314,6 +320,86 @@ class TagsController < ApplicationController end end + def update_org_subfield_tag_name + @tag_name = params[:tagName] + @rename_tag_name = params[:renameName] + @taggable_id = params[:taggableId] + @taggable_type = numbers_to_object_type(params[:taggableType]) + @rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag + @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id + @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank? + @obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank? + if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。 + if params[:org_subfield_id] + org_subfield = OrgSubfield.find params[:org_subfield_id] + if org_subfield + org_subfield.attachments.each do |attachment| + taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class) + if taggings + taggings.delete + attachment.tag_list.add(@rename_tag_name.split(",")) + attachment.save + end + end + end + end + else + if(@rename_tag.nil?) #这次命名的是新的tag + + # 是否还有其他记录 引用了 tag_id + @tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}") + # 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字 + if @tagging.count == 1 + @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) + @tag.update_attributes({:name=>@rename_tag_name}) + else #如果tagging表中的记录大于1,那么就要新增tag记录 + + unless @obj.nil? + @obj.tag_list.add(@rename_tag_name.split(",")) + @obj.save + end + #删除原来的对应的taggings的记录 + unless @taggings.nil? + @taggings.delete + end + end + else #这是已有的tag + # 更改taggings记录里的tag_id + unless @taggings.nil? + @taggings.update_attributes({:tag_id=>@rename_tag.id}) + end + end + end + + @obj_flag = params[:taggableType] + if @obj && @obj_flag == '6' && @obj.container.kind_of?(OrgSubfield) + @org_subfield = @obj.container + @tag_list = @tag_list = get_org_subfield_tag_list @org_subfield + elsif params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @tag_list = get_org_subfield_tag_list @org_subfield + + #这里要引用FilesController里的逻辑了。将资源库当前的文件列表刷新一遍。 + @flag = params[:flag] || false + sort = "" + @sort = "" + @order = "" + @is_remote = false + @isproject = false + + sort = "#{Attachment.table_name}.created_on desc" + + @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + + show_attachments @containers + elsif @obj && @obj_flag == '5' + @forum = @obj + end + respond_to do |format| + format.js + end + end + def show_attachments obj @attachments = [] obj.each do |container| @@ -372,6 +458,10 @@ class TagsController < ApplicationController @course = @obj.container @tag_list = @tag_list = get_course_tag_list @course end + if @obj && @obj_flag == '6' && @obj.container.kind_of?(OrgSubfield) + @org_subfield = @obj.container + @tag_list = @tag_list = get_org_subfield_tag_list @org_subfield + end respond_to do |format| format.js format.html diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b6d336547..281b8b7e0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -415,6 +415,7 @@ class UsersController < ApplicationController def user_select_homework homework = HomeworkCommon.find_by_id params[:checkMenu] homework_detail_programing = homework.homework_detail_programing + homework_detail_group = homework.homework_detail_group @homework = HomeworkCommon.new @select_course = params[:select_course] || 0 if homework @@ -444,6 +445,14 @@ class UsersController < ApplicationController ) end end + + if homework_detail_group + @homework.homework_detail_group = HomeworkDetailGroup.new + @homework_detail_group = @homework.homework_detail_group + @homework_detail_group.min_num = homework_detail_group.min_num + @homework_detail_group.max_num = homework_detail_group.max_num + @homework_detail_group.base_on_project = homework_detail_group.base_on_project + end end respond_to do |format| format.js @@ -1432,7 +1441,8 @@ class UsersController < ApplicationController def search_user_course @user = User.current if !params[:search].nil? - @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like '%#{params[:search.to_s]}%'") + search = "%#{params[:search].to_s.strip.downcase}%" + @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) .select { |course| @user.allowed_to?(:as_teacher,course)} else @course = @user.courses @@ -1451,7 +1461,8 @@ class UsersController < ApplicationController def search_user_project @user = User.current if !params[:search].nil? - @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like '%#{params[:search.to_s]}%'") + search = "%#{params[:search].to_s.strip.downcase}%" + @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) else @projects = @user.projects end @@ -1866,46 +1877,46 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search - search = params[:search].to_s.strip.downcase + search = "%#{params[:search].strip.downcase}%" if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") + " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like :p) ",:p=>search).order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like '%#{search}%') ").order("created_on desc") + " and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ - " and (filename like '%#{search}%') ").order("created_on desc") + " and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like '%#{search}%') ").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "4" #附件 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") end elsif params[:type] == "5" #用户资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") end end @type = params[:type] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a9563b73..c4bbc4ebb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -668,6 +668,42 @@ module ApplicationHelper return rep.blank? ? true :false end + # 获取Gitlab版本库提交总数 + def commit_count(project) + g = Gitlab.client + #add by hx + if g.commits(project.gpid , :page=>200).count > 0 + count = 4020 + elsif g.commits(project.gpid , :page=>25).count==0 + count = count_commits(project.gpid , 0 , 25) + elsif g.commits(project.gpid , :page=>50).count ==0 + count = count_commits(project.gpid , 25 , 50)+ 25 * 20 + elsif g.commits(project.gpid , :page=>75).count ==0 + count = count_commits(project.gpid , 50 , 75)+ 50 * 20 + elsif g.commits(project.gpid , :page=>100).count== 0 + count = count_commits(project.gpid , 75 , 100) + 75 * 20 + elsif g.commits(project.gpid , :page=>125).count==0 + count = count_commits(project.gpid , 100 , 125) + 100 * 20 + elsif g.commits(project.gpid , :page=>150).count==0 + count = count_commits(project.gpid , 125 , 150) + 125 * 20 + else + count = count_commits(project.gpid , 150 ,200) + 150 * 20 + end + end + + #add by hx + def count_commits(project_id , left , right) + count = 0 + (left..right).each do |page| + if $g.commits(project_id,:page => page).count == 0 + break + else + count = count + $g.commits(project_id,:page => page).count + end + end + return count + end + # 获取单一gitlab项目 def gitlab_repository(project) rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first @@ -1716,6 +1752,13 @@ module ApplicationHelper # def javascript_include_tag(*sources) options = sources.last.is_a?(Hash) ? sources.pop : {} + + @sources ||= [] + sources = sources.delete_if do|source| + @sources.include?(source) + end + @sources += sources + if plugin = options.delete(:plugin) sources = sources.map do |source| if plugin @@ -1725,7 +1768,12 @@ module ApplicationHelper end end end - super sources, options + + if sources && !sources.empty? + super(sources, options) + else + '' + end end def content_for(name, content = nil, &block) @@ -1924,6 +1972,8 @@ module ApplicationHelper elsif attachment.container.is_a?(Course) course = attachment.container candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1) + elsif attachment.container.is_a?(OrgSubfield) + candown = true elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board && attachment.container.board.course course = attachment.container.board.course @@ -1934,7 +1984,9 @@ module ApplicationHelper candown = true elsif attachment.container.class.to_s=="StudentWork" candown = true - elsif attachment.container.class.to_s=="BlogComment" + elsif attachment.container.class.to_s=="BlogComment" #博客资源允许下载 + candown = true + elsif attachment.container.class.to_s=="Memo" #论坛资源允许下载 candown = true elsif attachment.container.class.to_s == "User" candown = (attachment.is_public == 1 || attachment.is_public == true || attachment.author_id == User.current.id) @@ -2378,6 +2430,15 @@ module ApplicationHelper tag_list end + def get_org_subfield_tag_list org_subfield + all_attachments = org_subfield.attachments.select{|attachment| attachment.is_public? || + (attachment.container_type == "OrgSubfield" && User.current.member_of_org?(org_subfield.organization))|| + attachment.author_id == User.current.id + } + tag_list = attachment_tag_list all_attachments + tag_list + end + #获取匿评相关连接代码 def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1) if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") @@ -2663,18 +2724,11 @@ int main(int argc, char** argv){ end def import_ke(default_opt={}) - opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt + opt = {enable_at: false, prettify: false, init_activity: false}.merge default_opt ss = '' - if opt[:enable_at] - ss = '" + unless Setting.at_enabled? + opt[:enable_at] = false end ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg') diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index b0d0118e5..aba2fb58e 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -43,8 +43,9 @@ module ExerciseHelper ecs.each do |ec| arr << ec.exercise_choice.choice_position end - arr.sort - arr = arr.join("") + #arr = arr.sort + str = arr.sort.join("") + return str end # 判断用户是否已经提交了问卷 diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index cf9cbcc32..bd023f6d0 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -67,6 +67,17 @@ module FilesHelper s.html_safe end + #带勾选框的组织资源栏目列表 + def org_subfields_check_box_tags(name,org_subfields,attachment) + s = '' + org_subfields.each do |org_subfield| + if !org_subfield.attachments.include?attachment + s << "
" + end + end + s.html_safe + end + #判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期 def has_course? user,file result = false @@ -141,6 +152,12 @@ module FilesHelper result << attachment end end + elsif obj.is_a?(OrgSubfield) + attachments.each do |attachment| + if attachment.is_public? || (attachment.container_type == "OrgSubfield" && attachment.container_id == obj.id )|| attachment.author_id == User.current.id + result << attachment + end + end end end result diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 104cd16cb..d73e1592e 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -22,7 +22,10 @@ module ProjectScoreHelper #代码提交数量 def changesets_num project - project.changesets.count + g = Gitlab.client + project.gpid.nil? ? 0 : g.commits_total_count(project.gpid).count + # # commits_total_count(project.gpid) + # project.changesets.count end #讨论区帖子数量 diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 51d1846d8..afc6cb1d9 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -19,6 +19,7 @@ include AvatarHelper include StudentWorkHelper +include ApiHelper module ProjectsHelper def link_to_version(version, options = {}) return '' unless version && version.is_a?(Version) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2935d018a..963284f7f 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -89,7 +89,8 @@ module UsersHelper forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count = user.at_messages.where(viewed: false).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count end def user_mail_notification_options(user) diff --git a/app/models/at_message.rb b/app/models/at_message.rb new file mode 100644 index 000000000..3d20ffafb --- /dev/null +++ b/app/models/at_message.rb @@ -0,0 +1,102 @@ +#coding=utf-8 + +class AtMessage < ActiveRecord::Base + belongs_to :user + belongs_to :sender, class_name: "User", foreign_key: "sender_id" + attr_accessible :at_message, :container, :viewed, :user_id, :sender_id + belongs_to :at_message, polymorphic: true + belongs_to :container, polymorphic: true + + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy + validates :user_id, :sender_id, :at_message_id, :at_message_type, presence: true + + after_create :add_user_message + + scope :unviewed, ->(type, id){ + where(at_message_type: type, at_message_id:id, viewed: false) + } + + def viewed! + update_attribute :viewed, true + end + + def at_valid? + return true if at_message_type == 'Issue' + return true if 'Journal' == at_message_type + return true if 'JournalsForMessage' == at_message_type + return true if 'Message' == at_message_type + false + end + + def add_user_message + if MessageAll.where(message_type: self.class.name,message_id: self.id).empty? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end + end + + def subject + case at_message_type + when "Issue" + "新建问题: " + at_message.subject + when "Journal" + "问题留言: " + at_message.journalized.subject + when 'Message' + if(at_message.topic?) + "发布新帖: " + else + "回复帖子: " + end + at_message.subject + when 'JournalsForMessage' + "作业: #{at_message.jour.name} 中留言" + else + logger.error "error type: #{at_message_type}" + end + end + + def description + case at_message_type + when "Issue" + at_message.description + when "Journal" + at_message.notes + when 'Message' + at_message.content + when "JournalsForMessage" + at_message.notes + else + logger.error "error type: #{at_message_type}" + end + end + + def author + case at_message_type + when "Issue" + at_message.author + when "Journal" + at_message.user + when 'Message' + at_message.author + when 'JournalsForMessage' + at_message.user + else + logger.error "error type: #{at_message_type}" + end + end + + def url + case at_message_type + when "Issue" + {controller: :issues, action: :show, id: at_message} + when "Journal" + {controller: :issues, action: :show, id: at_message.journalized} + when 'Message' + {controller: :boards, action: :show, project_id: at_message.board.project, id: at_message.board} + when 'JournalsForMessage' + {controller: :homework_common, action: :index, course: at_message.jour.course_id} + else + logger.error "error type: #{at_message_type}" + end + + end + +end diff --git a/app/models/issue.rb b/app/models/issue.rb index edce3310a..5ecb3e36f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -52,6 +52,7 @@ class Issue < ActiveRecord::Base # ForgeMessage虚拟关联(多态) has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy + has_many :at_messages, class_name: 'AtMessage', as: :at_message ,:dependent => :destroy acts_as_nested_set :scope => 'root_id', :dependent => :destroy acts_as_attachable :before_add => :attachment_added, :after_remove => :attachment_removed @@ -82,7 +83,7 @@ class Issue < ActiveRecord::Base attr_reader :current_journal # fq - after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message + after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message after_update :be_user_score after_destroy :down_user_score # after_create :be_user_score @@ -156,6 +157,14 @@ class Issue < ActiveRecord::Base end end + # at 功能添加消息提醒 + def act_as_at_message + users = self.description.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) + end + end + # 更新缺陷 #def act_as_forge_message_update # unless self.author_id == self.assigned_to_id diff --git a/app/models/journal.rb b/app/models/journal.rb index 9ffc5d405..638a98006 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -28,10 +28,12 @@ class Journal < ActiveRecord::Base has_one :journal_reply has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 被ForgeActivity虚拟关联 - has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + #has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy 评论不应该算入 # 被ForgeMessage虚拟关联 has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy - # end + + has_many :at_messages, as: :at_message, dependent: :destroy + attr_accessor :indice acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" }, @@ -50,7 +52,7 @@ class Journal < ActiveRecord::Base before_create :split_private_notes # fq - after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message + after_save :act_as_activity,:be_user_score, :act_as_forge_message, :act_as_at_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -160,14 +162,14 @@ class Journal < ActiveRecord::Base end # end - # Time 2015-02-27 13:30:19 - # Author lizanle - # Description 公共表中需要保存一份该记录 - def act_as_forge_activity - self.forge_acts << ForgeActivity.new(:user_id => self.user_id, - :project_id => self.issue.project.id) - - end + # # Time 2015-02-27 13:30:19 + # # Author lizanle + # # Description 公共表中需要保存一份该记录 + # def act_as_forge_activity + # self.forge_acts << ForgeActivity.new(:user_id => self.user_id, + # :project_id => self.issue.project.id) + # + # end # 缺陷状态更改,消息提醒 def act_as_forge_message @@ -184,6 +186,13 @@ class Journal < ActiveRecord::Base end end + def act_as_at_message + users = self.notes.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id) + end + end + # 更新用户分数 -by zjc def be_user_score #新建了缺陷留言且留言不为空,不为空白 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 396133c7a..59da817f4 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -64,8 +64,10 @@ class JournalsForMessage < ActiveRecord::Base has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy + has_many :at_messages, as: :at_message, dependent: :destroy + validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -240,6 +242,12 @@ class JournalsForMessage < ActiveRecord::Base end end + def act_as_at_message + users = self.notes.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id) + end + end # 用户留言消息通知 def act_as_user_feedback_message # 主留言 diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 8891e6552..551ddd616 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -395,13 +395,13 @@ class Mailer < ActionMailer::Base user = User.find_by_mail(recipients) @user = user @token = Token.get_token_from_user(user, 'autologin') - @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) + @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id) # edit - @issue_author_url = url_for(user_activities_url(@author,:token => @token.value)) - @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + @issue_author_url = url_for(user_activities_url(@author)) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id) - @user_url = url_for(my_account_url(user,:token => @token.value)) + @user_url = url_for(my_account_url(user)) subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" @@ -471,7 +471,7 @@ class Mailer < ActionMailer::Base recipients = @project.manager_recipients s = l(:text_applied_project, :id => "##{@user.show_name}", :project => @project.name) @token = Token.get_token_from_user(@user, 'autologin') - @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members', :token => @token.value) + @applied_url = url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'members') mail :to => recipients, :subject => s end diff --git a/app/models/message.rb b/app/models/message.rb index d8f62171a..4cdae1f6e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -38,7 +38,7 @@ class Message < ActiveRecord::Base # 课程/项目 消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy - #end + has_many :at_messages, as: :at_message, dependent: :destroy has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -74,7 +74,7 @@ class Message < ActiveRecord::Base after_update :update_messages_board after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets - after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score + after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message #before_save :be_user_score scope :visible, lambda {|*args| @@ -96,6 +96,10 @@ class Message < ActiveRecord::Base end } + def topic? + parent_id.nil? + end + def visible?(user=User.current) if project !user.nil? && user.allowed_to?(:view_messages, project) @@ -237,6 +241,13 @@ class Message < ActiveRecord::Base end end end + + def act_as_at_message + users = self.content.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) + end + end #更新用户分数 -by zjc def be_user_score diff --git a/app/models/news.rb b/app/models/news.rb index 53581a536..a7407c91f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -41,7 +41,7 @@ class News < ActiveRecord::Base validates_presence_of :title, :description validates_length_of :title, :maximum => 60 validates_length_of :summary, :maximum => 255 - validates_length_of :description, :maximum => 10000 + # validates_length_of :description, :maximum => 10000 acts_as_attachable :delete_permission => :manage_news acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project diff --git a/app/models/repository.rb b/app/models/repository.rb index f50f37f31..571bba1b9 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -107,7 +107,7 @@ class Repository < ActiveRecord::Base def scm unless @scm @scm = self.scm_adapter.new(url, root_url, - login, password, path_encoding) + login, password, path_encoding, project_id) if root_url.blank? && @scm.root_url.present? update_attribute(:root_url, @scm.root_url) end diff --git a/app/models/user.rb b/app/models/user.rb index 0c8d65481..2714117e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -161,6 +161,7 @@ class User < Principal has_many :user_feedback_messages has_one :onclick_time has_many :system_messages + has_many :at_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" @@ -400,16 +401,7 @@ class User < Principal end def show_name - name = "" - unless self.user_extensions.nil? - if self.user_extensions.identity == 2 - name = firstname - else - name = lastname+firstname - end - else - name = lastname+firstname - end + name = lastname + firstname name.empty? || name.nil? ? login : name end ## end diff --git a/app/views/at/show.json.erb b/app/views/at/show.json.erb new file mode 100644 index 000000000..5341f251e --- /dev/null +++ b/app/views/at/show.json.erb @@ -0,0 +1,6 @@ +[ + <% @users && @users.each_with_index do |person,index| %> + {"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} + <%= index != @users.size-1 ? ',' : '' %> + <% end %> +] diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index ab8b80dcb..aac365a15 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -7,8 +7,10 @@ <% if defined?(container) && container && container.saved_attachments %> <% container.attachments.each_with_index do |attachment, i| %> - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>: - <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly => 'readonly') %> + <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> + + <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> <%= if attachment.id.nil? #待补充代码 else @@ -21,24 +23,7 @@
<% end %> - <% container.saved_attachments.each_with_index do |attachment, i| %> - - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %> - <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> - <%= l(:field_is_public) %>: - <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> - <%= if attachment.id.nil? - #待补充代码 - else - link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') - end - %> - <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> - <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - -
- <% end %> <% end %>
<% project = project %> diff --git a/app/views/attachments/add_exist_file_to_org_subfield.js.erb b/app/views/attachments/add_exist_file_to_org_subfield.js.erb new file mode 100644 index 000000000..4c4208f76 --- /dev/null +++ b/app/views/attachments/add_exist_file_to_org_subfield.js.erb @@ -0,0 +1,8 @@ +<% if !@save_flag && @save_message %> + $("#error_show").html("<%= @save_message.join(', ') %>"); +<% elsif @message && @message != "" %> + $("#error_show").html("<%= @message.html_safe %>"); +<% else %> + closeModal(); + location.reload(); +<% end %> \ No newline at end of file diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 5958fccff..815ff27e4 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -15,10 +15,10 @@ <% if edit_mode %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0 %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0,act_id: @course.id, act_type: @course.class.to_s %> <% else %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0 %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0, act_id: @course.id, act_type: @course.class.to_s %> <% end %>
diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb index c7065ece4..048402635 100644 --- a/app/views/blog_comments/_edit.html.erb +++ b/app/views/blog_comments/_edit.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <%= javascript_include_tag 'blog' %> <% end %> @@ -34,7 +34,9 @@ :class => 'talk_text fl', :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + act_id: article.id, act_type: article.class.to_s + %>

diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb index 32f4333c2..67642069c 100644 --- a/app/views/blog_comments/_reply_form.html.erb +++ b/app/views/blog_comments/_reply_form.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <% end %>
  • @@ -27,7 +27,9 @@ :minHeight=>100, :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + at_id: article.id, at_type: article.class.to_s + %>

  • diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb index 088b2cf67..cd53707d5 100644 --- a/app/views/blog_comments/quote.js.erb +++ b/app/views/blog_comments/quote.js.erb @@ -3,7 +3,7 @@ if($("#reply_message_<%= @blogComment.id%>").length > 0) { $(function(){ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); - init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%", "<%=@blogComment.class.to_s%>"); }); }else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

    "); diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index 1cb64b2b5..06adca74d 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -1,7 +1,7 @@ <% if @in_user_center%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); - init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity'); <% else%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity'); <% end %> \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index e46a7249f..aa984c621 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -27,7 +27,7 @@ } } $(function() { - init_activity_KindEditor_data(<%= @article.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @article.id%>,null,"85%", '<%=@article.class.to_s%>'); showNormalImage('message_description_<%= @article.id %>'); }); diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index a91dd8151..f6383c95b 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -74,7 +74,7 @@ } $(function () { - init_activity_KindEditor_data(<%= topic.id%>, null, "87%"); + init_activity_KindEditor_data(<%= topic.id%>, null, "87%", "<%=topic.class.to_s%>"); showNormalImage('activity_description_<%= topic.id %>'); /*var description_images=$("div#activity_description_<%#= topic.id %>").find("img"); if (description_images.length>0) { diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index e4cf57ae3..31cdf41eb 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <% end %> <%= error_messages_for 'message' %> @@ -34,7 +34,9 @@ :class => 'talk_text fl', :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + at_id: topic.id, at_type: topic.class.to_s + %>

    diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 306a0c7ce..de3b038e6 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,20 +1,3 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> - <%= javascript_include_tag "init_activity_KindEditor" %> -<% end %> - - - <% if topic %> - <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> - <% end %> - <% end %> - - <% if topics.count == 10 %> -
    展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
    - <% end %> -<% end%> + <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %> - - diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb new file mode 100644 index 000000000..c324f1d69 --- /dev/null +++ b/app/views/boards/_course_show_detail.html.erb @@ -0,0 +1,70 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag "init_activity_KindEditor" %> +<% end %> + + +<% if topics%> + <% topics.each do |topic| %> + + <% if topic %> + <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> + <% end %> + <% end %> + + <% if topics.count == 10 %> +
    展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
    + <% end %> +<% end%> + + \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 5f6275e9d..839d587b2 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -20,7 +20,7 @@ <% end %>
    -