Merge branch 'develop' into cxt_course

This commit is contained in:
cxt 2016-02-26 17:03:19 +08:00
commit 1f25dd4174
8 changed files with 55 additions and 12 deletions

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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'],

View File

@ -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

View File

@ -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 %>
<script>

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160225024759) do
ActiveRecord::Schema.define(:version => 20160224074034) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false

View File

@ -1013,8 +1013,9 @@ function showNormalImage(id) {
var image=$(description_images[i]);
var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element);
$(image).parent().colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
}
$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框
//$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); //有图片才将链接变为弹出框
}
}