Class: Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Post
- Includes:
- CommentableItem, HasOwner, Toggleable, VotableItem
- Defined in:
- app/models/post.rb
Constant Summary collapse
- TITLE_LIMIT =
140- SLUG_LIMIT =
200- SLUG_PATTERN =
/\A[a-z0-9]+[-_.a-z0-9]*[a-z0-9]+\z/- LEAD_LIMIT =
350- BODY_LIMIT =
50000- META_LIMIT =
250- ALT_LIMIT =
200- PER_PAGE =
10
Class Method Summary collapse
- .creation_parameters ⇒ Object
- .entity_parameters ⇒ Object
- .page_for_administration(page = 1) ⇒ Object
- .page_for_visitors(page = 1) ⇒ Object
Instance Method Summary collapse
Class Method Details
.creation_parameters ⇒ Object
76 77 78 |
# File 'app/models/post.rb', line 76 def self.creation_parameters entity_parameters + %i(post_type_id) end |
.entity_parameters ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'app/models/post.rb', line 66 def self.entity_parameters main_data = %i(post_category_id title slug lead body visible translation region_id) image_data = %i(image image_alt_text image_name image_author_name image_author_link) = %i(source_name source_link meta_title meta_description meta_keywords) flags_data = %i(show_owner allow_comments) = %i(author_name author_title author_url) main_data + image_data + + + flags_data end |
.page_for_administration(page = 1) ⇒ Object
57 58 59 |
# File 'app/models/post.rb', line 57 def self.page_for_administration(page = 1) recent.page(page).per(PER_PAGE) end |
.page_for_visitors(page = 1) ⇒ Object
62 63 64 |
# File 'app/models/post.rb', line 62 def self.page_for_visitors(page = 1) list_for_visitors.page(page).per(PER_PAGE) end |
Instance Method Details
#editable_by?(user) ⇒ Boolean
81 82 83 |
# File 'app/models/post.rb', line 81 def editable_by?(user) owned_by?(user) || UserPrivilege.user_has_privilege?(user, :chief_editor) end |
#has_image_data? ⇒ Boolean
85 86 87 |
# File 'app/models/post.rb', line 85 def has_image_data? !image_name.blank? || !.blank? || !.blank? end |
#has_source_data? ⇒ Boolean
89 90 91 |
# File 'app/models/post.rb', line 89 def has_source_data? !source_name.blank? || !source_link.blank? end |