docbrown/app/controllers/concerns/verify_setup_completed.rb
Ridhwana 4359d5b09a
[deploy] Site Config: Get Started Section and Show Required Fields (#9289)
* chore: spike

* fix: update doesnt get to symbol

* spelling

* chore: some suggestions

* chore: change name

* chore: content tag and safe join

* chore: keep this open for now

* chore: code climate

* more code climate stuff

* chore: remove commas

* fix: tests

* feat: update the descriptions and placeholders

* chore: update all the variables

* chore: update lines

* feat: update ""

* chore: length line

* feat: content_tag

* chore: disable rubocop:disable Rails/OutputSafety

* feat: collapse the get started section if everything is filled out

* chore: comment

* some cleanup

* codeclimate :(
2020-07-20 08:20:15 -04:00

47 lines
1 KiB
Ruby

module VerifySetupCompleted
extend ActiveSupport::Concern
module_function
MANDATORY_CONFIGS = %i[
community_description
community_action
tagline
main_social_image
logo_png
mascot_user_id
mascot_image_url
meta_keywords
suggested_tags
suggested_users
].freeze
included do
# rubocop:disable Rails/LexicallyScopedActionFilter
before_action :verify_setup_completed, only: %i[index new edit show]
# rubocop:enable Rails/LexicallyScopedActionFilter
end
def setup_completed?
MANDATORY_CONFIGS.all? { |config| SiteConfig.public_send(config).present? }
end
private
def verify_setup_completed
return if config_path? || setup_completed?
link = helpers.link_to("the configuration page", internal_config_path)
# rubocop:disable Rails/OutputSafety
flash[:global_notice] = "Setup not completed yet, please visit #{link}.".html_safe
# rubocop:enable Rails/OutputSafety
end
def config_path?
request.env["PATH_INFO"] == internal_config_path
end
end