私有课程上传资源都为私有

tmp
huang 10 years ago
parent c11905707d
commit 7898208b16

@ -442,7 +442,12 @@ class Attachment < ActiveRecord::Base
def self.attach_filesex(obj, attachments,attachment_type)
result = obj.save_attachmentsex(attachments, User.current,attachment_type)
if obj.is_public?
public_status = true
else
public_status = false
end
result = obj.save_attachmentsex(attachments, User.current,attachment_type, public_status)
obj.attach_saved_attachments
result
end

@ -33,9 +33,16 @@
<%= link_to("选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select c_lorange",:remote => true) if has_course?(User.current,file) %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<% if @course.is_public? %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open c_blue",:method => :post %>
</span>
<% else %>
<span id="is_public_<%= file.id %>">
<a class="f_l re_open c_blue">私有</a>
</span>
<% end %>
<% else %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>

@ -93,13 +93,13 @@ module Redmine
end
end
def save_attachmentsex(attachments, author=User.current,attachment_type)
def save_attachmentsex(attachments, author=User.current,attachment_type, public_status)
@curattachment_type = attachment_type
result = save_attachments(attachments,author)
result = save_attachments(attachments,author, public_status)
result
end
def save_attachments(attachments, author=User.current)
def save_attachments(attachments, author=User.current,public_status)
# 清除临时文件
if attachments
tempAttach = attachments[:dummy]
@ -140,11 +140,16 @@ module Redmine
end
end
end
if a && !attachment['is_public_checkbox']
if public_status
if a && !attachment['is_public_checkbox']
a.is_public = false
elsif a && attachment['is_public_checkbox']
a.is_public = true
end
else
a.is_public = false
elsif a && attachment['is_public_checkbox']
a.is_public = true
end
set_attachment_public(a) if a
next unless a
a.description = attachment['description'].to_s.strip

Loading…
Cancel
Save