diff --git a/app/controllers/concerns/moments_concern.rb b/app/controllers/concerns/moments_concern.rb index 152283c6de..824d2b8c14 100644 --- a/app/controllers/concerns/moments_concern.rb +++ b/app/controllers/concerns/moments_concern.rb @@ -11,6 +11,10 @@ def publishing? params[:publishing] == '1' end + def display? + params[:display] == true + end + def saving_as_draft? !publishing? end diff --git a/app/controllers/moments_controller.rb b/app/controllers/moments_controller.rb index 8ded8b5592..c14f540a8f 100644 --- a/app/controllers/moments_controller.rb +++ b/app/controllers/moments_controller.rb @@ -27,6 +27,7 @@ def show show_with_comments(@moment) @resources = ResourceRecommendations.new(@moment).call @resources_tags = resources_url_tags(@moment) + @moment.resource_recommendations? end # GET /moments/new @@ -99,7 +100,7 @@ def set_moment def moment_params params.require(:moment).permit(:name, :why, :fix, :comment, :draft, - :bookmarked, + :bookmarked, :resource_recommendations, category: [], mood: [], viewers: [], strategy: []) end diff --git a/app/helpers/moments_form_helper.rb b/app/helpers/moments_form_helper.rb index 8b908c08ba..8705e30478 100644 --- a/app/helpers/moments_form_helper.rb +++ b/app/helpers/moments_form_helper.rb @@ -88,10 +88,10 @@ def moment_bookmarked end def moment_display_resources - moment_input_props('comment', 'switch', 'comment.allow_comments') + moment_input_props('resource_recommendations', 'switch', 'moments.resource_recommendations') .merge(value: true, - uncheckedValue: false, checked: @moment.comment, - info: t('comment.hint'), dark: true) + uncheckedValue: false, checked: @moment.resource_recommendations, + dark: true) end def moment_form_inputs diff --git a/app/models/moment.rb b/app/models/moment.rb index 5e22e5ffbb..04df3f41ae 100644 --- a/app/models/moment.rb +++ b/app/models/moment.rb @@ -17,6 +17,7 @@ # secret_share_expires_at :datetime # published_at :datetime # bookmarked :boolean +# resource_recommendations :boolean # class Moment < ApplicationRecord @@ -48,6 +49,7 @@ class Moment < ApplicationRecord validates :why, length: { minimum: 1 } validates :secret_share_expires_at, presence: true, if: :secret_share_identifier? + validates :resource_recommendations, inclusion: [true, false] scope :published, -> { where.not(published_at: nil) } scope :recent, -> { order('created_at DESC') } diff --git a/app/views/moments/show.html.erb b/app/views/moments/show.html.erb index 7fda5e03a1..077ac1eae1 100644 --- a/app/views/moments/show.html.erb +++ b/app/views/moments/show.html.erb @@ -43,16 +43,18 @@ <% end %> -<% if @resources.any? %> -