Attachment添加file_dir 属性
This commit is contained in:
parent
d3d656f3b8
commit
5c648c9284
|
@ -14,9 +14,10 @@ module Mobile
|
|||
f.send(field)
|
||||
end
|
||||
else
|
||||
#case field
|
||||
# when ""
|
||||
#end
|
||||
case field
|
||||
when :file_dir
|
||||
"attachments/download/" << f.send(:id).to_s << '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -27,6 +28,7 @@ module Mobile
|
|||
attachment_expose :downloads
|
||||
attachment_expose :quotes
|
||||
attachment_expose :created_on
|
||||
attachment_expose :file_dir
|
||||
end
|
||||
end
|
||||
end
|
|
@ -434,24 +434,15 @@ class CoursesService
|
|||
# 课程课件
|
||||
def course_attachments params
|
||||
result = []
|
||||
@course = Course.find(params[:course_id])
|
||||
@attachments = @course.attachments.order("created_on desc")
|
||||
course = Course.find(params[:course_id])
|
||||
attachments = course.attachments.order("created_on ")
|
||||
if !params[:name].nil? && params[:name] != ""
|
||||
@attachments.each do |atta|
|
||||
result << {:filename => atta.filename,
|
||||
:description => atta.description,
|
||||
:downloads => atta.downloads,
|
||||
:quotes => atta.quotes.nil? ? 0 :atta.quotes } if atta.filename.include?(params[:name])
|
||||
attachments.each do |atta|
|
||||
result << atta if atta.filename.include?(params[:name])
|
||||
|
||||
end
|
||||
else
|
||||
@attachments.each do |atta|
|
||||
result << {:filename => atta.filename,
|
||||
:description => atta.description,
|
||||
:downloads => atta.downloads,
|
||||
:quotes => atta.quotes.nil? ? 0 :atta.quotes }
|
||||
|
||||
end
|
||||
result = attachments
|
||||
end
|
||||
result
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue