Class: Decidim::Posts::PostCommentCell

Inherits:
ViewModel
  • Object
show all
Includes:
Cell::ViewModel::Partial, Comments::CommentsHelper, ResourceHelper
Defined in:
app/cells/decidim/posts/post_comment_cell.rb

Instance Method Summary collapse

Instance Method Details

#comments_countObject



41
42
43
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 41

def comments_count
  model.comments_count
end

#machine_translations_toggled?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 37

def machine_translations_toggled?
  RequestStore.store[:toggle_machine_translations]
end

#model_typeObject



17
18
19
20
21
22
23
24
25
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 17

def model_type
  if model.is_a?(Decidim::Posts::Post)
    "Post"
  elsif model.is_a?(Decidim::Meetings::Meeting)
    "Meeting"
  else
    "Post"
  end
end

#postObject



13
14
15
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 13

def post
  model
end

#post_commentable?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 27

def post_commentable?
  if model.respond_to?(:enable_comments?)
    model.enable_comments?
  elsif model.respond_to?(:comments_enabled?)
    model.comments_enabled?
  else
    false # Default to false if neither method exists
  end
end

#showObject



9
10
11
# File 'app/cells/decidim/posts/post_comment_cell.rb', line 9

def show
  render :show
end