Fix bug.
This commit is contained in:
parent
3c1c1d40da
commit
33272f9193
|
@ -393,7 +393,11 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
||||||
redirect_to :back
|
redirect_to :back
|
||||||
else
|
else
|
||||||
tmp_filename_data = @student.olympia_student_images.last.student_file.file.read
|
tmp_filename_data = @student.olympia_student_images.last.student_file.file.read
|
||||||
send_data(tmp_filename_data, type: 'image/jpg', disposition: 'attachment', filename: "#{@student.StudentName}.jpg")
|
file = @student.olympia_student_images.last.student_file.file.file.to_s
|
||||||
|
extname = File.extname(file) rescue ".jpg"
|
||||||
|
extname = ".jpg" if extname.blank?
|
||||||
|
mime_type = MIME::Types.type_for(file).first.content_type rescue "image/jpg"
|
||||||
|
send_data(tmp_filename_data, type: mime_type, disposition: 'attachment', filename: "#{@student.StudentName}#{extname}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id)
|
@student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id)
|
||||||
|
|
|
@ -4,7 +4,21 @@
|
||||||
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
|
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
|
||||||
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
|
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
|
||||||
<div class="fileupload-new thumbnail pull-left">
|
<div class="fileupload-new thumbnail pull-left">
|
||||||
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
|
<% file = image_form.send(image_field_name).last.send(field_name).to_s
|
||||||
|
extname = File.extname(file) rescue ".jpg"
|
||||||
|
extname = ".jpg" if extname.blank?
|
||||||
|
file_name = URI.decode(File.basename(file)) rescue File.basename(file)
|
||||||
|
%>
|
||||||
|
<% if extname.match(/(jpg|png|gif|bmp)/i) %>
|
||||||
|
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
|
||||||
|
<% elsif extname.match(/pdf/i) %>
|
||||||
|
<object data="<%=file%>" type="application/pdf" title="<%=file_name%>" height="120" width="120">
|
||||||
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
||||||
|
<embed src="<%=file%>" title="<%=file_name%>" type="application/pdf" />
|
||||||
|
</object>
|
||||||
|
<% else %>
|
||||||
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||||
|
|
|
@ -22,7 +22,11 @@
|
||||||
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
|
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
|
||||||
<% elsif th_name == 'scan_file_of_certificate'%>
|
<% elsif th_name == 'scan_file_of_certificate'%>
|
||||||
<% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %>
|
<% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %>
|
||||||
<td><a href='<%="#{admin_olympiamanagements_download_scan_file_of_certificate_path}?student_id=#{field.id}" %>'><%= "#{field.StudentName}.jpg" %><img src="/assets/gif.gif" border="0" alt="<%= "#{field.StudentName}.jpg" %>"></a></td>
|
<% file = field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.last.file.to_s
|
||||||
|
extname = File.extname(file) rescue ".jpg"
|
||||||
|
extname = ".jpg" if extname.blank?
|
||||||
|
%>
|
||||||
|
<td><a href='<%="#{admin_olympiamanagements_download_scan_file_of_certificate_path}?student_id=#{field.id}" %>'><%= "#{field.StudentName}#{extname}" %><img src="/assets/gif.gif" border="0" alt="<%= "#{field.StudentName}#{extname}" %>"></a></td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td> </td>
|
<td> </td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -4,7 +4,21 @@
|
||||||
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
|
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
|
||||||
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
|
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
|
||||||
<div class="fileupload-new thumbnail pull-left">
|
<div class="fileupload-new thumbnail pull-left">
|
||||||
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
|
<% file = image_form.send(image_field_name).last.send(field_name).to_s
|
||||||
|
extname = File.extname(file) rescue ".jpg"
|
||||||
|
extname = ".jpg" if extname.blank?
|
||||||
|
file_name = URI.decode(File.basename(file)) rescue File.basename(file)
|
||||||
|
%>
|
||||||
|
<% if extname.match(/(jpg|png|gif|bmp)/i) %>
|
||||||
|
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
|
||||||
|
<% elsif extname.match(/pdf/i) %>
|
||||||
|
<object data="<%=file%>" type="application/pdf" title="<%=file_name%>" height="120" width="120">
|
||||||
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
||||||
|
<embed src="<%=file%>" title="<%=file_name%>" type="application/pdf" />
|
||||||
|
</object>
|
||||||
|
<% else %>
|
||||||
|
<a href="<%=file%>" title="<%=file_name%>"><%=file_name%></a>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||||
|
|
Loading…
Reference in New Issue