diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 7655f1eb4..f7845d6f1 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -633,9 +633,10 @@ update end (render_404; return false) unless @repository @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s - @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip + # gitlab端获取默认分支 + gitlab_branchs = $g.project(@project.gpid).default_branch + @project.gpid.nil? ? (@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip) : (@rev = params[:rev].blank? ? gitlab_branchs : params[:rev].to_s.strip) @rev_to = params[:rev_to] - unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE) if @repository.branches.blank? raise InvalidRevisionParam diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d1f98668c..e6b2a2036 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1592,7 +1592,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 4 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end @save_message = attach_copied_obj.errors.full_messages end end @@ -1628,7 +1630,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 4 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end @save_message = attach_copied_obj.errors.full_messages end end @@ -1686,7 +1690,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 1 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) @@ -1725,7 +1731,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 1 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end unless Project.find(project_id).project_score.nil? Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1) end @@ -1782,7 +1790,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 1 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end end end elsif params[:send_ids].present? @@ -1816,7 +1826,9 @@ class UsersController < ApplicationController if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 1 end - attach_copied_obj.save + if attach_copied_obj.save + ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + end end end else @@ -1845,6 +1857,10 @@ class UsersController < ApplicationController course_ids.each do |course_id| if Course.find(course_id).news.map(&:id).exclude?(news.id) course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + #record forward to table forwards if new record is valid + if course_news.valid? + news.forwards << Forward.new(:to_type => course_news.class.name, :to_id => course_news.id) + end news.attachments.each do |attach| course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1861,6 +1877,10 @@ class UsersController < ApplicationController project = Project.find(project_id) if project.news.map(&:id).exclude?(news.id) message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end news.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1874,6 +1894,10 @@ class UsersController < ApplicationController news = News.find(params[:send_id]) field_id = params[:subfield] org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + # record forward to table forwards if new record is valid + if org_news.valid? + news.forwards << Forward.new(:to_type => org_news.class.name, :to_id => org_news.id) + end news.attachments.each do |attach| org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1889,6 +1913,10 @@ class UsersController < ApplicationController course = Course.find(course_id) if course.news.map(&:id).exclude?(@message.id) message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end @message.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1905,6 +1933,10 @@ class UsersController < ApplicationController project = Project.find(project_id) if project.news.map(&:id).exclude?(@message.id) message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end @message.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1921,6 +1953,10 @@ class UsersController < ApplicationController @message.save board = OrgSubfield.find(field_id).boards.first mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if mes.valid? + @message.forwards << Forward.new(:to_type => mes.class.name, :to_id => mes.id) + end @message.attachments.each do |attach| mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, diff --git a/app/models/attachment.rb b/app/models/attachment.rb index e29f8698f..82f648ad9 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -28,7 +28,7 @@ class Attachment < ActiveRecord::Base belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy - has_many :forwards, :as => :from + has_many :forwards, :as => :from, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end diff --git a/app/models/message.rb b/app/models/message.rb index 6381f444f..24bda5610 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -45,6 +45,8 @@ class Message < ActiveRecord::Base has_many :ActivityNotifies,:as => :activity, :dependent => :destroy + #转发表 + has_many :forwards, :as => :from, :dependent => :destroy after_destroy :delete_org_activities acts_as_searchable :columns => ['subject', 'content'], diff --git a/app/models/news.rb b/app/models/news.rb index d0fccae17..f31c6bcef 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -37,6 +37,9 @@ class News < ActiveRecord::Base has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end + #转发表 + has_many :forwards, :as => :from, :dependent => :destroy + has_many :ActivityNotifies,:as => :activity, :dependent => :destroy validates_presence_of :title, :description diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb index 9d3fe2de8..9e77d3fa8 100644 --- a/app/views/org_document_comments/_new.html.erb +++ b/app/views/org_document_comments/_new.html.erb @@ -1,6 +1,6 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> - <%= javascript_include_tag "des_KindEditor" %> + <%= javascript_include_tag "des_kindEditor" %> <% end %>