Skip to content

Commit

Permalink
wth - (SPARCRequest & SPARC Dashboard) Document upload bug
Browse files Browse the repository at this point in the history
User cannot currently upload '.xls' attachments. Please look into this bug

[#156406084]

Story - https://www.pivotaltracker.com/story/show/156406084
  • Loading branch information
wtholt committed Apr 2, 2018
1 parent 6fee8e0 commit b376406
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@ class Document < ApplicationRecord
has_and_belongs_to_many :sub_service_requests
belongs_to :protocol
has_attached_file :document #, :preserve_files => true
validates_attachment :document, content_type: { content_type: [
"application/pdf",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.ms-office",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.ms-powerpoint",
"application/octet-stream",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/msword",
"application/vnd.ms-excel",
"image/jpeg",
"text/csv",
"text/rtf",
"text/plain",
"text/msg",
"message/rfc822",
"image/gif",
"image/png",
"image/tiff"
] }
validates_attachment_file_name :document, matches: [
/\.pdf$/,
/\.docx?$/,
/\.xlsx?$/,
/\.rtf$/,
/\.txt$/,
/\.csv$/,
/\.ppt?$/,
/\.msg$/,
/\.eml$/,
/\.jpg$/,
/\.gif$/,
/\.png$/,
/\.tiff$/,
/\.jpeg$/
]

validates :doc_type, :document, presence: true
validates :doc_type_other, presence: true, if: Proc.new { |doc| doc.doc_type == 'other' }
Expand Down

0 comments on commit b376406

Please sign in to comment.