From cdaa9ba41ac0b1d185e214edec1edcf53c6d8db3 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:10:32 +0530 Subject: [PATCH 1/6] File getting uploaded and stored in public folder --- app/models/event_attachment.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index e90e0f23..3741ccea 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -3,8 +3,14 @@ class EventAttachment < ActiveRecord::Base belongs_to :event attr_accessible :public, :attachment, :event_id, :title - - has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" + + has_attached_file :attachment + validates_attachment_content_type :attachment, :content_type => ['text/plain','image/jpg','image/jpeg', + 'image/pjpeg','image/png','image/x-png','image/gif','application/pdf','application/msword','applicationvnd.ms-word', + 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document','application/msexcel', + 'application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/mspowerpoint', + 'application/vnd.ms-powerpoint','application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.oasis.opendocument.presentation','application/vnd.openxmlformats-officedocument.wordprocessingml.document'] include Rails.application.routes.url_helpers def to_jq_upload From 8c69d0f6511f1b14141aeba48cfef4fe2456c254 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:14:08 +0530 Subject: [PATCH 2/6] fixes by houndci --- app/models/event_attachment.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 3741ccea..51bb6f3b 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -1,16 +1,17 @@ class EventAttachment < ActiveRecord::Base has_paper_trail - belongs_to :event attr_accessible :public, :attachment, :event_id, :title - has_attached_file :attachment - validates_attachment_content_type :attachment, :content_type => ['text/plain','image/jpg','image/jpeg', - 'image/pjpeg','image/png','image/x-png','image/gif','application/pdf','application/msword','applicationvnd.ms-word', - 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document','application/msexcel', - 'application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/mspowerpoint', - 'application/vnd.ms-powerpoint','application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/vnd.oasis.opendocument.presentation','application/vnd.openxmlformats-officedocument.wordprocessingml.document'] + validates_attachment_content_type :attachment, content_type: ['text/plain','image/jpg','image/jpeg', + 'image/pjpeg','image/png','image/x-png','image/gif','application/pdf','application/msword', + 'applicationvnd.ms-word','applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', + 'application/msexcel','application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/mspowerpoint','application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] include Rails.application.routes.url_helpers def to_jq_upload From 1f3e9a39c8296e2d1cf886421a2e17c94cab8b4a Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:23:16 +0530 Subject: [PATCH 3/6] fixes by houndci --- app/models/event_attachment.rb | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 51bb6f3b..e584a4cc 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -3,29 +3,29 @@ class EventAttachment < ActiveRecord::Base belongs_to :event attr_accessible :public, :attachment, :event_id, :title has_attached_file :attachment - validates_attachment_content_type :attachment, content_type: ['text/plain','image/jpg','image/jpeg', - 'image/pjpeg','image/png','image/x-png','image/gif','application/pdf','application/msword', - 'applicationvnd.ms-word','applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', - 'application/msexcel','application/vnd.ms-excel', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'application/mspowerpoint','application/vnd.ms-powerpoint', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/vnd.oasis.opendocument.presentation', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] + validates_attachment_content_type :attachment, content_type: + ['text/plain', 'image/jpg', 'image/jpeg','image/pjpeg', 'image/png', 'image/x-png', 'image/gif', + 'application/pdf', 'application/msword','applicationvnd.ms-word', + 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', + 'application/msexcel', 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/mspowerpoint', 'application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] include Rails.application.routes.url_helpers def to_jq_upload { - "name" => read_attribute(:attachment_file_name), - "size" => read_attribute(:attachment_file_size), - "title" => read_attribute(:title), - "public" => read_attribute(:public), - #"url" => attachment.url(:original), - "url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - "delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - "delete_type" => "DELETE" + "name" => read_attribute(:attachment_file_name), + "size" => read_attribute(:attachment_file_size), + "title" => read_attribute(:title), + "public" => read_attribute(:public), + #"url" => attachment.url(:original), + "url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), + "delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), + "delete_type" => "DELETE" } - end #:path => ":rails_root/public/system/:attachment/:id/:style/:filename", # :url => "/system/:attachment/:id/:style/:filename" From 07ac2baa68c326b2e2bcbda4c2f64116fcd45296 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:44:41 +0530 Subject: [PATCH 4/6] fixes by houndci --- app/models/event_attachment.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index e584a4cc..5a30d817 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -17,14 +17,16 @@ class EventAttachment < ActiveRecord::Base def to_jq_upload { - "name" => read_attribute(:attachment_file_name), - "size" => read_attribute(:attachment_file_size), - "title" => read_attribute(:title), - "public" => read_attribute(:public), + 'name' => read_attribute(:attachment_file_name), + 'size' => read_attribute(:attachment_file_size), + 'title' => read_attribute(:title), + 'public' => read_attribute(:public), #"url" => attachment.url(:original), - "url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - "delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - "delete_type" => "DELETE" + 'url' => conference_proposal_event_attachment_path( + self.event.conference.short_title, self.event_id, self.id), + 'delete_url' => conference_proposal_event_attachment_path( + self.event.conference.short_title, self.event_id, self.id), + 'delete_type' => "DELETE" } end #:path => ":rails_root/public/system/:attachment/:id/:style/:filename", From 85cc4413bda7ed571ce7355849b93941991b8686 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:46:50 +0530 Subject: [PATCH 5/6] fixes by houndci --- app/models/event_attachment.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 5a30d817..35633359 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -4,8 +4,8 @@ class EventAttachment < ActiveRecord::Base attr_accessible :public, :attachment, :event_id, :title has_attached_file :attachment validates_attachment_content_type :attachment, content_type: - ['text/plain', 'image/jpg', 'image/jpeg','image/pjpeg', 'image/png', 'image/x-png', 'image/gif', - 'application/pdf', 'application/msword','applicationvnd.ms-word', + ['text/plain', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', + 'application/pdf', 'application/msword', 'applicationvnd.ms-word', 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', 'application/msexcel', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', @@ -14,7 +14,6 @@ class EventAttachment < ActiveRecord::Base 'application/vnd.oasis.opendocument.presentation', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] include Rails.application.routes.url_helpers - def to_jq_upload { 'name' => read_attribute(:attachment_file_name), @@ -33,6 +32,4 @@ class EventAttachment < ActiveRecord::Base # :url => "/system/:attachment/:id/:style/:filename" #has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"} - - end From 6b65559ebd03f406247c54e72b26a44bf2d10d35 Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 16 May 2014 12:50:50 +0530 Subject: [PATCH 6/6] fixes by houndci --- app/models/event_attachment.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 35633359..33d7927b 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -4,15 +4,15 @@ class EventAttachment < ActiveRecord::Base attr_accessible :public, :attachment, :event_id, :title has_attached_file :attachment validates_attachment_content_type :attachment, content_type: - ['text/plain', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', - 'application/pdf', 'application/msword', 'applicationvnd.ms-word', - 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', - 'application/msexcel', 'application/vnd.ms-excel', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'application/mspowerpoint', 'application/vnd.ms-powerpoint', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/vnd.oasis.opendocument.presentation', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] + ['text/plain', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', + 'application/pdf', 'application/msword', 'applicationvnd.ms-word', + 'applicaiton/vnd.openxmlformats-officedocument.wordprocessingm1.document', + 'application/msexcel', 'application/vnd.ms-excel', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'application/mspowerpoint', 'application/vnd.ms-powerpoint', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'application/vnd.oasis.opendocument.presentation', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'] include Rails.application.routes.url_helpers def to_jq_upload {