Merge branch 'dev_cxt' into dev_aliyun

dev_daiao
cxt 5 years ago
commit e438c10a0b

@ -18,9 +18,9 @@ class AttachmentsController < ApplicationController
pdf_attachment = params[:disposition] || "attachment"
if pdf_attachment == "inline"
send_file absolute_path(local_path(@file)),filename: @file.filename, disposition: 'inline',type: 'application/pdf'
send_file absolute_path(local_path(@file)),filename: @file.title, disposition: 'inline',type: 'application/pdf'
else
send_file(absolute_path(local_path(@file)), filename: @file.filename,stream:false, type: @file.content_type.presence || 'application/octet-stream')
send_file(absolute_path(local_path(@file)), filename: @file.title,stream:false, type: @file.content_type.presence || 'application/octet-stream')
end
update_downloads(@file)
end

@ -27,12 +27,21 @@ class Attachment < ApplicationRecord
validates_length_of :description, maximum: 100
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def diskfile
File.join(File.join(Rails.root, "files"), disk_directory.to_s, disk_filename.to_s)
end
def title
filename
title = filename
if container.is_a?(StudentWork) && author_id != User.current.id
course = container&.homework_common&.course
unless User.current.teacher_of_course?(course)
title = "#{Time.now.strftime('%Y%m%d%H%M%S')}_#{DCODES.sample(8).join}" + File.extname(filename)
end
end
title
end
def downloads_count

@ -165,7 +165,7 @@ class Competition < ApplicationRecord
def get_module_name type
case type
when 'home' then '首页'
when 'home' then '赛制介绍'
when 'enroll' then '报名'
when 'inform' then '通知公告'
when 'chart' then '排行榜'

@ -11,7 +11,7 @@ json.update_user_name @is_evaluation ? "匿名" : @work.update_user.try(:real_na
json.update_atta @homework.late_duration && @is_author
json.attachments @attachments do |atta|
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false}
json.partial! "attachments/attachment_simple", locals: {attachment: atta, delete: false, }
end
unless @is_evaluation

Loading…
Cancel
Save