Class: Literature
- Inherits:
-
Upload
- Object
- ActiveRecord::Base
- ApplicationRecord
- Upload
- Literature
- Defined in:
- app/models/literature.rb
Overview
== Schema Information
Table name: uploads
Database name: primary
id :integer not null, primary key
asset :jsonb
attachment_mime_type :string
attachment_name :string
attachment_processing :boolean
attachment_size :integer
attachment_uid :string
category :string(255)
document_date :date
expiration_date :date
note :text
position :integer
resource_type :string(255)
template :string
thumbnail_asset :jsonb
type :string(30)
created_at :datetime
updated_at :datetime
resource_id :integer
Indexes
idx_resource_type_category (resource_type,category) WHERE (resource_id IS NULL)
idx_resource_type_category_resource_id (resource_type,category,resource_id)
index_uploads_on_category (category)
index_uploads_on_resource_type_and_resource_id (resource_type,resource_id)
index_uploads_on_type (type) WHERE (type IS NOT NULL)
Constant Summary
Constants inherited from Upload
Upload::CATEGORIES, Upload::EXCLUDE_CATEGORIES_FOR_MANUAL_UPLOAD, Upload::IMAGE_EXTENSIONS, Upload::MODEL_TO_CATEGORIES, Upload::RESOURCES_WITH_UPLOADS_COUNT, Upload::UNCLASSIFIED_CATEGORIES
Constants included from Models::Auditable
Models::Auditable::ALWAYS_IGNORED
Instance Attribute Summary
Attributes inherited from Upload
#attachment, #import, #local_file_path, #should_destroy, #template
Instance Method Summary collapse
Methods inherited from Upload
#active_download_token, all_categories_for_select, #articles, #attachment_ext, #browser_previewable?, #cad_category?, #clone_with_file, #communications, #create_new_download_token, custom_ship_labels, #deletable?, #determine_orientation, #determine_page_size, #download_tokens, #file_exists?, #get_local_file_path, has_document_date?, #has_document_date?, has_role_restrictions?, #has_role_restrictions?, #has_thumbnail?, #image_attachment, #image_category?, #image_url, in_category, invalid, #is_audio?, #is_image?, #is_image_or_pdf?, #is_mp3?, #is_pdf?, #is_video?, #is_wav?, #items, literatures, #mime_type, #mime_type_symbol, most_recent_first, options_for_categories_select, #options_for_categories_select, #pdf_category?, #pdf_thumbnail_attachment, #pdf_thumbnail_url, #presigned_url, #publication, #recipient_party_id, #resource, #resource_combo, #resource_combo=, #roles, #scope_condition, #set_local_file_path, sorted_by_position, temp_location, #template_options_for_select, #thumbnail_2x_url, #thumbnail_url, #title, #to_file, #to_s, #undefined_mime_type?, uploadify, uploadify_from_data, uploadify_from_url, valid
Methods included from Models::Auditable
#all_skipped_columns, #audit_reference_data, #creator, #should_not_save_version, #stamp_record, #updater
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::EventPublishable
Instance Method Details
#file_name_for_download ⇒ Object
43 44 45 46 47 |
# File 'app/models/literature.rb', line 43 def file_name_for_download file_name = publication&.file_name_for_download file_name ||= file_name end |
#ok_to_delete? ⇒ Boolean
37 38 39 40 41 |
# File 'app/models/literature.rb', line 37 def ok_to_delete? # Check if this upload is used as literature for any publication (Item) # Use direct database query to avoid association caching issues !Item.exists?(literature_id: id) && resource.nil? end |