Merge branch 'hjq_beidou' into develop

wuhao v20160402_02
huang 9 years ago
commit 7d07989939

@ -70,8 +70,8 @@ class AttachmentsController < ApplicationController
def direct_download def direct_download
@attachment.increment_download @attachment.increment_download
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment), :type => detect_content_type(@attachment),
:disposition => 'attachment' #inline can open in browser :disposition => 'attachment' #inline can open in browser
end end
def direct_download_history def direct_download_history
@ -175,7 +175,7 @@ class AttachmentsController < ApplicationController
@attachment = Attachment.find(params[:attachmentid]) @attachment = Attachment.find(params[:attachmentid])
if @attachment != nil if @attachment != nil
filedense = params[:newtype].to_s filedense = params[:newtype].to_s
# d = Iconv.conv("unicodebig","utf-8",filedense) # d = Iconv.conv("unicodebig","utf-8",filedense)
if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public) if filedense == "%E5%85%AC%E5%BC%80" #l(:field_is_public)
@attachment.is_public = 1 @attachment.is_public = 1
else else
@ -210,9 +210,9 @@ class AttachmentsController < ApplicationController
if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size])
if stale?(:etag => thumbnail) if stale?(:etag => thumbnail)
send_file thumbnail, send_file thumbnail,
:filename => filename_for_content_disposition(@attachment.filename), :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment), :type => detect_content_type(@attachment),
:disposition => 'inline' :disposition => 'inline'
end end
else else
# No thumbnail for the attachment or thumbnail could not be created # No thumbnail for the attachment or thumbnail could not be created
@ -292,10 +292,10 @@ class AttachmentsController < ApplicationController
respond_to do |format| respond_to do |format|
if !@attachment.container.nil? && if !@attachment.container.nil? &&
(@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) && (@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) &&
@attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) && @attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) &&
@attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) || @attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon) ||
@attachment.container.is_a?(StudentWork)) @attachment.container.is_a?(StudentWork))
if @attachment.container.is_a?(News) if @attachment.container.is_a?(News)
format.html { redirect_to_referer_or news_path(@attachment.container) } format.html { redirect_to_referer_or news_path(@attachment.container) }
elsif @attachment.container.is_a?(StudentWorksScore) elsif @attachment.container.is_a?(StudentWorksScore)
@ -327,25 +327,25 @@ class AttachmentsController < ApplicationController
elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment) elsif !@attachment.container.nil? && @attachment.container.is_a?(OrgDocumentComment)
format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)} format.html {redirect_to_referer_or org_document_comment_path(@attachment.container)}
else else
if @project.nil? if @project.nil?
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) } format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
else else
format.html { redirect_to_referer_or project_path(@project) } format.html { redirect_to_referer_or project_path(@project) }
end end
end end
format.js format.js
end end
end end
def delete_homework def delete_homework
@bid = @attachment.container.bid @bid = @attachment.container.bid
# Make sure association callbacks are called # Make sure association callbacks are called
container = @attachment.container container = @attachment.container
@attachment.container.attachments.delete(@attachment) @attachment.container.attachments.delete(@attachment)
#if container.attachments.empty? #if container.attachments.empty?
#container.delete #container.delete
#end #end
respond_to do |format| respond_to do |format|
format.html { redirect_to_referer_or respond_path(@bid) } format.html { redirect_to_referer_or respond_path(@bid) }
@ -594,7 +594,7 @@ class AttachmentsController < ApplicationController
end end
end end
private private
def find_project def find_project
@attachment = Attachment.find(params[:id]) @attachment = Attachment.find(params[:id])
# Show 404 if the filename in the url is wrong # Show 404 if the filename in the url is wrong
@ -608,7 +608,7 @@ private
@attachment.container.board.course) @attachment.container.board.course)
@course = @attachment.container.board.course @course = @attachment.container.board.course
else else
unless @attachment.container_type == 'Bid'|| @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork' unless @attachment.container_type == 'Bid' || @attachment.container_type == 'Organization' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork'
@project = @attachment.project @project = @attachment.project
end end
end end
@ -628,7 +628,7 @@ private
def read_authorize def read_authorize
if @attachment.container_type == "HomeworkAttach" || @attachment.container_type == 'Bid' if @attachment.container_type == "HomeworkAttach" || @attachment.container_type == 'Bid'
true true
#User.current.allowed_to?(:view_homework_attaches, @attachment.project) ? true : deny_access #User.current.allowed_to?(:view_homework_attaches, @attachment.project) ? true : deny_access
else else
@attachment.visible? ? true : deny_access @attachment.visible? ? true : deny_access
@ -654,16 +654,14 @@ private
def renderTag def renderTag
@attachmentNew = Attachment.find(params[:attchmentId]) @attachmentNew = Attachment.find(params[:attchmentId])
respond_to do |format| respond_to do |format|
format.js format.js
end end
end end
def has_login def has_login
unless@attachment.container_type == "Organization" unless @attachment && @attachment.container_type == "PhoneAppVersion"
unless @attachment && @attachment.container_type == "PhoneAppVersion" render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download)
render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download)
end
end end
end end
end end

@ -14,7 +14,7 @@
<%= javascript_include_tag 'attachments' %> <%= javascript_include_tag 'attachments' %>
<%#= call_hook :view_layouts_base_html_head %> <%#= call_hook :view_layouts_base_html_head %>
<!-- page specific tags --> <!-- page specific tags -->
<%= yield :header_tags -%> <%#= yield :header_tags -%>
<!-- MathJax的配置 --> <!-- MathJax的配置 -->
<script type="text/javascript" <script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">

Loading…
Cancel
Save