app/models/alchemy/attachment.rb in alchemy_cms-4.0.6 vs app/models/alchemy/attachment.rb in alchemy_cms-4.1.0.beta

- old
+ new

@@ -16,17 +16,16 @@ # cached_tag_list :text # file_uid :string # module Alchemy - class Attachment < ActiveRecord::Base + class Attachment < BaseRecord include Alchemy::Filetypes include Alchemy::NameConversions - include Alchemy::Touching + include Alchemy::Taggable + include Alchemy::ContentTouching - acts_as_taggable - dragonfly_accessor :file, app: :alchemy_attachments do after_assign { |f| write_attribute(:file_mime_type, f.mime_type) } end stampable stamper_class_name: Alchemy.user_class_name @@ -62,12 +61,10 @@ message: Alchemy.t("not a valid file"), unless: -> { self.class.allowed_filetypes.include?('*') } before_save :set_name, if: :file_name_changed? - after_update :touch_contents - scope :with_file_type, ->(file_type) { where(file_mime_type: file_type) } # Instance methods def to_jq_upload @@ -96,33 +93,27 @@ # Returns a css class name for kind of file # def icon_css_class case file_mime_type - when "application/x-shockwave-flash" - then "flash" - when "image/x-psd" - then "psd" - when "text/plain" - then "text" - when "application/rtf" - then "rtf" when "application/pdf" - then "pdf" + then "file-pdf" when "application/msword" - then "word" - when "application/vnd.ms-excel" - then "excel" + then "file-word" + when *TEXT_FILE_TYPES + then "file-alt" + when *EXCEL_FILE_TYPES + then "file-excel" when *VCARD_FILE_TYPES - then "vcard" + then "address-card" when *ARCHIVE_FILE_TYPES - then "archive" + then "file-archive" when *AUDIO_FILE_TYPES - then "audio" + then "file-audio" when *IMAGE_FILE_TYPES - then "image" + then "file-image" when *VIDEO_FILE_TYPES - then "video" + then "file-video" else "file" end end