Class: PostIllustration

Inherits:
ApplicationRecord show all
Includes:
HasOwner
Defined in:
app/models/post_illustration.rb

Overview

Inline post illustration

Attributes:

agent_id [Agent], optional
created_at [DateTime]
image [SimpleImageUploader]
ip [Inet], optional
updated_at [DateTime]
user_id [User], optional

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.ckeditor_upload!(parameters) ⇒ Object

Parameters:

  • parameters (Hash)


31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/post_illustration.rb', line 31

def self.ckeditor_upload!(parameters)
  entity = new(parameters)
  if entity.save
    entity.ckeditor_data
  else
    {
      uploaded: 0,
      error: 'Could not upload image'
    }
  end
end

.page_for_administration(page = 1) ⇒ Object

Parameters:

  • page (Integer) (defaults to: 1)


26
27
28
# File 'app/models/post_illustration.rb', line 26

def self.page_for_administration(page = 1)
  list_for_administration.page(page)
end

Instance Method Details

#ckeditor_dataObject

Response data for CKEditor upload



56
57
58
59
60
61
62
# File 'app/models/post_illustration.rb', line 56

def ckeditor_data
  {
    uploaded: 1,
    fileName: File.basename(image.path),
    url: image.hd_url
  }
end

#editable_by?(user) ⇒ Boolean

Deprecated.

use component handler

Parameters:

  • user (User)

Returns:

  • (Boolean)


51
52
53
# File 'app/models/post_illustration.rb', line 51

def editable_by?(user)
  Biovision::Components::BaseComponent.handler('posts', user).editable?(self)
end

#nameObject



43
44
45
46
47
# File 'app/models/post_illustration.rb', line 43

def name
  return '' if image.blank?

  CGI::unescape(File.basename(image.path))
end