|
|
|
@ -1791,13 +1791,24 @@ class UsersController < ApplicationController
|
|
|
|
|
def share_news_to_project
|
|
|
|
|
news = News.find(params[:send_id])
|
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
|
# project_ids.each do |project_id|
|
|
|
|
|
# if Project.find(project_id).news.map(&:id).exclude?(news.id)
|
|
|
|
|
# project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now)
|
|
|
|
|
# news.attachments.each do |attach|
|
|
|
|
|
# project_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,
|
|
|
|
|
# :is_public => attach.is_public, :quotes => 0)
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
|
if Project.find(project_id).news.map(&:id).exclude?(news.id)
|
|
|
|
|
project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now)
|
|
|
|
|
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)
|
|
|
|
|
news.attachments.each do |attach|
|
|
|
|
|
project_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,
|
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
|
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,
|
|
|
|
|
:is_public => attach.is_public, :quotes => 0)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|