send resource to org
This commit is contained in:
parent
1103e7eab4
commit
659f322ca2
|
@ -1617,12 +1617,12 @@ class UsersController < ApplicationController
|
|||
@flag = true
|
||||
if params[:send_id].present?
|
||||
send_id = params[:send_id]
|
||||
subfield_id = params[:subfield_id]
|
||||
subfield_id = params[:subfield]
|
||||
if subfield_id.nil?
|
||||
@flag = false
|
||||
end
|
||||
ori = Attachment.find_by_id(send_id)
|
||||
unless org_id.nil?
|
||||
unless subfield_id.nil?
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = OrgSubfield.find(subfield_id)
|
||||
|
@ -1635,33 +1635,31 @@ class UsersController < ApplicationController
|
|||
end
|
||||
elsif params[:send_ids].present?
|
||||
send_ids = params[:send_ids].split(" ")
|
||||
project_ids = params[:projects_ids]
|
||||
if project_ids.nil?
|
||||
subfield_id = params[:subfield]
|
||||
if subfield_id.nil?
|
||||
@flag = false
|
||||
end
|
||||
send_ids.each do |send_id|
|
||||
|
||||
ori = Attachment.find_by_id(send_id)
|
||||
unless project_ids.nil?
|
||||
project_ids.each do |project_id|
|
||||
unless subfield_id.nil?
|
||||
next if ori.blank?
|
||||
attach_copied_obj = ori.copy
|
||||
attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
|
||||
attach_copied_obj.container = Project.find(project_id)
|
||||
attach_copied_obj.container = OrgSubfield.find(subfield_id)
|
||||
attach_copied_obj.created_on = Time.now
|
||||
attach_copied_obj.author_id = User.current.id
|
||||
if attach_copied_obj.attachtype == nil
|
||||
attach_copied_obj.attachtype = 1
|
||||
end
|
||||
attach_copied_obj.save
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@flag=true
|
||||
end
|
||||
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')) "+
|
||||
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','OrgSubfield','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(',')}))").order("created_on desc")
|
||||
@type = params[:type]
|
||||
@limit = 25
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
<%= form_tag add_exist_file_to_org_user_path(user),:remote=>true,:id=>'orgs_list_form' do %>
|
||||
<%= hidden_field_tag(:send_id, send_id) %>
|
||||
<%= hidden_field_tag(:send_ids, send_ids) %>
|
||||
<div class="sectionWrap fl mr15">
|
||||
<ul class="fontGrey3 sectionContent">
|
||||
<% unless @orgs.empty? %>
|
||||
|
|
Loading…
Reference in New Issue