Class: Decidim::Blogs::PostsController
- Inherits:
-
ApplicationController
- Object
- DecidimController
- ApplicationController
- Components::BaseController
- ApplicationController
- Decidim::Blogs::PostsController
- Includes:
- Flaggable, FormFactory, IconHelper, Paginable
- Defined in:
- decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb
Overview
Exposes the blog resource so users can view them
Constant Summary
Constants included from Paginable
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods included from IconHelper
#component_icon, #manifest_icon, #resource_icon, #resource_type_icon, #resource_type_icon_key, #text_with_resource_icon
Methods included from LayoutHelper
#_icon_classes, #apple_favicon, #application_path, #current_url, #current_user_unread_data, #extended_navigation_bar, #external_icon, #favicon, #icon, #legacy_favicon, #role, #root_url
Methods included from TooltipHelper
Methods included from ModalHelper
#decidim_drawer, #decidim_modal
Methods included from OrganizationHelper
#current_organization_name, #organization_colors, #organization_description_label, #organization_name
Methods included from TranslatableAttributes
#attachment?, #default_locale?
Methods inherited from Components::BaseController
#current_component, #current_manifest, #current_participatory_space, #permission_class_chain, #permission_scope, #redirect_unless_feature_private, #set_component_breadcrumb_item
Methods included from RegistersPermissions
Methods inherited from ApplicationController
Methods included from UserBlockedChecker
#check_user_block_status, #check_user_not_blocked
Methods included from NeedsSnippets
Methods included from Headers::HttpCachingDisabler
Methods included from HasStoredPath
#skip_store_location?, #store_current_location
Methods included from NeedsOrganization
enhance_controller, extended, included
Instance Method Details
#create ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 27 def create :create, :blogpost @form = form(Decidim::Blogs::PostForm).from_params(params, current_component: current_component) CreatePost.call(@form) do on(:ok) do |new_post| flash[:notice] = I18n.t("posts.create.success", scope: "decidim.blogs.admin") redirect_to post_path(new_post) end on(:invalid) do flash.now[:alert] = I18n.t("posts.create.invalid", scope: "decidim.blogs.admin") render action: "new" end end end |
#destroy ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 66 def destroy :destroy, :blogpost, blogpost: post Decidim.traceability.perform_action!("delete", post, current_user) do post.destroy! end flash[:notice] = I18n.t("posts.destroy.success", scope: "decidim.blogs.admin") redirect_to posts_path end |
#edit ⇒ Object
44 45 46 47 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 44 def edit :update, :blogpost, blogpost: post @form = form(PostForm).from_model(post) end |
#index ⇒ Object
16 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 16 def index; end |
#new ⇒ Object
22 23 24 25 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 22 def new :create, :blogpost @form = form(Decidim::Blogs::PostForm).instance end |
#show ⇒ Object
18 19 20 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 18 def show raise ActionController::RoutingError, "Not Found" unless post end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'decidim-blogs/app/controllers/decidim/blogs/posts_controller.rb', line 49 def update :update, :blogpost, blogpost: post @form = form(PostForm).from_params(params, current_component: current_component) UpdatePost.call(@form, post) do on(:ok) do |post| flash[:notice] = I18n.t("posts.update.success", scope: "decidim.blogs.admin") redirect_to post_path(post) end on(:invalid) do flash.now[:alert] = I18n.t("posts.update.invalid", scope: "decidim.blogs.admin") render action: "edit" end end end |