Class: Decidim::Posts::PostHeaderCell
- Inherits:
-
ViewModel
- Object
- ViewModel
- Decidim::Posts::PostHeaderCell
- Includes:
- Cell::ViewModel::Partial, EndorsableHelper
- Defined in:
- app/cells/decidim/posts/post_header_cell.rb
Instance Method Summary collapse
- #delete_method ⇒ Object
- #delete_post_path ⇒ Object
- #edit_post_path ⇒ Object
- #post ⇒ Object
- #post_deleteable? ⇒ Boolean
- #post_editable? ⇒ Boolean
- #show ⇒ Object
- #show_menu? ⇒ Boolean
- #show_report_button? ⇒ Boolean
- #show_translate_button? ⇒ Boolean
Instance Method Details
#delete_method ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 34 def delete_method if post.component.manifest_name == "meetings" :put else :delete end end |
#delete_post_path ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 25 def delete_post_path if post.component.manifest_name == "meetings" # use MeetingsController from posts module Decidim::EngineRouter.main_proxy(posts_component_for_meeting(post)).withdraw_meeting_path(assembly_slug: post.component.participatory_space.slug, component_id: 1, id: post) else Decidim::EngineRouter.main_proxy(post.component).post_path(post) end end |
#edit_post_path ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 16 def edit_post_path if post.component.manifest_name == "meetings" # use MeetingsController from posts module Decidim::EngineRouter.main_proxy(posts_component_for_meeting(post)).edit_meeting_path(post) else Decidim::EngineRouter.main_proxy(post.component).edit_post_path(post) end end |
#post ⇒ Object
12 13 14 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 12 def post model end |
#post_deleteable? ⇒ Boolean
52 53 54 55 56 57 58 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 52 def post_deleteable? if post.component.manifest_name == "meetings" post.withdrawable_by?(current_user) else post.deleteable_by?(current_user) end end |
#post_editable? ⇒ Boolean
42 43 44 45 46 47 48 49 50 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 42 def post_editable? if post.component.manifest_name == "meetings" post.(current_user) else # Don't allow editing of survey posts return false if post.category == "survey" post.editable_by?(current_user) end end |
#show ⇒ Object
8 9 10 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 8 def show render :show end |
#show_menu? ⇒ Boolean
68 69 70 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 68 def || post_editable? || post_deleteable? || end |
#show_report_button? ⇒ Boolean
60 61 62 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 60 def post. != current_user && post.class == Decidim::Posts::Post end |
#show_translate_button? ⇒ Boolean
64 65 66 |
# File 'app/cells/decidim/posts/post_header_cell.rb', line 64 def false # disbled for now end |