diff --git a/app/assets/stylesheets/admin/admin.css.scss b/app/assets/stylesheets/admin/admin.css.scss index 3226661..36fda72 100644 --- a/app/assets/stylesheets/admin/admin.css.scss +++ b/app/assets/stylesheets/admin/admin.css.scss @@ -13,6 +13,14 @@ @import "../mixins/css3"; +#pdf_prescription{ + font-weight:bold; + padding:20px; + border:2px solid #226198; + margin-top:20px; + +} + #busy{ position:absolute; diff --git a/app/models/prescription.rb b/app/models/prescription.rb index 87026f0..f078993 100644 --- a/app/models/prescription.rb +++ b/app/models/prescription.rb @@ -9,4 +9,16 @@ class Prescription < ActiveRecord::Base DONE_BYS = [["GB",1],["MB",2],["VB",3],["MV",4],["EA",5],["PG",6]] + def file_type + + + mime = `file --mime -br "#{self.file.path}"`.strip.split(';')[0] + mime + + end + + def is_pdf? + true if self.file_type == "application/pdf" + end + end diff --git a/app/uploaders/prescription_uploader.rb b/app/uploaders/prescription_uploader.rb index 14e944b..0bf101a 100644 --- a/app/uploaders/prescription_uploader.rb +++ b/app/uploaders/prescription_uploader.rb @@ -40,7 +40,7 @@ class PrescriptionUploader < CarrierWave::Uploader::Base # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_white_list - %w(jpg jpeg gif png) + %w(jpg jpeg gif png pdf) end # Override the filename of the uploaded files: diff --git a/app/views/admin/prescriptions/_show.html.haml b/app/views/admin/prescriptions/_show.html.haml index 7aedf9c..c043d59 100644 --- a/app/views/admin/prescriptions/_show.html.haml +++ b/app/views/admin/prescriptions/_show.html.haml @@ -15,7 +15,15 @@ =simple_format @prescription.notes .file - =image_tag @prescription.file.url if @prescription.file? + + -if @prescription.file? + -if @prescription.is_pdf? + #pdf_prescription=link_to "Cette ordonnance est au format pdf. Cliquez-ici pour la visualiser.", @prescription.file.url, :target => "_blank" + -else + =image_tag @prescription.file.url, :style => "width:100%;" + =link_to "Cliquez-ici pour télécharger image dans une nouvelle fenêtre.", @prescription.file.url, :target => "_blank" + + #right_bar.bar_transparent_dark.position_absolute_bottom .left