1、课程、项目讨论区编辑附件没有公开字样问题。2、设置附件私有属性遗漏讨论区的附件的情况添加。3、编辑附件的描述、公开属性无效的问题,原因编辑保存逻辑存在问题,修正
This commit is contained in:
parent
0633d5661e
commit
ef3e0798cc
|
@ -411,6 +411,17 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Finds an attachment that matches the given token
|
||||
def self.find_by_token_only(token)
|
||||
if token.to_s =~ /^(\d+)\.([0-9a-f]+)$/
|
||||
attachment_id, attachment_digest = $1, $2
|
||||
attachment = Attachment.where(:id => attachment_id, :digest => attachment_digest).first
|
||||
if attachment
|
||||
attachment
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Bulk attaches a set of files to an object
|
||||
#
|
||||
# Returns a Hash of the results:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
|
||||
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
|
||||
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
|
||||
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, :class => 'is_public')%>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
|
@ -18,6 +19,7 @@
|
|||
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
|
||||
link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
|
||||
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
|
||||
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
|
||||
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, :class => 'is_public')%>
|
||||
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
|
||||
</span>
|
||||
|
|
|
@ -79,9 +79,11 @@ module Redmine
|
|||
if res.is_public
|
||||
if( (self.class.to_s=="Project" && self.is_public == false) ||
|
||||
(self.has_attribute?(:project) && self.project && self.project.is_public == false) ||
|
||||
(self.has_attribute?(:board) && self.board.project && self.board.project.is_public == false) ||
|
||||
(self.class.to_s=="HomeworkAttach" && self.bid.reward_type == 3) ||
|
||||
(self.class.to_s=="Course" && self.is_public == false) ||
|
||||
(self.has_attribute?(:course) && self.course && self.course.is_public == false)
|
||||
(self.has_attribute?(:course) && self.course && self.course.is_public == false) ||
|
||||
(self.has_attribute?(:board) && self.board.course && self.board.course.is_public == false)
|
||||
)
|
||||
res.is_public = false
|
||||
end
|
||||
|
@ -120,18 +122,22 @@ module Redmine
|
|||
end
|
||||
if attachments.is_a?(Array)
|
||||
attachments.each do |attachment|
|
||||
next unless attachment.is_a?(Hash)
|
||||
a = nil
|
||||
if file = attachment['file']
|
||||
next unless file.size > 0
|
||||
a = Attachment.create(:file => file, :author => author)
|
||||
elsif token = attachment['token']
|
||||
a = Attachment.find_by_token(token)
|
||||
next unless a
|
||||
a.filename = attachment['filename'] unless attachment['filename'].blank?
|
||||
a.content_type = attachment['content_type']
|
||||
if attachment.is_a?(Hash)
|
||||
a = nil
|
||||
file = attachment['file']
|
||||
token = attachment['token']
|
||||
t = file && file.size > 0
|
||||
if file && file.size > 0
|
||||
a = Attachment.create(:file => file, :author => author)
|
||||
elsif token
|
||||
a = Attachment.find_by_token_only(token)
|
||||
if a
|
||||
a.filename = attachment['filename'] unless attachment['filename'].blank?
|
||||
a.content_type = attachment['content_type']
|
||||
end
|
||||
end
|
||||
end
|
||||
if !attachment[:is_public]
|
||||
if a && !attachment[:is_public]
|
||||
a.is_public = false
|
||||
end
|
||||
set_attachment_public(a)
|
||||
|
|
Loading…
Reference in New Issue