From 2fe491167c50f5bd5bf37f6f55344956df29392c Mon Sep 17 00:00:00 2001 From: Denny de la Haye <2021@denny.me> Date: Thu, 8 Apr 2021 13:52:22 +0100 Subject: [PATCH] Minor tidying was all I could do here in the end --- .../shiny_blog/admin/blog_posts_controller.rb | 11 ----------- .../concerns/shinycms/admin/with_discussions.rb | 2 +- .../app/public/concerns/shinycms/admin/with_posts.rb | 12 ++++++++++++ .../shiny_news/admin/news_posts_controller.rb | 11 ----------- 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/plugins/ShinyBlog/app/controllers/shiny_blog/admin/blog_posts_controller.rb b/plugins/ShinyBlog/app/controllers/shiny_blog/admin/blog_posts_controller.rb index e35e35119..242fb0135 100644 --- a/plugins/ShinyBlog/app/controllers/shiny_blog/admin/blog_posts_controller.rb +++ b/plugins/ShinyBlog/app/controllers/shiny_blog/admin/blog_posts_controller.rb @@ -9,17 +9,11 @@ module ShinyBlog # Admin area controller for ShinyBlog plugin for ShinyCMS class Admin::BlogPostsController < AdminController - include ShinyCMS::Admin::WithDateTimeInputs - include ShinyCMS::Admin::WithDiscussions include ShinyCMS::Admin::WithPosts - include ShinyCMS::Admin::WithTags before_action :set_post_for_create, only: :create before_action :set_post, only: %i[ edit update destroy ] - helper_method :admin_tag_list - helper_method :load_html_editor? - def index authorize Post @@ -111,10 +105,5 @@ def strong_params_for_update combine_date_and_time_params( temp_params, :posted_at ) end - - # Return true if the page we're on might need a WYSIWYG HTML editor - def load_html_editor? - action_name == 'new' || action_name == 'edit' - end end end diff --git a/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_discussions.rb b/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_discussions.rb index 850cc5d14..9f64ee902 100644 --- a/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_discussions.rb +++ b/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_discussions.rb @@ -24,7 +24,7 @@ def create_discussion_or_update_flags( resource, show, lock ) if resource.discussion.present? resource.discussion.update!( show_on_site: show, locked: lock ) elsif show - ShinyCMS::Discussion.create!( resource: @post, show_on_site: show, locked: lock ) + ShinyCMS::Discussion.create!( resource: resource, show_on_site: show, locked: lock ) end end end diff --git a/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_posts.rb b/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_posts.rb index b1685a45d..176e66307 100644 --- a/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_posts.rb +++ b/plugins/ShinyCMS/app/public/concerns/shinycms/admin/with_posts.rb @@ -12,7 +12,14 @@ module Admin module WithPosts extend ActiveSupport::Concern + include ShinyCMS::Admin::WithDateTimeInputs + include ShinyCMS::Admin::WithDiscussions + include ShinyCMS::Admin::WithTags + included do + helper_method :admin_tag_list + helper_method :load_html_editor? + def enforce_change_author_capability_for_create( category ) params[ :post ][ :user_id ] = current_user.id unless current_user.can? :change_author, category end @@ -20,6 +27,11 @@ def enforce_change_author_capability_for_create( category ) def enforce_change_author_capability_for_update( category ) params[ :post ].delete( :user_id ) unless current_user.can? :change_author, category end + + # Return true if the page we're on might need a WYSIWYG HTML editor + def load_html_editor? + action_name == 'new' || action_name == 'edit' + end end end end diff --git a/plugins/ShinyNews/app/controllers/shiny_news/admin/news_posts_controller.rb b/plugins/ShinyNews/app/controllers/shiny_news/admin/news_posts_controller.rb index acaf14ea5..55930ba81 100644 --- a/plugins/ShinyNews/app/controllers/shiny_news/admin/news_posts_controller.rb +++ b/plugins/ShinyNews/app/controllers/shiny_news/admin/news_posts_controller.rb @@ -9,17 +9,11 @@ module ShinyNews # Admin area controller for ShinyNews plugin for ShinyCMS class Admin::NewsPostsController < AdminController - include ShinyCMS::Admin::WithDateTimeInputs - include ShinyCMS::Admin::WithDiscussions include ShinyCMS::Admin::WithPosts - include ShinyCMS::Admin::WithTags before_action :set_post_for_create, only: :create before_action :set_post, only: %i[ edit update destroy ] - helper_method :admin_tag_list - helper_method :load_html_editor? - def index authorize Post @@ -111,10 +105,5 @@ def strong_params_for_update combine_date_and_time_params( temp_params, :posted_at ) end - - # Return true if the page we're on might need a WYSIWYG HTML editor - def load_html_editor? - action_name == 'new' || action_name == 'edit' - end end end