|
@@ -0,0 +1,34 @@
|
|
|
+module CustomNotifications
|
|
|
+ module AttachmentsControllerPatch
|
|
|
+ def self.included(base)
|
|
|
+ base.extend(ClassMethods)
|
|
|
+ base.send(:include, InstanceMethods)
|
|
|
+
|
|
|
+ base.class_eval do
|
|
|
+ alias_method_chain :download, customnotifications:
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ module ClassMethods
|
|
|
+ end
|
|
|
+
|
|
|
+ module InstanceMethods
|
|
|
+ def download_with_customnotifications
|
|
|
+ if @attachment.container.is_a?(Version) || @attachment.container.is_a?(Project)
|
|
|
+ @attachment.increment_download
|
|
|
+ end
|
|
|
+
|
|
|
+ if stale?(:etag => @attachment.digest)
|
|
|
+ # images and pdfs are sent inline
|
|
|
+ send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
|
|
+ :type => detect_content_type(@attachment),
|
|
|
+ :disposition => (@attachment.image? || @attachment.pdf? ? 'inline' : 'attachment')
|
|
|
+ end
|
|
|
+
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+end
|
|
|
+
|
|
|
+AttachmentsController.send(:include, CustomNotifications::AttachmentsControllerPatch)
|
|
|
+
|